From 78c38743d8e9c43621915ad38d5a72931ad6f86f Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Thu, 6 Nov 2014 02:55:22 -0800 Subject: [PATCH] add address to scriptSig. --- example/index.js | 1 + src/bitcoindjs.cc | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/example/index.js b/example/index.js index 8ff9b249..b5e982f6 100755 --- a/example/index.js +++ b/example/index.js @@ -159,6 +159,7 @@ bitcoind.on('open', function(status) { if (argv['on-block']) { return bitcoind.on('block', function callee(block) { + if (block.tx.length === 1) return; bitcoind.log('Found Block:'); bitcoind.log(block); return assertHex(block); diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index 1ae2d69c..f447e9d9 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -5262,6 +5262,15 @@ ctx_to_jstx(const CTransaction& ctx, uint256 block_hash, Local jstx) { Local o = NanNew(); o->Set(NanNew("asm"), NanNew(txin.scriptSig.ToString())); o->Set(NanNew("hex"), NanNew(HexStr(txin.scriptSig.begin(), txin.scriptSig.end()))); + + CTransaction prev_tx; + if (GetTransaction(txin.prevout.hash, prev_tx, block_hash, true)) { + CTxDestination from; + ExtractDestination(prev_tx.vout[txin.prevout.n].scriptPubKey, from); + CBitcoinAddress addrFrom(from); + o->Set(NanNew("address"), NanNew(addrFrom.ToString())); + } + in->Set(NanNew("scriptSig"), o); in->Set(NanNew("sequence"), NanNew((unsigned int)txin.nSequence)->ToUint32());