add rpc to return pubkey

This commit is contained in:
blackjok3r
2018-10-24 12:12:18 +08:00
parent 5a363fdffc
commit c4ee47ec36
4 changed files with 36 additions and 15 deletions

View File

@@ -257,18 +257,6 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex)
return result;
}
void voutToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
{
UniValue vout(UniValue::VARR);
for (unsigned int i = 0; i < tx.vout.size(); i++) {
const CTxOut& txout = tx.vout[i];
UniValue out(UniValue::VOBJ);
out.push_back(Pair("hex", HexStr(txout.scriptPubKey.begin(), txout.scriptPubKey.end())));
vout.push_back(out);
}
entry.push_back(Pair("vout", vout));
}
UniValue getdatafromblock(const UniValue& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
@@ -335,18 +323,20 @@ UniValue getdatafromblock(const UniValue& params, bool fHelp)
UniValue result(UniValue::VARR);
unsigned int i = 0;
fprintf(stderr, "number of tx in block: %ld\n", block.vtx.size());
// Iif block tx size is > 2 then we can do this
BOOST_FOREACH(const CTransaction&tx, block.vtx)
{
//if the vout size = 3 then its a valid TX get the data. dont use the test here! it wont work with notarisations!
if ( (i == 0) || (i == (block.vtx.size() -1)) )
{
fprintf(stderr, "skipped tx number: %d \n",i);
} else {
fprintf(stderr, "added tx number: %d \n",i);
UniValue objTx(UniValue::VOBJ);
//voutToJSON(tx, uint256(), objTx);
//const CTxOut& txout = tx.vout[i];
//UniValue out(UniValue::VOBJ);
objTx.push_back(Pair("hex", HexStr(tx.vout[2].scriptPubKey.begin(), tx.vout[2].scriptPubKey.end())));
// function here to extract seqid from first and last TX
// we an push the data or not depending on input from RPC.
result.push_back(objTx);
}
i = i + 1;