fix ES6 issue, and actually verify the TXO

This commit is contained in:
Daniel Cousens 2018-02-01 13:14:34 +11:00
parent 31703e2e40
commit 6fc1273b7e

View file

@ -1,3 +1,4 @@
var assert = require('assert')
var bitcoin = require('../../') var bitcoin = require('../../')
var dhttp = require('dhttp/200') var dhttp = require('dhttp/200')
@ -44,7 +45,7 @@ function faucet (address, value, callback) {
function fetch (txId, callback) { function fetch (txId, callback) {
dhttp({ dhttp({
method: 'GET', method: 'GET',
url: APIURL + '/t/' + txId url: APIURL + '/t/' + txId + '/json'
}, callback) }, callback)
} }
@ -56,12 +57,12 @@ function unspents (address, callback) {
} }
function verify (txo, callback) { function verify (txo, callback) {
let { txId } = txo fetch(txo.txId, function (err, tx) {
fetch(txId, function (err, txHex) {
if (err) return callback(err) if (err) return callback(err)
// TODO: verify address and value var txoActual = tx.outs[txo.vout]
if (txo.address) assert.strictEqual(txoActual.address, txo.address)
if (txo.value) assert.strictEqual(txoActual.value, txo.value)
callback() callback()
}) })
} }