mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-19 13:27:35 +02:00
Merge f656165e9c into merged_master (Bitcoin PR #18772)
I'm gonna be honest, I largely just rewrote this one. It adds a "fee" field to the RPC transaction output, which I replaced with a feemap which is directly extracted from the transaction rather than computed implicitly from inputs - outputs. Removed a functional test that fee computations become impossible without chain data, since in Elements there is no chain data lookup involved.
This commit is contained in:
commit
658b2312da
5 changed files with 77 additions and 11 deletions
|
|
@ -203,16 +203,21 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIn
|
|||
result.pushKV("versionHex", strprintf("%08x", block.nVersion));
|
||||
result.pushKV("merkleroot", block.hashMerkleRoot.GetHex());
|
||||
UniValue txs(UniValue::VARR);
|
||||
for(const auto& tx : block.vtx)
|
||||
{
|
||||
if(txDetails)
|
||||
{
|
||||
if (txDetails) {
|
||||
CBlockUndo blockUndo;
|
||||
const bool have_undo = !IsBlockPruned(blockindex) && UndoReadFromDisk(blockUndo, blockindex);
|
||||
for (size_t i = 0; i < block.vtx.size(); ++i) {
|
||||
const CTransactionRef& tx = block.vtx.at(i);
|
||||
// coinbase transaction (i == 0) doesn't have undo data
|
||||
const CTxUndo* txundo = (have_undo && i) ? &blockUndo.vtxundo.at(i - 1) : nullptr;
|
||||
UniValue objTx(UniValue::VOBJ);
|
||||
TxToUniv(*tx, uint256(), objTx, true, RPCSerializationFlags());
|
||||
TxToUniv(*tx, uint256(), objTx, true, RPCSerializationFlags(), txundo);
|
||||
txs.push_back(objTx);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
for (const CTransactionRef& tx : block.vtx) {
|
||||
txs.push_back(tx->GetHash().GetHex());
|
||||
}
|
||||
}
|
||||
result.pushKV("tx", txs);
|
||||
result.pushKV("time", block.GetBlockTime());
|
||||
|
|
@ -1015,6 +1020,7 @@ static RPCHelpMan getblock()
|
|||
{RPCResult::Type::OBJ, "", "",
|
||||
{
|
||||
{RPCResult::Type::ELISION, "", "The transactions in the format of the getrawtransaction RPC. Different from verbosity = 1 \"tx\" result"},
|
||||
{RPCResult::Type::NUM, "fee", "The transaction fee in " + CURRENCY_UNIT + ", omitted if block undo data is not available"},
|
||||
}},
|
||||
}},
|
||||
}},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue