BlockCypher explorer如何获取有关已用或未用交易状态的数据?
{0: [1],
1: [0, 8, 2],
2: [8, 1, 4, 5],
8: [1, 2, 9, 10, 11, 12],
3: [4],
4: [2, 3],
5: [2, 6, 7],
6: [5, 7],
7: [5, 6],
9: [8, 10, 11, 12],
10: [8, 9, 11, 12],
11: [8, 9, 10, 12],
12: [8, 9, 10, 11]
}
库是否有一些方法?
答案 0 :(得分:0)
我不确定bitcoin-js
lib,但是Blockcypher具有API方法:
const fetch = require('cross-fetch')
const getAddress = async address => {
const url = `https://api.blockcypher.com/v1/btc/test3/addrs/${address}`
const res = await fetch(url)
return await res.json()
}
getAddress('mitTmNgXyoEANondxZns8dS6GcXTzVhJW6')
.then(({txrefs}) => txrefs.filter(tx => tx.spent === false))
.then(data => console.log(data))
您会得到类似的东西
[ { tx_hash: 'bdbd9253b052cb17afdf42c006c69f6d9f7513d2176db1c088fdbd2381edf2de',
block_height: 1519165,
tx_input_n: -1,
tx_output_n: 1,
value: 15800000,
ref_balance: 32343852,
spent: false, // @docs tx status
confirmations: 60,
confirmed: '2019-05-31T20:43:22Z',
double_spend: false },
{ tx_hash: '4014e09c48ec4de6c4f1e82b38107f4ca77037e96e4989abe5ba5cf459d57700',
block_height: 1519149,
tx_input_n: -1,
tx_output_n: 1,
value: 10000,
ref_balance: 17044852,
spent: false, // @docs tx status
confirmations: 76,
confirmed: '2019-05-31T18:43:02Z',
double_spend: false } ]