Thanks for the replies guys. @HCP I had already seen that page and was working on a program derived from that
I managed to output transactions as they are passed to the Bitcoin Core client via tx messages in real-time:
var zmq = require('zeromq')
, sock = zmq.socket('sub')
, RpcClient = require('bitcoind-rpc');
sock.connect('tcp://127.0.0.1:29000');
var config = {
protocol: 'http',
user: 'bitcoin',
pass: 'local321',
host: '127.0.0.1',
port: '8332',
};
var rpc = new RpcClient(config);
sock.subscribe('rawtx')
sock.on('message', function(topic, message) {
rpc.decodeRawTransaction(message.toString('hex'), function(err, resp) {
console.log(JSON.stringify(resp, null, 4)) // Change code here
})
})
Note: Should only be ran after Core's done verifying to prevent Core from crashing.
This is one of the thousands of transactions that are emitted by this:
{
"result": {
"txid": "d0c7061f2932aab93b4dfb1e7061ca06e7bceb2f46db2d8d31ae4af881079e14",
"hash": "e25d73f479b07feec55115afd670ac86ef3b8565eeff040a1e5b573f122da5f0",
"version": 2,
"size": 258,
"vsize": 176,
"weight": 702,
"locktime": 0,
"vin": [
{
"txid": "793c35452a0afe536b29ac282fd34bfa10a9b11e622c50a968e96828b4987980",
"vout": 2,
"scriptSig": {
"asm": "",
"hex": ""
},
"txinwitness": [
"3045022100f99d5710d33f49cc2dd8d697af8e84ffc3618ae1c8726c769d257d30e6c31dff0220149bb4f31fbda2078a91fba08c7060a135ecaf8c52b042cdf9a90dbd6ad4373701",
"026e5628506ecd33242e5ceb5fdafe4d3066b5c0f159b3c05a621ef65f177ea286"
],
"sequence": 4294967293
}
],
"vout": [
{
"value": 0.01963328,
"n": 0,
"scriptPubKey": {
"asm": "OP_DUP OP_HASH160 df8baa7ce04baa355dfdff9553315ba8a5092e73 OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a914df8baa7ce04baa355dfdff9553315ba8a5092e7388ac",
"reqSigs": 1,
"type": "pubkeyhash",
"addresses": [
"1MNzzwWMzL8fkBCeTZ5dZU3HL4o6WTX8qm"
]
}
},
{
"value": 0.0026072,
"n": 1,
"scriptPubKey": {
"asm": "OP_HASH160 908504c01b5b27b90087cbf945b9b846382ddd2c OP_EQUAL",
"hex": "a914908504c01b5b27b90087cbf945b9b846382ddd2c87",
"reqSigs": 1,
"type": "scripthash",
"addresses": [
"3EsAaTZAqqdPf8gVtxXnkMCh2dLCVk5bKE"
]
}
},
{
"value": 11.26734088,
"n": 2,
"scriptPubKey": {
"asm": "0 f60834ef165253c571b11ce9fa74e46692fc5ec1",
"hex": "0014f60834ef165253c571b11ce9fa74e46692fc5ec1",
"reqSigs": 1,
"type": "witness_v0_keyhash",
"addresses": [
"bc1q7cyrfmck2ffu2ud3rn5l5a8yv6f0chkp0zpemf"
]
}
}
]
},
"error": null,
"id": 9989
}
So from here I can inspect the vouts, and each "value" and "address". The question now is, although address is an array, it appears that each vout only corresponds to one address.
Can I safely take the first address in each vout and assume it has the value listed? Or will it ever emit multiple addresses in one out? (That doesn't make any sense though).