Fix samples

This commit is contained in:
Chris Clark
2015-10-30 15:22:03 -07:00
parent 7bc242bcd0
commit f722514ecf
2 changed files with 20 additions and 11 deletions

View File

@@ -24,18 +24,22 @@ const payment = {
}
};
function quit(message) {
console.log(message);
process.exit(0);
}
function fail(message) {
console.error(message);
process.exit(1);
}
api.connect().then(() => {
console.log('Connected...');
api.preparePayment(address, payment, instructions).then(txJSON => {
return api.preparePayment(address, payment, instructions).then(prepared => {
console.log('Payment transaction prepared...');
const signedTransaction = api.sign(txJSON, secret).signedTransaction;
const {signedTransaction} = api.sign(prepared.txJSON, secret);
console.log('Payment transaction signed...');
api.submit(signedTransaction).then(response => {
console.log(response);
process.exit(0);
}).catch(error => {
console.log(error);
process.exit(1);
});
api.submit(signedTransaction).then(quit, fail);
});
});
}).catch(fail);