Created
September 3, 2014 21:07
-
-
Save ice09/2f1aa773893a13f25e0a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ripple account to watch for payment | |
var acct = 'rDPe2PCQtxngg5euANuGiL9o9XEsNfim2g' | |
// API key for Mailgun | |
var api_key = 'key-'; | |
// Subdomain for Mailgun | |
var domain = 'domain.mailgun.org'; | |
// create Mailgun | |
var Mailgun = require('mailgun-js'); | |
var mailgun = new Mailgun({apiKey: api_key, domain: domain}); | |
// create Ribble lib | |
var Remote = require('ripple-lib').Remote; | |
var remote = new Remote({ | |
servers: [ 'wss://s1.ripple.com:443' ] | |
}); | |
remote.connect(function() { | |
// listen for transaction_all events | |
remote.on('transaction_all', function on(transaction) { | |
var trx = transaction.transaction | |
if (trx.Destination) { | |
console.log(trx.Account + " ==> " + trx.Destination + " [" + trx.Amount + "]") | |
if (trx.Destination == acct) { | |
var data = { | |
from: 'XRP Watcher', | |
to: 'me@web.de', | |
subject: 'XRP received', | |
text: 'You received ' + trx.Amount + ' from Account ' + trx.Account | |
} | |
mailgun.messages().send(data, function (error, body) { | |
console.log(body); | |
}); | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment