add cancel script

This commit is contained in:
Josh Harvey 2017-04-17 19:04:10 +03:00
parent 985e3811e3
commit d2700b4eb3
4 changed files with 58 additions and 8 deletions

25
bin/lamassu-cancel Executable file
View file

@ -0,0 +1,25 @@
#!/usr/bin/env node
const uuid = require('@fczbkk/uuid4')
const tx = require('../lib/cash-out-tx')
const argv = process.argv.slice(2)
if (argv.length !== 1) {
console.log('Usage: lamassu-cancel <tx-id>')
console.log('Cancels the cash out transaction with given tx-id so it cannot be dispensed.')
process.exit(1)
}
const txId = argv[0]
if (!uuid.validate(txId)) {
console.log('tx-id must be valid uuid. e.g.: f8093ded-c542-4916-8ab5-6ebeceb287c1')
process.exit(2)
}
tx.cancel(txId)
.then(() => console.log('Success.'))
.catch(err => console.log(`Error: ${err.message}`))
.then(() => process.exit(0))