Skip to content

Commit

Permalink
rpc: Strange (but historical) header formatting for dumptxoutset
Browse files Browse the repository at this point in the history
Github-Pull: bitcoin#18689
Rebased-From: 65d0697 [partial]
  • Loading branch information
pnn authored and luke-jr committed Feb 8, 2022
1 parent 58e0d32 commit 17d3ed7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/rpc/blockchain.cpp
Expand Up @@ -2808,10 +2808,12 @@ UniValue CreateUTXOSnapshot(
SnapshotMetadata metadata{tip->GetBlockHash(), stats.coins_count, tip->nChainTx};
afile << metadata;
} else {
afile.write("#(blockhash " + tip->GetBlockHash().ToString() + ")");
afile.write("#(blockhash " + tip->GetBlockHash().ToString() + " ) ");

for(const auto& text : { "txid", "vout", "value", "coinbase", "height", "scriptPubKey" }) {
afile.write(separator);
if (text != "txid") {
afile.write(separator);
}
afile.write(text);
}
afile.write("\n");
Expand Down
4 changes: 2 additions & 2 deletions test/functional/rpc_dumptxoutset.py
Expand Up @@ -65,7 +65,7 @@ def test_dump_file(self, filename, is_human_readable, expected_digest):
with open(expected_path, 'r', encoding='utf-8') as f:
content = f.readlines()
assert_equal(content[0].rstrip(),
"#(blockhash 6fd417acba2a8738b06fee43330c50d58e6a725046c3d843c8dd7e51d46d1ed6),txid,vout,value,coinbase,height,scriptPubKey")
"#(blockhash 6fd417acba2a8738b06fee43330c50d58e6a725046c3d843c8dd7e51d46d1ed6 ) txid,vout,value,coinbase,height,scriptPubKey")
assert_equal(content[1].rstrip(),
"213ecbdfe837a2c8ffc0812da62d4de94efce8894c67e22ff658517ecf104e03,0,5000000000,1,81,76a9142b4569203694fc997e13f2c0a1383b9e16c77a0d88ac")

Expand All @@ -77,7 +77,7 @@ def run_test(self):
self.generate(node, COINBASE_MATURITY)

self.test_dump_file('txoutset.dat', False, '7ae82c986fa5445678d2a21453bb1c86d39e47af13da137640c2b1cf8093691c')
self.test_dump_file('txoutset.txt', True, '5bc8a9c14d1f6d89833342dcd6014bdf9ddb5f19e3741760da6d6d666971df41')
self.test_dump_file('txoutset.txt', True, '5554c7d08c2f9aaacbbc66617eb59f13aab4b8c0574f4d8b12f728c60dc7d287')

if __name__ == '__main__':
DumptxoutsetTest().main()

0 comments on commit 17d3ed7

Please sign in to comment.