Skip to content

p2p_core%feat!: type the block, tx and BIP152 compact block messages - #135

Merged
PastaPastaPasta merged 2 commits into
developfrom
pasta/p2p-bip152-blocktx
Nov 18, 2026
Merged

PastaPastaPasta merged 2 commits into
developfrom
pasta/p2p-bip152-blocktx

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Motivation

dash-p2p-core recognises block, tx, cmpctblock, getblocktxn and blocktxn but hands their payloads back as raw bytes. A client that relays blocks, transactions or compact blocks has to lay out and parse each message itself. This pull request types the five messages. block and tx use the existing dash-primitives decoders. The message structs are named after their P2pMsg variants, as GetHeaders and GetBlocks are, where rust-bitcoin has HeaderAndShortIds, BlockTransactionsRequest and BlockTransactions. Only PrefilledTransaction, idx and prefilled_txs follow rust-bitcoin. The short ID is ShortTxId because ShortId already names the BIP324 short message ID in this crate. Computing short IDs is left to the caller.

Additional Information

Commit Notes Reference implementation
Type the block and tx messages P2pMsg::Block and P2pMsg::Tx carry Block and Transaction, decoded by the existing primitive decoders. dash-primitives already tests those codecs, so the test here checks only that block and tx payloads decode to these variants. block, tx
Type the BIP152 compact block messages ShortTxId, PrefilledTransaction, CmpctBlock, GetBlockTxn and BlockTxn in msg/compact.rs. A cmpctblock whose short IDs and prefilled transactions together exceed CmpctBlock::MAX_TX_COUNT is refused while reading the counts, which accepts and refuses the same inputs as the reference's check after both lists. A prefilled index that does not fit u16, and a getblocktxn index whose running sum does not fit u16, are refused while reading. GetBlockTxn::new and its deserialization take only strictly increasing indexes, the only lists the reference writes. Every section of the new corpus/compact.json5 is printed by the program above it, run in net_tests at v24.0.0. Its literals are, for blocks 1592894 and 1592891, a testnet peer's cmpctblock reply, the getblocktxn we sent for every transaction it left out, and the peer's blocktxn reply. compact block and combined count, prefilled transaction, 16-bit narrowing, differential indexes, block transactions

The getblocktxn index list and the blocktxn transaction list have no bound beyond ordinary vector decoding.

Consumers, all in the rust-dashcore node:

  • All five: the message reader in dash-p2p/src/read.rs.
  • CmpctBlock, GetBlockTxn and BlockTxn: compact block relay in dashd-p2p/src/processing/compact.rs.

Breaking Changes

P2pMsg::Block, P2pMsg::Tx, P2pMsg::CmpctBlock, P2pMsg::GetBlockTxn and P2pMsg::BlockTxn hold the typed messages instead of Vec<u8>, so code that builds or matches them must change, and a payload that does not decode as its message is now refused. P2pMsg::is_stub is false for them.

How Has This Been Tested?

just comb
cargo nextest run -p dash-p2p-core --all-features

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional tests
  • I have made corresponding changes to the documentation
  • I did not use agentic assistance (i.e. LLMs, AI) except as disclosed and can answer questions,
    comments and concerns without said assistance. I assume authorship of the code submitted.
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

Agent disclosure

Code was generated with Codex using GPT 6.1 Sol at high effort, with Muse Wonder at high effort, and with Claude Code using Claude Opus 5.5 at medium and high effort, running autonomously as agents on behalf of the author. The corpus programs, the capture of the testnet messages, commit messages and this description were generated with Claude Code using Claude Opus 5.5 at high effort. The agents also built the reference implementation's unit tests at v24.0.0 and ran the programs that wrote the vectors. The change was reviewed by a Claude Code agent using Opus 5.5 at high effort.

🤖 Generated with Claude Code

@PastaPastaPasta PastaPastaPasta added this to the 0.3 milestone Nov 18, 2026
@github-actions

Copy link
Copy Markdown

Note

This pull request has no conflicts! 🎊 🎉 🎊

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features
    • Added support for compact-block messages, including compact block data, requests for specific transactions, and responses containing transactions.
    • Block and transaction messages are now handled as structured peer-to-peer messages.
    • Compact-block transaction requests require indexes in ascending order, and compact-block payloads enforce limits on transaction counts and indexes.

The message module adds typed codecs for BIP152 compact-block messages, including count limits and validation of differential transaction indexes. It registers block, transaction, and compact-block commands as parsed messages instead of stubs. The changes also add tests for wire encoding, payload decoding, and serde behavior.

Suggested reviewers: kwvg, thepastaclaw

Merge Risk: Minimal · up to e22e6

This change replaces raw byte payloads for block, transaction and compact-block messages with typed messages that reject malformed input. It is a breaking API change for code that matches on these variants, but that is intended. No concrete defect was found, and the added tests cover the new limits and dispatch.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: typing the block, tx and BIP152 compact block P2P messages. The raw summary confirms this change, which moves those messages from raw bytes or stubs to typed payloads.…
Description check Passed The description states the motivation, lists the five typed messages, and explains the naming, limits, and breaking changes. It matches the changeset, which adds compact.rs types and re-registers the …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: typing the block, tx and BIP152 compact block P2P messages. The raw summary confirms this change, which moves those messages from raw bytes or stubs to typed payloads. The title uses the conventional type(scope)! form for a breaking change.

Full details: Description check

Explanation

The description states the motivation, lists the five typed messages, and explains the naming, limits, and breaking changes. It matches the changeset, which adds compact.rs types and re-registers the block, tx and BIP152 messages in mod.rs. It also covers the tests and the corpus file.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9d117ce and e22e6a5.

Files ignored due to path filters: 1

  • pkgs/p2p_core/corpus/compact.json5 is excluded by !**/*.json5
Files selected for processing: 2

  • pkgs/p2p_core/src/msg/blocks.rs
  • pkgs/p2p_core/src/msg/compact.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@PastaPastaPasta

Copy link
Copy Markdown
Member Author

/self-reviewed 681099d

@thepastaclaw

thepastaclaw commented Nov 18, 2026 •

Copy link
Copy Markdown

✅ Final review complete — no blockers (commit e22e6a5) · triage: critical

@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.56098% with 3 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
pkgs/p2p_core/src/msg/compact.rs 97.32% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@thepastaclaw thepastaclaw left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final validation — Phase 1 + Phase 2

Updated after discussion: 1 finding(s) of this review were settled in the inline threads.

  • ✅ Withdrawn: 🟡 Add a direct regression test for oversized prefilled indexes

The implementation correctly types the five relay messages, preserves Dash Core wire semantics, and applies the relevant bounds before allocation or narrowing. One in-scope test-coverage gap remains: the new prefilled-index narrowing path is not exercised by a p2p_core decode-error test. CI functional and platform checks passed; the lint failure is limited to cargo-deny advisories for unchanged transitive dependencies (chrono and libz-sys).

🟡 1 0 suggestion(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

Review provenance

Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); reviewer 4: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 5: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — This is a large, intricate change to peer-facing network deserialization in pkgs/p2p_core/src/msg/compact.rs and related message decoding, including bounds and index validation for remotely supplied payloads.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `pkgs/p2p_core/src/msg/compact.rs`:
- [SUGGESTION → WITHDRAWN in discussion; do not fix] pkgs/p2p_core/src/msg/compact.rs:47-53: Add a direct regression test for oversized prefilled indexes
  `PrefilledTransaction::decode` correctly uses `CompactSize::decode_as::<u16>`, so an index greater than `u16::MAX` is rejected rather than truncated. However, the p2p_core tests cover the analogous compact-block count and getblocktxn differential-index failures without exercising this new wire path; the existing generic dash-types test does not protect the message-level wiring. Add a direct case that encodes `65536` followed by a minimal transaction and asserts `CompactSizeExceedsLimit`.

Comment on lines +47 to +53
impl BaseCodec for PrefilledTransaction {
fn decode(data: &mut &[u8]) -> Result<Self, DecodeError> {
Ok(Self {
idx: CompactSize::decode_as(data)?,
tx: Transaction::decode(data)?,
})
}

@thepastaclaw thepastaclaw Nov 18, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Withdrawn at e22e6a5a; see the replies below.

🟡 Suggestion: Add a direct regression test for oversized prefilled indexes

PrefilledTransaction::decode correctly uses CompactSize::decode_as::<u16>, so an index greater than u16::MAX is rejected rather than truncated. However, the p2p_core tests cover the analogous compact-block count and getblocktxn differential-index failures without exercising this new wire path; the existing generic dash-types test does not protect the message-level wiring. Add a direct case that encodes 65536 followed by a minimal transaction and asserts CompactSizeExceedsLimit.

Suggested change
impl BaseCodec for PrefilledTransaction {
fn decode(data: &mut &[u8]) -> Result<Self, DecodeError> {
Ok(Self {
idx: CompactSize::decode_as(data)?,
tx: Transaction::decode(data)?,
})
}
#[rstest]
fn prefilled_index_is_narrowed_to_u16() {
let mut raw = Vec::new();
CompactSize::from(u64::from(u16::MAX) + 1).encode(&mut raw);
tx().encode(&mut raw);
assert_eq!(
PrefilledTransaction::decode(&mut raw.as_slice()),
Err(DecodeError::CompactSizeExceedsLimit {
limit: u16::MAX as usize,
value: u64::from(u16::MAX) + 1,
})
);
}

source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not adding this one. The bound comes from the u16 field and CompactSize::decode_as; PrefilledTransaction::decode adds no check of its own. dash-types tests that type bound in decode_as_bounds_the_value_by_the_type, and an earlier review of this PR dropped the same test for that reason. The getblocktxn case is tested here because GetBlockTxn::decode does its own range check on the running sum.


🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this is not needed to establish correctness: PrefilledTransaction::decode delegates the range check directly to the generic CompactSize::decode_as, and the shared dash-types tests cover that contract. A message-level case could improve coverage, but it is optional rather than a defect or merge requirement, so I’m withdrawing the suggestion.

Withdrawing this finding.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Withdrawn (re-reviewed at e22e6a5a): You're right that idx: u16 selects the same checked conversion path exercised by the generic decode_as test. The current head adds no prefilled-index arithmetic or separate range check, so I'm leaving the suggestion withdrawn.

@github-actions github-actions Bot added the status:behind This pull request can be rebased on the base branch. label Nov 18, 2026
@PastaPastaPasta
PastaPastaPasta force-pushed the pasta/p2p-bip152-blocktx branch from 681099d to 9d117ce Compare November 18, 2026 06:05
@github-actions github-actions Bot removed the status:behind This pull request can be rebased on the base branch. label Nov 18, 2026
@PastaPastaPasta

Copy link
Copy Markdown
Member Author

Ready for steward review at 9d117ce

Rebased onto develop at 3fd31ae (#136) with no other change. Fork just comb passed on both commits (run 44248797381).

$ git range-diff eda56fb2..681099d4 3fd31ae3..9d117ce0
1:  1916e7fe = 1:  39472203 p2p_core%feat!: type the block and tx messages
2:  681099d4 = 2:  9d117ce0 p2p_core%feat!: type the BIP152 compact block messages

🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.

@PastaPastaPasta PastaPastaPasta left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Steward review at 9d117ce: one more push, all conventions. The independent review and my own pass found nothing wrong with what the five messages accept, refuse or write:

  • field order, widths and endianness match the reference at v24.0.0 (blockencodings.h L22-L42, L56-L80, L116-L125; serialize.h L713-L726);
  • the combined count, the 16-bit prefilled index and the differential getblocktxn indexes refuse the same byte strings as the reference. CompactSize::decode caps each difference, so the running sum cannot overflow;
  • the testnet rows are what their comments say. Both blocks' merkle roots recompute, and every short ID in the cmpctblock rows recomputes from its block's transactions;
  • fork just comb passes on both commits, and CI passes on this head.

Changes (each in the commit that added the code, then force-push):

  1. Struct docs are headlines (compact.rs:19, :31-32, :36, :115-116, :193). "A struct's doc is a headline. Decoder and encoder facts go on the BaseCodec::decode and encode docs" (#86, #87). The CompactSize offsets, the 16-bit narrowing and the differential encoding move to the decode/encode docs, or go. Compare "A filterload payload." and "The filter of one block." on develop.
  2. No block and tx corpus in dash-p2p-core (3947220: corpus/blocks.json5 block and tx sections and their program, corpus_block and corpus_tx in blocks.rs). dash-primitives already proves the Block and Transaction codecs. What this crate adds is the command-to-variant mapping, which is a plain read in the reference. "Test a property once, in the crate that owns it. Consumers test only their own mapping onto it" (design rulings §5). The govobj and govobjvote variants have no corpus here either. Replace them with one rstest that checks decode_payload maps block and tx bytes to P2pMsg::Block and P2pMsg::Tx.
  3. combined_counts_are_bounded without the branch (compact.rs:228-255). The if full == 0 builds a different payload, limit and value in each arm, so the reader has to work out which case runs which arm ("Clever code golf is hard to read", #87). Split it into two plain tests, one for the short-ID count and one for the prefilled count, or pass the expected limit and value as case parameters.
  4. Description: names. rust-bitcoin names the message structs HeaderAndShortIds, BlockTransactionsRequest and BlockTransactions. This PR names them after their variants, as GetHeaders and GetBlocks are. Say that. Only PrefilledTransaction, idx and prefilled_txs follow rust-bitcoin.
  5. Description: disclosure. Give the effort for each authoring model, not only for the reviewer.

Considered and not asked for

  • Constraining CmpctBlock::new and its deserialization to MAX_TX_COUNT. encode can then write a list decode refuses, but the reference's writer does the same. This was declined on #128 for IsdLock and Spork. GetBlockTxn is different: an unordered list would make encode subtract past zero. It goes in the log as a judgment call.
  • A reference row with a gapped getblocktxn request or a non-zero prefilled index. The rows are captured testnet traffic, and the sum case covers gap encoding.

After the push: post the ready line with the range-diff from 9d117ce. I will check the range myself. If it holds only these changes, there is no further review round.


🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.

`block` and `tx` decode with the existing primitive decoders.
Decode `cmpctblock`, `getblocktxn` and `blocktxn`. A `cmpctblock`
carries at most `CmpctBlock::MAX_TX_COUNT` short IDs and prefilled
transactions together.
@PastaPastaPasta
PastaPastaPasta force-pushed the pasta/p2p-bip152-blocktx branch from 9d117ce to e22e6a5 Compare November 18, 2026 21:45
@PastaPastaPasta

Copy link
Copy Markdown
Member Author

Ready for steward review at e22e6a5

Fork just comb passed on both commits (run 44390013114). The description now says how the structs are named and gives each authoring model's effort.

git range-diff --creation-factor=100 3fd31ae3 9d117ce0 e22e6a5a
1:  39472203 ! 1:  24640927 p2p_core%feat!: type the block and tx messages
    @@ Metadata
      ## Commit message ##
         p2p_core%feat!: type the block and tx messages
     
    -    `block` and `tx` decode with the existing primitive decoders, with
    -    vectors printed by the reference implementation at v24.0.0.
    -
    - ## pkgs/p2p_core/corpus/blocks.json5 ##
    -@@
    - //
    - // Block relay vectors. Generated with the reference
    --// implementation (dashpay/dash v24.0.0-rc.3, 0364ed626e).
    -+// implementation (dashpay/dash v24.0.0-rc.3, 0364ed626e), except
    -+// `block_tx_payloads`, run at v24.0.0 (938fba5028) on blocks captured from
    -+// one testnet peer on 2026-11-16.
    - //
    - // Each section comes with the program used to generate the vectors.
    - //
    -@@ pkgs/p2p_core/corpus/blocks.json5: BOOST_AUTO_TEST_CASE(getblocks_payloads)
    -       }
    -     },
    -   },
    -+/*
    -+BOOST_AUTO_TEST_CASE(block_tx_payloads)
    -+{
    -+    // Testnet block 0000000c19cb9d0928ccf448d50a62605e0539d0450e34d7d6d16a6c032be53f at height 1592894, the block reply to getdata.
    -+    constexpr char BLOCK_1592894[] =
    -+        "0000002039b6faeaf20337ab6fc43eeb00a8fd2cb86882c7829d7532db2530559700000014eeda990119c7e36b99d9ada2ace3a56e0934f599005cd03bc667d998ad6d38b845fb6a25fe001e0faa05000703000500010000000000000000000000000000000000000000000000000000000000000000ffffffff016affffffff03cb4d8c03000000001976a914b489115851ca07a26a5ad8bac3cec3c7dbebd83188ac2ed5fd0300000000016a3214a706000000001976a91464f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d788ac00000000cf04003e4e1800fb8ba050a8320b0ba74d1efb092faa19d5c0e32ac5d50a37dd6ff256a5065c3be8506d814cdd0c13aac6ab36860016f52ceb303420b4adc6117b97893f89fc1600b26526a325de13f29f214d2742dfc3a85c8e9f3d07b4ffb5fb563b53e44ddd27cb590d30518af7540051de8251fab27d0b15df595abe387bbee1cde961ccfecc9c60fe0c5db6b640be5576cbf662e8cb832d1a761a874d8a3d6d356127186237882df554e922000000000000000000000000000000000000000000000000000000000000000000000200000003f2d13a03aba96a1011e3be39d0ee6ae6831215b5c5dabbc52392891857cee796000000006a47304402207e562bc9470a065f1ced82320e8072e2596d8f3e030139c7eeec487c8d2a67d402204fa8d4f40d100c0095b8e1e6f9a388f968820c06cc89ad562684d4a8c200e400812103c51a04888b9e957e8704054e0a38f9ede9501093b44021a3bd5779ee67f0691cffffffff56bedbd3621a3ad1ee105d2918edc0030919fd138b3b274a1fa2f0c6806934ab020000006a47304402202ee66d8d29ee8a9124ac0e697c8d37f476add63823d2451fa63a498c9202cbb70220072708a01dea0f88805ec9ee636a014a0f8053b301d58314ba6ac2257455c144812103b4337fdd89b0f872732d51616480506571e1906dcab4de49403357f8303cc2acffffffff16a15201d610acb54c682339dbe1749f62390337ab967040d2fa2405a5ac50b5060000006a4730440220704f235fb0021b44cbfea4bb112fba12071a05e51ba2abd34667638119ccbc4b02206c3620f4b2c7721f71833f3c6a2afac584eb4b9dbe2422d1f922f8b468a7a28d8121030b9622e1ca8310ea3394c25977b90c9058b57afec82e1f30a221be6bea928800ffffffff0310f19a3b000000001976a9144fffb09caab83ed8a12a27d5d9ad162996194d5288ac10f19a3b000000001976a91462f111004a7c77a1a4004c0813b9b37b592b20e188ac10f19a3b000000001976a914889f16de6b2c6846d2794c977f17b23a542793b888ac0000000002000000063dd9143945f424bdf7b6af0925ad6be57001c28b3a9bd84f7bc50085abd7040b060000006a4730440220634d6b8d6e60c56c72270fcdc9edd74edbc6777b67a1b7797d0b3095aada53c902203354950807f3102d157303938e21841091db3c16c93d6be3e9afffd696e577508121035f011e4aa2662ccd27372c055e2776d9983c2de4d26b34e494acd91690a654acffffffffd866c61566fef17a26a3ce130d829e4eca5738e5fcead2281e81d036e794d858170000006a47304402201a68f16bd3f8310364c16f588c0a9ff55838bb8756320a36395ef89aa01f6c73022064dc3c4bf1b7873b5defff325ea66c3aac212e1a23f3396bddeec2f0ada730368121024a926de7bf6ec3476b7921f6941d2add8977c554c5639d610b1ee22f03aff1d6ffffffffe4c3b6ba1ccfa9e6f538371cfbca4f8196276a92f9591569e19206931568ee86000000006a4730440220023c6c2d3038555b09da01588e28b4a67b05d0c090dc35439fb9e3b5e72791d002201fb89f2fbc0ab5e74a14a2ef00faaa39cf5c0a125980b04c7825e2378eebe826812103ad83a1965bc0bdc01eaf5050e19d3904cc07295f42b2b6f0cd23b383d3a4ccdbffffffff31ffa6005733c5fea18cc7cff1ea009bf11e7f62a06e07834bab7c940a1882c4090000006a47304402205613821a65ec758b5e3461c5c9e8c0a65fb8d08be704953ad71e871ad55c1062022013267c4818d6c347f7f9551bc2da25a3cd07c0266bec4a72908d4849da1960608121026238d241af712a46891a7af1fba01eecc83170d4646847c4a92583a50a65c7beffffffff43f1349ec56f06359ce651473eed260cc229566451da7885f92d003e5a1a2ed1060000006a47304402207ca8ea5c0274206cfb5bb085f60698eb1557b6191b6d42cd7edc649c8e45448802207da39e0c3091398893335a297c3bfc26ad6d15a63ff01db4dc32b1b1eac35af28121037fa9accebb4883ddfee2e492475b71a9989f3e77615c330437c389bf7b07cd1effffffff4ec041bd994ae19d084215eb8120a80aa34b1e6f35931fa323945b283df3f7dd170000006a4730440220295b9d87be939430e91957ddd77981362aea4134ca9bd70027c5d6b00d48029902206871c100b8ca0125251949776f549ef23e863e682f8cc5363df7ba068224007781210241381695b0aee6e81eb28cdfbb003e5aa50843c70887a9eb0f61cde39c4b1de3ffffffff06e8e4f505000000001976a9140059ec50310b62423ef9459460ff76ddd9eb78be88ace8e4f505000000001976a91456669cf22d810e82052f83f315f71af1188c1f8988ace8e4f505000000001976a91483554baf827b505744b93bb0ddff2b29c373440a88ace8e4f505000000001976a9148e7e59300beb8241301eb71e42849fbaf3ccff3088ace8e4f505000000001976a91494bda7fa8b10359fc4ef2744fb65f1f0f7241fb688ace8e4f505000000001976a914dbf03f42aa7e0d2395b53198df04dbd2ed88bd0688ac000000000200000001e0f5aa482e2b22a298213a784cde77c273389ca1531a1a72278e7ad109c18a4b010000006a4730440220101abd6152650ed0d87485188c8bd84004554705b23132912cf5b0b7fbca1f3b02201713e1d594f6f4cd21b615960e690daf85f2b1e52e598978177551311d4e6ecb0121030a211b57934fc2a1cd18f9390e11e58164db7687a61d237502c1a015b064eb52ffffffff04a8630300000000001976a914a6d85bbc165dcaa903a8c4b75210395cb733348f88ac8f510300000000001976a914beeb3d50fe6af4eaead1b4ef95608c4ac1c810e488ac0cf80100000000001976a9147ee0bfdab6c808024a459d09b8b91a956f453f7a88acdb980200000000001976a914eda6626bbcfc960d886c553587c86d7ab825a3a788ac000000000200000001306372f9076911ab7adaeb3d93d751dc6da844791f577109f031d2f1000ab4fb020000006a4730440220196299b7b942cf90df5edeb7a14a3297f4d8eff28ff1181e53a00b6208e11c09022019d5ca5b7797de23014da2f8ed63b739b2172e598160caf0ba3c2c387ccf94100121026293fbf4806abf069a9ef7464c34dc1780e053e86aa7b58a1eecb7f76a0ee446ffffffff05b21d0200000000001976a914baebbad073fed1e2ffa50d4b09291d5b0e00c02d88ac4bf20100000000001976a9144d0e4a45aa0540f4ad0163f6f522eb66f87edc2188ac19780200000000001976a914a9cc4d8048c0b0d52b3c35b2af2c138d1f17b6d688acfd620200000000001976a9145a325dbe32e63da25225d9f3e11c7bd096b15d3c88ac6ea80200000000001976a914b8a7177e6bfb33dd578c18e005111798b8ecf49488ac000000000200000001c2e03c87f29210606e1acd022534eeedfd8f6a2608be18e7e70c1465538eba1a0b0000006a47304402204ace6498ae54cdb311284cea050409087e7bf7207df8c41a0ebbc5726c83200b022023a1928f5489fd133403e57ceb13986d6f8a9236437162faef4beb24cb02d8f5012103fd9eaada791523da0270d0c584a072c3110c52632e8ecd79114be0b7ab6f36e0ffffffff057e920200000000001976a914529f1f96c542c0ffb8d3a5bb690d9cadff2d92d588acd0a30200000000001976a91450ee917d6c6e0556fc99c68ed1596c730be6d30688acda0a0200000000001976a91410b7cd826e3750ec0a24139473975721b59c2d4888acbeb70100000000001976a9140854d05f62b8d112ea44d47dc853edfbcf5cb72588ac3ca20200000000001976a91453197867304cfac6065b225580aa45f627be2e9688ac0000000002000000013e42cc4f3a16255eec2340c28d44dbee6594219d73acef242ff0170903e37a7c010000006a47304402201c6277b9c4506d9d468f9539a13899d239d09e952d1061593d79d1e23336ed950220235058e0168e231b2b655b8b9119b559ff4de395d548b5d558351b72333d9467012103f8623d78e6a3a447bd853615cbdd40d15ce4cd81969c1d4d8c0e5c4d17cb3593feffffff02409c0000000000001976a91411a2855ec9c346ca8432b205795e839807b093e488ac00fe0200000000001976a9143545219b20be31d759b7861f1761b740615ebd2088ac3d4e1800";
    -+    // Testnet block 000000a7d51270cdd8ba9080312cd9880889cf3417ca07c025a0382acf0db110 at height 1592891, the block reply to getdata.
    -+    constexpr char BLOCK_1592891[] =
    -+        "0000002046165b23936a4b0740638b1447a2d5a6fce55b425c40d429818b518f7c000000e1e22e2acf67610f6bebe1e52a9efa2f87109025b91323987d8c79bf10179c6d5d44fb6a2406011ee14200000403000500010000000000000000000000000000000000000000000000000000000000000000ffffffff016affffffff03b84b8c03000000001976a914b489115851ca07a26a5ad8bac3cec3c7dbebd83188ac2ed5fd0300000000016af80da706000000001976a91464f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d788ac00000000cf04003b4e1800fb8ba050a8320b0ba74d1efb092faa19d5c0e32ac5d50a37dd6ff256a5065c3be8506d814cdd0c13aac6ab36860016f52ceb303420b4adc6117b97893f89fc1600a97b564be55309f14aba8e85e51f41884cfefbdb7e0d54d5fcda1435ac4454a8548533e2e72ee80969e259e852d7ef8811c6cb891881846292d2a81ff47f67e52e3ebbcaa0be63061150f54994d5da8779a268c752a16570a5c21f6bf2ac9b54feadfb48e9220000000000000000000000000000000000000000000000000000000000000000000003000600000000000000fd490101003b4e1800030001c96737f5a923a20fa28e9e3785d33d200dc5882e164fa71c8be42ee53600000032fffeffffffff0332fffeffffffff03b7920bc1fa929f99c8703a94e8ae4391a8f1e87577567477fa40550498001bcc1a495bd2b888c9060a0953c6fb6fab1ba6d61e3b06efabda63cc9a14c262b86769756d3ed49f6724a30890577925c1248fed286b469b83ac2ddff15a1cc19da3e93c4deb706a2d1e6c20a035eb53bdf36a5a543e87250ed3667454793d14723516340bbff7384216691cd6fc7bea8a69cd52426cbbad77eda67daa8eee747089985b6f6e0e46c1b673433356f42b7e2aa73c934a6f5e5af93abd7c9967fc400552d2cc47a7e72c56f4e725f99e5060eab6bd31a00f2a614fb2bc944e271cd6aa027795983cde31795934bdd81ee4d3987e2ade80bb4275c059e53af99956243526e486d865930cb3f2b2d714553aa41f03000600000000000000fd550101003b4e1800030004c96737f5a923a20fa28e9e3785d33d200dc5882e164fa71c8be42ee53600000064fffffffffffffffbffffffff0f64ffffffffffffffffffffffff0f8e3d8c6c17fe7be5ea668f40adf4f70acf8067ec5431e801e47a72bfcd6d0d2f1025444819b20c8e3e025177fdf7324e51a58cacfd373e166e9ce552b28c255f272b2a0a0158c2e3a874d4ff5a444332a2e31f9806fdac0e5c67fdfb91788fa2c78dc38f81073c0249e4e04b27bf8fec908ae8475eba171921879f936d20e04c16538c36306c52fbfc59eeb4852d5ab7371ce6ff3a46707f5f2de02d691fde8a3b1ea1259ad0d0a0c73457b98d799906b2c5303c6b6573cf29a269d6e9d7b407d35f901fa5ffa9af8d5038fa5b7cde9deba48a55df35590fa08cd82c05ee615b085805d6a13271e7aecc90e22c51b20ae0f98508cb5d866aa9a5a16b8799c09bd2e9c057516f462c6ec1e525536a8fd703000600000000000000fd430101003b4e1800030006c96737f5a923a20fa28e9e3785d33d200dc5882e164fa71c8be42ee53600000019ffffff0119ffffff018dbaebf8abcb16b40ba6731f7b8879ed980da175d582083b4f2aa22c9343e347fe202c6985b688179455034006c50a97cb8e5552ef0f88b6f536d4b2d742945abc665978199891fbd057d0e92e936b4194e33fe2c20559ce48006839271a5fad479d04f2fa8d1a8e04b0e0b211845e2b67aee4f16a4d8b1e4f61005aaa866b2e135b0222afe6d67c744eaedd63d2a45646ee26829425e47bd8c1bb6d4bf5cedc9338ef8c1b348b764e2130d22e311cf6a912ae0b509e195d6780ca879d953a7716b826604f59cd672273067f221b6fdcecde2f82f641efe059fbe245e7faf1ae097e0f39ce092b8da8a6feefccf4bc22f6e43abf2c1a25fb4ad2e63c2b88d5023dba7dca401115db28d0cceb803647a6";
    -+    const auto tx_json = [](const CTransaction& tx) {
    -+        std::string inputs, outputs;
    -+        for (const auto& in : tx.vin) {
    -+            inputs += strprintf("%s{\"prevout\": {\"hash\": \"%s\", \"index\": %u}, \"scriptSig\": \"%s\", \"sequence\": %u}",
    -+                                inputs.empty() ? "" : ", ", in.prevout.hash.ToString(), in.prevout.n, HexStr(in.scriptSig), in.nSequence);
    -+        }
    -+        for (const auto& out : tx.vout) {
    -+            outputs += strprintf("%s{\"value\": %d, \"scriptPubKey\": \"%s\"}", outputs.empty() ? "" : ", ", out.nValue, HexStr(out.scriptPubKey));
    -+        }
    -+        return strprintf("{\"version\": %d, \"txType\": %u, \"inputs\": [%s], \"outputs\": [%s], \"lockTime\": %u, \"extraPayload\": \"%s\"}",
    -+                         tx.nVersion, tx.nType, inputs, outputs, tx.nLockTime, HexStr(tx.vExtraPayload));
    -+    };
    -+    const auto row = [](const std::string& comment, const std::string& label, const std::string& raw, const std::string& details) {
    -+        std::printf("    // %s\n    \"%s\": {\n      \"raw\": \"%s\",\n      \"details\": %s\n    },\n",
    -+                    comment.c_str(), label.c_str(), raw.c_str(), details.c_str());
    -+    };
    -+    std::vector<std::pair<int, CBlock>> blocks;
    -+    for (const auto& [height, raw] : std::vector<std::pair<int, const char*>>{{1592894, BLOCK_1592894}, {1592891, BLOCK_1592891}}) {
    -+        DataStream input{ParseHex(raw)};
    -+        input >> blocks.emplace_back(height, CBlock{}).second;
    -+        BOOST_REQUIRE(input.empty());
    -+        DataStream output{};
    -+        output << blocks.back().second;
    -+        BOOST_REQUIRE_EQUAL(HexStr(output), raw);
    -+    }
    -+
    -+    std::printf("  \"block\": {\n");
    -+    for (const auto& [height, block] : blocks) {
    -+        DataStream raw{};
    -+        raw << block;
    -+        std::string types, transactions;
    -+        for (const auto& tx : block.vtx) {
    -+            types += strprintf("%s%u", types.empty() ? "" : ", ", tx->nType);
    -+            transactions += strprintf("%s%s", transactions.empty() ? "" : ", ", tx_json(*tx));
    -+        }
    -+        row(strprintf("Testnet block %d, transaction types %s.", height, types), block.GetHash().ToString(), HexStr(raw),
    -+            strprintf("{\"header\": {\"version\": %d, \"prevHash\": \"%s\", \"merkleRoot\": \"%s\", \"time\": %u, \"bits\": %u, \"nonce\": %u}, "
    -+                      "\"transactions\": [%s]}",
    -+                      block.nVersion, block.hashPrevBlock.ToString(), block.hashMerkleRoot.ToString(), block.nTime, block.nBits, block.nNonce,
    -+                      transactions));
    -+    }
    -+    std::printf("  },\n");
    -+
    -+    std::printf("  \"tx\": {\n");
    -+    std::set<uint16_t> types;
    -+    for (const auto& [height, block] : blocks) {
    -+        for (const auto& tx : block.vtx) {
    -+            if (!types.insert(tx->nType).second) continue;
    -+            DataStream raw{};
    -+            raw << *tx;
    -+            row(strprintf("First type %u transaction of these blocks, from testnet block %d: inputs %u, outputs %u, extra payload %u bytes.",
    -+                          tx->nType, height, tx->vin.size(), tx->vout.size(), tx->vExtraPayload.size()),
    -+                tx->GetHash().ToString(), HexStr(raw), tx_json(*tx));
    -+        }
    -+    }
    -+    std::printf("  },\n");
    -+}
    -+*/
    -+  "block": {
    -+    // Testnet block 1592894, transaction types 5, 0, 0, 0, 0, 0, 0.
    -+    "0000000c19cb9d0928ccf448d50a62605e0539d0450e34d7d6d16a6c032be53f": {
    -+      "raw": "0000002039b6faeaf20337ab6fc43eeb00a8fd2cb86882c7829d7532db2530559700000014eeda990119c7e36b99d9ada2ace3a56e0934f599005cd03bc667d998ad6d38b845fb6a25fe001e0faa05000703000500010000000000000000000000000000000000000000000000000000000000000000ffffffff016affffffff03cb4d8c03000000001976a914b489115851ca07a26a5ad8bac3cec3c7dbebd83188ac2ed5fd0300000000016a3214a706000000001976a91464f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d788ac00000000cf04003e4e1800fb8ba050a8320b0ba74d1efb092faa19d5c0e32ac5d50a37dd6ff256a5065c3be8506d814cdd0c13aac6ab36860016f52ceb303420b4adc6117b97893f89fc1600b26526a325de13f29f214d2742dfc3a85c8e9f3d07b4ffb5fb563b53e44ddd27cb590d30518af7540051de8251fab27d0b15df595abe387bbee1cde961ccfecc9c60fe0c5db6b640be5576cbf662e8cb832d1a761a874d8a3d6d356127186237882df554e922000000000000000000000000000000000000000000000000000000000000000000000200000003f2d13a03aba96a1011e3be39d0ee6ae6831215b5c5dabbc52392891857cee796000000006a47304402207e562bc9470a065f1ced82320e8072e2596d8f3e030139c7eeec487c8d2a67d402204fa8d4f40d100c0095b8e1e6f9a388f968820c06cc89ad562684d4a8c200e400812103c51a04888b9e957e8704054e0a38f9ede9501093b44021a3bd5779ee67f0691cffffffff56bedbd3621a3ad1ee105d2918edc0030919fd138b3b274a1fa2f0c6806934ab020000006a47304402202ee66d8d29ee8a9124ac0e697c8d37f476add63823d2451fa63a498c9202cbb70220072708a01dea0f88805ec9ee636a014a0f8053b301d58314ba6ac2257455c144812103b4337fdd89b0f872732d51616480506571e1906dcab4de49403357f8303cc2acffffffff16a15201d610acb54c682339dbe1749f62390337ab967040d2fa2405a5ac50b5060000006a4730440220704f235fb0021b44cbfea4bb112fba12071a05e51ba2abd34667638119ccbc4b02206c3620f4b2c7721f71833f3c6a2afac584eb4b9dbe2422d1f922f8b468a7a28d8121030b9622e1ca8310ea3394c25977b90c9058b57afec82e1f30a221be6bea928800ffffffff0310f19a3b000000001976a9144fffb09caab83ed8a12a27d5d9ad162996194d5288ac10f19a3b000000001976a91462f111004a7c77a1a4004c0813b9b37b592b20e188ac10f19a3b000000001976a914889f16de6b2c6846d2794c977f17b23a542793b888ac0000000002000000063dd9143945f424bdf7b6af0925ad6be57001c28b3a9bd84f7bc50085abd7040b060000006a4730440220634d6b8d6e60c56c72270fcdc9edd74edbc6777b67a1b7797d0b3095aada53c902203354950807f3102d157303938e21841091db3c16c93d6be3e9afffd696e577508121035f011e4aa2662ccd27372c055e2776d9983c2de4d26b34e494acd91690a654acffffffffd866c61566fef17a26a3ce130d829e4eca5738e5fcead2281e81d036e794d858170000006a47304402201a68f16bd3f8310364c16f588c0a9ff55838bb8756320a36395ef89aa01f6c73022064dc3c4bf1b7873b5defff325ea66c3aac212e1a23f3396bddeec2f0ada730368121024a926de7bf6ec3476b7921f6941d2add8977c554c5639d610b1ee22f03aff1d6ffffffffe4c3b6ba1ccfa9e6f538371cfbca4f8196276a92f9591569e19206931568ee86000000006a4730440220023c6c2d3038555b09da01588e28b4a67b05d0c090dc35439fb9e3b5e72791d002201fb89f2fbc0ab5e74a14a2ef00faaa39cf5c0a125980b04c7825e2378eebe826812103ad83a1965bc0bdc01eaf5050e19d3904cc07295f42b2b6f0cd23b383d3a4ccdbffffffff31ffa6005733c5fea18cc7cff1ea009bf11e7f62a06e07834bab7c940a1882c4090000006a47304402205613821a65ec758b5e3461c5c9e8c0a65fb8d08be704953ad71e871ad55c1062022013267c4818d6c347f7f9551bc2da25a3cd07c0266bec4a72908d4849da1960608121026238d241af712a46891a7af1fba01eecc83170d4646847c4a92583a50a65c7beffffffff43f1349ec56f06359ce651473eed260cc229566451da7885f92d003e5a1a2ed1060000006a47304402207ca8ea5c0274206cfb5bb085f60698eb1557b6191b6d42cd7edc649c8e45448802207da39e0c3091398893335a297c3bfc26ad6d15a63ff01db4dc32b1b1eac35af28121037fa9accebb4883ddfee2e492475b71a9989f3e77615c330437c389bf7b07cd1effffffff4ec041bd994ae19d084215eb8120a80aa34b1e6f35931fa323945b283df3f7dd170000006a4730440220295b9d87be939430e91957ddd77981362aea4134ca9bd70027c5d6b00d48029902206871c100b8ca0125251949776f549ef23e863e682f8cc5363df7ba068224007781210241381695b0aee6e81eb28cdfbb003e5aa50843c70887a9eb0f61cde39c4b1de3ffffffff06e8e4f505000000001976a9140059ec50310b62423ef9459460ff76ddd9eb78be88ace8e4f505000000001976a91456669cf22d810e82052f83f315f71af1188c1f8988ace8e4f505000000001976a91483554baf827b505744b93bb0ddff2b29c373440a88ace8e4f505000000001976a9148e7e59300beb8241301eb71e42849fbaf3ccff3088ace8e4f505000000001976a91494bda7fa8b10359fc4ef2744fb65f1f0f7241fb688ace8e4f505000000001976a914dbf03f42aa7e0d2395b53198df04dbd2ed88bd0688ac000000000200000001e0f5aa482e2b22a298213a784cde77c273389ca1531a1a72278e7ad109c18a4b010000006a4730440220101abd6152650ed0d87485188c8bd84004554705b23132912cf5b0b7fbca1f3b02201713e1d594f6f4cd21b615960e690daf85f2b1e52e598978177551311d4e6ecb0121030a211b57934fc2a1cd18f9390e11e58164db7687a61d237502c1a015b064eb52ffffffff04a8630300000000001976a914a6d85bbc165dcaa903a8c4b75210395cb733348f88ac8f510300000000001976a914beeb3d50fe6af4eaead1b4ef95608c4ac1c810e488ac0cf80100000000001976a9147ee0bfdab6c808024a459d09b8b91a956f453f7a88acdb980200000000001976a914eda6626bbcfc960d886c553587c86d7ab825a3a788ac000000000200000001306372f9076911ab7adaeb3d93d751dc6da844791f577109f031d2f1000ab4fb020000006a4730440220196299b7b942cf90df5edeb7a14a3297f4d8eff28ff1181e53a00b6208e11c09022019d5ca5b7797de23014da2f8ed63b739b2172e598160caf0ba3c2c387ccf94100121026293fbf4806abf069a9ef7464c34dc1780e053e86aa7b58a1eecb7f76a0ee446ffffffff05b21d0200000000001976a914baebbad073fed1e2ffa50d4b09291d5b0e00c02d88ac4bf20100000000001976a9144d0e4a45aa0540f4ad0163f6f522eb66f87edc2188ac19780200000000001976a914a9cc4d8048c0b0d52b3c35b2af2c138d1f17b6d688acfd620200000000001976a9145a325dbe32e63da25225d9f3e11c7bd096b15d3c88ac6ea80200000000001976a914b8a7177e6bfb33dd578c18e005111798b8ecf49488ac000000000200000001c2e03c87f29210606e1acd022534eeedfd8f6a2608be18e7e70c1465538eba1a0b0000006a47304402204ace6498ae54cdb311284cea050409087e7bf7207df8c41a0ebbc5726c83200b022023a1928f5489fd133403e57ceb13986d6f8a9236437162faef4beb24cb02d8f5012103fd9eaada791523da0270d0c584a072c3110c52632e8ecd79114be0b7ab6f36e0ffffffff057e920200000000001976a914529f1f96c542c0ffb8d3a5bb690d9cadff2d92d588acd0a30200000000001976a91450ee917d6c6e0556fc99c68ed1596c730be6d30688acda0a0200000000001976a91410b7cd826e3750ec0a24139473975721b59c2d4888acbeb70100000000001976a9140854d05f62b8d112ea44d47dc853edfbcf5cb72588ac3ca20200000000001976a91453197867304cfac6065b225580aa45f627be2e9688ac0000000002000000013e42cc4f3a16255eec2340c28d44dbee6594219d73acef242ff0170903e37a7c010000006a47304402201c6277b9c4506d9d468f9539a13899d239d09e952d1061593d79d1e23336ed950220235058e0168e231b2b655b8b9119b559ff4de395d548b5d558351b72333d9467012103f8623d78e6a3a447bd853615cbdd40d15ce4cd81969c1d4d8c0e5c4d17cb3593feffffff02409c0000000000001976a91411a2855ec9c346ca8432b205795e839807b093e488ac00fe0200000000001976a9143545219b20be31d759b7861f1761b740615ebd2088ac3d4e1800",
    -+      "details": {"header": {"version": 536870912, "prevHash": "00000097553025db32759d82c78268b82cfda800eb3ec46fab3703f2eafab639", "merkleRoot": "386dad98d967c63bd05c0099f534096ea5e3aca2add9996be3c7190199daee14", "time": 1794852280, "bits": 503381541, "nonce": 371215}, "transactions": [{"version": 3, "txType": 5, "inputs": [{"prevout": {"hash": "0000000000000000000000000000000000000000000000000000000000000000", "index": 4294967295}, "scriptSig": "6a", "sequence": 4294967295}], "outputs": [{"value": 59526603, "scriptPubKey": "76a914b489115851ca07a26a5ad8bac3cec3c7dbebd83188ac"}, {"value": 66966830, "scriptPubKey": "6a"}, {"value": 111612978, "scriptPubKey": "76a91464f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d788ac"}], "lockTime": 0, "extraPayload": "04003e4e1800fb8ba050a8320b0ba74d1efb092faa19d5c0e32ac5d50a37dd6ff256a5065c3be8506d814cdd0c13aac6ab36860016f52ceb303420b4adc6117b97893f89fc1600b26526a325de13f29f214d2742dfc3a85c8e9f3d07b4ffb5fb563b53e44ddd27cb590d30518af7540051de8251fab27d0b15df595abe387bbee1cde961ccfecc9c60fe0c5db6b640be5576cbf662e8cb832d1a761a874d8a3d6d356127186237882df554e92200000000000000000000000000000000000000000000000000000000000000000000"}, {"version": 2, "txType": 0, "inputs": [{"prevout": {"hash": "96e7ce5718899223c5bbdac5b5151283e66aeed039bee311106aa9ab033ad1f2", "index": 0}, "scriptSig": "47304402207e562bc9470a065f1ced82320e8072e2596d8f3e030139c7eeec487c8d2a67d402204fa8d4f40d100c0095b8e1e6f9a388f968820c06cc89ad562684d4a8c200e400812103c51a04888b9e957e8704054e0a38f9ede9501093b44021a3bd5779ee67f0691c", "sequence": 4294967295}, {"prevout": {"hash": "ab346980c6f0a21f4a273b8b13fd190903c0ed18295d10eed13a1a62d3dbbe56", "index": 2}, "scriptSig": "47304402202ee66d8d29ee8a9124ac0e697c8d37f476add63823d2451fa63a498c9202cbb70220072708a01dea0f88805ec9ee636a014a0f8053b301d58314ba6ac2257455c144812103b4337fdd89b0f872732d51616480506571e1906dcab4de49403357f8303cc2ac", "sequence": 4294967295}, {"prevout": {"hash": "b550aca50524fad2407096ab370339629f74e1db3923684cb5ac10d60152a116", "index": 6}, "scriptSig": "4730440220704f235fb0021b44cbfea4bb112fba12071a05e51ba2abd34667638119ccbc4b02206c3620f4b2c7721f71833f3c6a2afac584eb4b9dbe2422d1f922f8b468a7a28d8121030b9622e1ca8310ea3394c25977b90c9058b57afec82e1f30a221be6bea928800", "sequence": 4294967295}], "outputs": [{"value": 1000010000, "scriptPubKey": "76a9144fffb09caab83ed8a12a27d5d9ad162996194d5288ac"}, {"value": 1000010000, "scriptPubKey": "76a91462f111004a7c77a1a4004c0813b9b37b592b20e188ac"}, {"value": 1000010000, "scriptPubKey": "76a914889f16de6b2c6846d2794c977f17b23a542793b888ac"}], "lockTime": 0, "extraPayload": ""}, {"version": 2, "txType": 0, "inputs": [{"prevout": {"hash": "0b04d7ab8500c57b4fd89b3a8bc20170e56bad2509afb6f7bd24f4453914d93d", "index": 6}, "scriptSig": "4730440220634d6b8d6e60c56c72270fcdc9edd74edbc6777b67a1b7797d0b3095aada53c902203354950807f3102d157303938e21841091db3c16c93d6be3e9afffd696e577508121035f011e4aa2662ccd27372c055e2776d9983c2de4d26b34e494acd91690a654ac", "sequence": 4294967295}, {"prevout": {"hash": "58d894e736d0811e28d2eafce53857ca4e9e820d13cea3267af1fe6615c666d8", "index": 23}, "scriptSig": "47304402201a68f16bd3f8310364c16f588c0a9ff55838bb8756320a36395ef89aa01f6c73022064dc3c4bf1b7873b5defff325ea66c3aac212e1a23f3396bddeec2f0ada730368121024a926de7bf6ec3476b7921f6941d2add8977c554c5639d610b1ee22f03aff1d6", "sequence": 4294967295}, {"prevout": {"hash": "86ee6815930692e1691559f9926a2796814fcafb1c3738f5e6a9cf1cbab6c3e4", "index": 0}, "scriptSig": "4730440220023c6c2d3038555b09da01588e28b4a67b05d0c090dc35439fb9e3b5e72791d002201fb89f2fbc0ab5e74a14a2ef00faaa39cf5c0a125980b04c7825e2378eebe826812103ad83a1965bc0bdc01eaf5050e19d3904cc07295f42b2b6f0cd23b383d3a4ccdb", "sequence": 4294967295}, {"prevout": {"hash": "c482180a947cab4b83076ea0627f1ef19b00eaf1cfc78ca1fec5335700a6ff31", "index": 9}, "scriptSig": "47304402205613821a65ec758b5e3461c5c9e8c0a65fb8d08be704953ad71e871ad55c1062022013267c4818d6c347f7f9551bc2da25a3cd07c0266bec4a72908d4849da1960608121026238d241af712a46891a7af1fba01eecc83170d4646847c4a92583a50a65c7be", "sequence": 4294967295}, {"prevout": {"hash": "d12e1a5a3e002df98578da51645629c20c26ed3e4751e69c35066fc59e34f143", "index": 6}, "scriptSig": "47304402207ca8ea5c0274206cfb5bb085f60698eb1557b6191b6d42cd7edc649c8e45448802207da39e0c3091398893335a297c3bfc26ad6d15a63ff01db4dc32b1b1eac35af28121037fa9accebb4883ddfee2e492475b71a9989f3e77615c330437c389bf7b07cd1e", "sequence": 4294967295}, {"prevout": {"hash": "ddf7f33d285b9423a31f93356f1e4ba30aa82081eb1542089de14a99bd41c04e", "index": 23}, "scriptSig": "4730440220295b9d87be939430e91957ddd77981362aea4134ca9bd70027c5d6b00d48029902206871c100b8ca0125251949776f549ef23e863e682f8cc5363df7ba068224007781210241381695b0aee6e81eb28cdfbb003e5aa50843c70887a9eb0f61cde39c4b1de3", "sequence": 4294967295}], "outputs": [{"value": 100001000, "scriptPubKey": "76a9140059ec50310b62423ef9459460ff76ddd9eb78be88ac"}, {"value": 100001000, "scriptPubKey": "76a91456669cf22d810e82052f83f315f71af1188c1f8988ac"}, {"value": 100001000, "scriptPubKey": "76a91483554baf827b505744b93bb0ddff2b29c373440a88ac"}, {"value": 100001000, "scriptPubKey": "76a9148e7e59300beb8241301eb71e42849fbaf3ccff3088ac"}, {"value": 100001000, "scriptPubKey": "76a91494bda7fa8b10359fc4ef2744fb65f1f0f7241fb688ac"}, {"value": 100001000, "scriptPubKey": "76a914dbf03f42aa7e0d2395b53198df04dbd2ed88bd0688ac"}], "lockTime": 0, "extraPayload": ""}, {"version": 2, "txType": 0, "inputs": [{"prevout": {"hash": "4b8ac109d17a8e27721a1a53a19c3873c277de4c783a2198a2222b2e48aaf5e0", "index": 1}, "scriptSig": "4730440220101abd6152650ed0d87485188c8bd84004554705b23132912cf5b0b7fbca1f3b02201713e1d594f6f4cd21b615960e690daf85f2b1e52e598978177551311d4e6ecb0121030a211b57934fc2a1cd18f9390e11e58164db7687a61d237502c1a015b064eb52", "sequence": 4294967295}], "outputs": [{"value": 222120, "scriptPubKey": "76a914a6d85bbc165dcaa903a8c4b75210395cb733348f88ac"}, {"value": 217487, "scriptPubKey": "76a914beeb3d50fe6af4eaead1b4ef95608c4ac1c810e488ac"}, {"value": 129036, "scriptPubKey": "76a9147ee0bfdab6c808024a459d09b8b91a956f453f7a88ac"}, {"value": 170203, "scriptPubKey": "76a914eda6626bbcfc960d886c553587c86d7ab825a3a788ac"}], "lockTime": 0, "extraPayload": ""}, {"version": 2, "txType": 0, "inputs": [{"prevout": {"hash": "fbb40a00f1d231f00971571f7944a86ddc51d7933debda7aab116907f9726330", "index": 2}, "scriptSig": "4730440220196299b7b942cf90df5edeb7a14a3297f4d8eff28ff1181e53a00b6208e11c09022019d5ca5b7797de23014da2f8ed63b739b2172e598160caf0ba3c2c387ccf94100121026293fbf4806abf069a9ef7464c34dc1780e053e86aa7b58a1eecb7f76a0ee446", "sequence": 4294967295}], "outputs": [{"value": 138674, "scriptPubKey": "76a914baebbad073fed1e2ffa50d4b09291d5b0e00c02d88ac"}, {"value": 127563, "scriptPubKey": "76a9144d0e4a45aa0540f4ad0163f6f522eb66f87edc2188ac"}, {"value": 161817, "scriptPubKey": "76a914a9cc4d8048c0b0d52b3c35b2af2c138d1f17b6d688ac"}, {"value": 156413, "scriptPubKey": "76a9145a325dbe32e63da25225d9f3e11c7bd096b15d3c88ac"}, {"value": 174190, "scriptPubKey": "76a914b8a7177e6bfb33dd578c18e005111798b8ecf49488ac"}], "lockTime": 0, "extraPayload": ""}, {"version": 2, "txType": 0, "inputs": [{"prevout": {"hash": "1aba8e5365140ce7e718be08266a8ffdedee342502cd1a6e601092f2873ce0c2", "index": 11}, "scriptSig": "47304402204ace6498ae54cdb311284cea050409087e7bf7207df8c41a0ebbc5726c83200b022023a1928f5489fd133403e57ceb13986d6f8a9236437162faef4beb24cb02d8f5012103fd9eaada791523da0270d0c584a072c3110c52632e8ecd79114be0b7ab6f36e0", "sequence": 4294967295}], "outputs": [{"value": 168574, "scriptPubKey": "76a914529f1f96c542c0ffb8d3a5bb690d9cadff2d92d588ac"}, {"value": 173008, "scriptPubKey": "76a91450ee917d6c6e0556fc99c68ed1596c730be6d30688ac"}, {"value": 133850, "scriptPubKey": "76a91410b7cd826e3750ec0a24139473975721b59c2d4888ac"}, {"value": 112574, "scriptPubKey": "76a9140854d05f62b8d112ea44d47dc853edfbcf5cb72588ac"}, {"value": 172604, "scriptPubKey": "76a91453197867304cfac6065b225580aa45f627be2e9688ac"}], "lockTime": 0, "extraPayload": ""}, {"version": 2, "txType": 0, "inputs": [{"prevout": {"hash": "7c7ae3030917f02f24efac739d219465eedb448dc24023ec5e25163a4fcc423e", "index": 1}, "scriptSig": "47304402201c6277b9c4506d9d468f9539a13899d239d09e952d1061593d79d1e23336ed950220235058e0168e231b2b655b8b9119b559ff4de395d548b5d558351b72333d9467012103f8623d78e6a3a447bd853615cbdd40d15ce4cd81969c1d4d8c0e5c4d17cb3593", "sequence": 4294967294}], "outputs": [{"value": 40000, "scriptPubKey": "76a91411a2855ec9c346ca8432b205795e839807b093e488ac"}, {"value": 196096, "scriptPubKey": "76a9143545219b20be31d759b7861f1761b740615ebd2088ac"}], "lockTime": 1592893, "extraPayload": ""}]}
    -+    },
    -+    // Testnet block 1592891, transaction types 5, 6, 6, 6.
    -+    "000000a7d51270cdd8ba9080312cd9880889cf3417ca07c025a0382acf0db110": {
    -+      "raw": "0000002046165b23936a4b0740638b1447a2d5a6fce55b425c40d429818b518f7c000000e1e22e2acf67610f6bebe1e52a9efa2f87109025b91323987d8c79bf10179c6d5d44fb6a2406011ee14200000403000500010000000000000000000000000000000000000000000000000000000000000000ffffffff016affffffff03b84b8c03000000001976a914b489115851ca07a26a5ad8bac3cec3c7dbebd83188ac2ed5fd0300000000016af80da706000000001976a91464f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d788ac00000000cf04003b4e1800fb8ba050a8320b0ba74d1efb092faa19d5c0e32ac5d50a37dd6ff256a5065c3be8506d814cdd0c13aac6ab36860016f52ceb303420b4adc6117b97893f89fc1600a97b564be55309f14aba8e85e51f41884cfefbdb7e0d54d5fcda1435ac4454a8548533e2e72ee80969e259e852d7ef8811c6cb891881846292d2a81ff47f67e52e3ebbcaa0be63061150f54994d5da8779a268c752a16570a5c21f6bf2ac9b54feadfb48e9220000000000000000000000000000000000000000000000000000000000000000000003000600000000000000fd490101003b4e1800030001c96737f5a923a20fa28e9e3785d33d200dc5882e164fa71c8be42ee53600000032fffeffffffff0332fffeffffffff03b7920bc1fa929f99c8703a94e8ae4391a8f1e87577567477fa40550498001bcc1a495bd2b888c9060a0953c6fb6fab1ba6d61e3b06efabda63cc9a14c262b86769756d3ed49f6724a30890577925c1248fed286b469b83ac2ddff15a1cc19da3e93c4deb706a2d1e6c20a035eb53bdf36a5a543e87250ed3667454793d14723516340bbff7384216691cd6fc7bea8a69cd52426cbbad77eda67daa8eee747089985b6f6e0e46c1b673433356f42b7e2aa73c934a6f5e5af93abd7c9967fc400552d2cc47a7e72c56f4e725f99e5060eab6bd31a00f2a614fb2bc944e271cd6aa027795983cde31795934bdd81ee4d3987e2ade80bb4275c059e53af99956243526e486d865930cb3f2b2d714553aa41f03000600000000000000fd550101003b4e1800030004c96737f5a923a20fa28e9e3785d33d200dc5882e164fa71c8be42ee53600000064fffffffffffffffbffffffff0f64ffffffffffffffffffffffff0f8e3d8c6c17fe7be5ea668f40adf4f70acf8067ec5431e801e47a72bfcd6d0d2f1025444819b20c8e3e025177fdf7324e51a58cacfd373e166e9ce552b28c255f272b2a0a0158c2e3a874d4ff5a444332a2e31f9806fdac0e5c67fdfb91788fa2c78dc38f81073c0249e4e04b27bf8fec908ae8475eba171921879f936d20e04c16538c36306c52fbfc59eeb4852d5ab7371ce6ff3a46707f5f2de02d691fde8a3b1ea1259ad0d0a0c73457b98d799906b2c5303c6b6573cf29a269d6e9d7b407d35f901fa5ffa9af8d5038fa5b7cde9deba48a55df35590fa08cd82c05ee615b085805d6a13271e7aecc90e22c51b20ae0f98508cb5d866aa9a5a16b8799c09bd2e9c057516f462c6ec1e525536a8fd703000600000000000000fd430101003b4e1800030006c96737f5a923a20fa28e9e3785d33d200dc5882e164fa71c8be42ee53600000019ffffff0119ffffff018dbaebf8abcb16b40ba6731f7b8879ed980da175d582083b4f2aa22c9343e347fe202c6985b688179455034006c50a97cb8e5552ef0f88b6f536d4b2d742945abc665978199891fbd057d0e92e936b4194e33fe2c20559ce48006839271a5fad479d04f2fa8d1a8e04b0e0b211845e2b67aee4f16a4d8b1e4f61005aaa866b2e135b0222afe6d67c744eaedd63d2a45646ee26829425e47bd8c1bb6d4bf5cedc9338ef8c1b348b764e2130d22e311cf6a912ae0b509e195d6780ca879d953a7716b826604f59cd672273067f221b6fdcecde2f82f641efe059fbe245e7faf1ae097e0f39ce092b8da8a6feefccf4bc22f6e43abf2c1a25fb4ad2e63c2b88d5023dba7dca401115db28d0cceb803647a6",
    -+      "details": {"header": {"version": 536870912, "prevHash": "0000007c8f518b8129d4405c425be5fca6d5a247148b6340074b6a93235b1646", "merkleRoot": "6d9c1710bf798c7d982313b9259010872ffa9e2ae5e1eb6b0f6167cf2a2ee2e1", "time": 1794851933, "bits": 503383588, "nonce": 17121}, "transactions": [{"version": 3, "txType": 5, "inputs": [{"prevout": {"hash": "0000000000000000000000000000000000000000000000000000000000000000", "index": 4294967295}, "scriptSig": "6a", "sequence": 4294967295}], "outputs": [{"value": 59526072, "scriptPubKey": "76a914b489115851ca07a26a5ad8bac3cec3c7dbebd83188ac"}, {"value": 66966830, "scriptPubKey": "6a"}, {"value": 111611384, "scriptPubKey": "76a91464f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d788ac"}], "lockTime": 0, "extraPayload": "04003b4e1800fb8ba050a8320b0ba74d1efb092faa19d5c0e32ac5d50a37dd6ff256a5065c3be8506d814cdd0c13aac6ab36860016f52ceb303420b4adc6117b97893f89fc1600a97b564be55309f14aba8e85e51f41884cfefbdb7e0d54d5fcda1435ac4454a8548533e2e72ee80969e259e852d7ef8811c6cb891881846292d2a81ff47f67e52e3ebbcaa0be63061150f54994d5da8779a268c752a16570a5c21f6bf2ac9b54feadfb48e92200000000000000000000000000000000000000000000000000000000000000000000"}, {"version": 3, "txType": 6, "inputs": [], "outputs": [], "lockTime": 0, "extraPayload": "01003b4e1800030001c96737f5a923a20fa28e9e3785d33d200dc5882e164fa71c8be42ee53600000032fffeffffffff0332fffeffffffff03b7920bc1fa929f99c8703a94e8ae4391a8f1e87577567477fa40550498001bcc1a495bd2b888c9060a0953c6fb6fab1ba6d61e3b06efabda63cc9a14c262b86769756d3ed49f6724a30890577925c1248fed286b469b83ac2ddff15a1cc19da3e93c4deb706a2d1e6c20a035eb53bdf36a5a543e87250ed3667454793d14723516340bbff7384216691cd6fc7bea8a69cd52426cbbad77eda67daa8eee747089985b6f6e0e46c1b673433356f42b7e2aa73c934a6f5e5af93abd7c9967fc400552d2cc47a7e72c56f4e725f99e5060eab6bd31a00f2a614fb2bc944e271cd6aa027795983cde31795934bdd81ee4d3987e2ade80bb4275c059e53af99956243526e486d865930cb3f2b2d714553aa41f"}, {"version": 3, "txType": 6, "inputs": [], "outputs": [], "lockTime": 0, "extraPayload": "01003b4e1800030004c96737f5a923a20fa28e9e3785d33d200dc5882e164fa71c8be42ee53600000064fffffffffffffffbffffffff0f64ffffffffffffffffffffffff0f8e3d8c6c17fe7be5ea668f40adf4f70acf8067ec5431e801e47a72bfcd6d0d2f1025444819b20c8e3e025177fdf7324e51a58cacfd373e166e9ce552b28c255f272b2a0a0158c2e3a874d4ff5a444332a2e31f9806fdac0e5c67fdfb91788fa2c78dc38f81073c0249e4e04b27bf8fec908ae8475eba171921879f936d20e04c16538c36306c52fbfc59eeb4852d5ab7371ce6ff3a46707f5f2de02d691fde8a3b1ea1259ad0d0a0c73457b98d799906b2c5303c6b6573cf29a269d6e9d7b407d35f901fa5ffa9af8d5038fa5b7cde9deba48a55df35590fa08cd82c05ee615b085805d6a13271e7aecc90e22c51b20ae0f98508cb5d866aa9a5a16b8799c09bd2e9c057516f462c6ec1e525536a8fd7"}, {"version": 3, "txType": 6, "inputs": [], "outputs": [], "lockTime": 0, "extraPayload": "01003b4e1800030006c96737f5a923a20fa28e9e3785d33d200dc5882e164fa71c8be42ee53600000019ffffff0119ffffff018dbaebf8abcb16b40ba6731f7b8879ed980da175d582083b4f2aa22c9343e347fe202c6985b688179455034006c50a97cb8e5552ef0f88b6f536d4b2d742945abc665978199891fbd057d0e92e936b4194e33fe2c20559ce48006839271a5fad479d04f2fa8d1a8e04b0e0b211845e2b67aee4f16a4d8b1e4f61005aaa866b2e135b0222afe6d67c744eaedd63d2a45646ee26829425e47bd8c1bb6d4bf5cedc9338ef8c1b348b764e2130d22e311cf6a912ae0b509e195d6780ca879d953a7716b826604f59cd672273067f221b6fdcecde2f82f641efe059fbe245e7faf1ae097e0f39ce092b8da8a6feefccf4bc22f6e43abf2c1a25fb4ad2e63c2b88d5023dba7dca401115db28d0cceb803647a6"}]}
    -+    },
    -+  },
    -+  "tx": {
    -+    // First type 5 transaction of these blocks, from testnet block 1592894: inputs 1, outputs 3, extra payload 207 bytes.
    -+    "597688004a83ac6365a719b5af339a47f9cdc7c978e56b5ec9bad12ba97b6b4f": {
    -+      "raw": "03000500010000000000000000000000000000000000000000000000000000000000000000ffffffff016affffffff03cb4d8c03000000001976a914b489115851ca07a26a5ad8bac3cec3c7dbebd83188ac2ed5fd0300000000016a3214a706000000001976a91464f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d788ac00000000cf04003e4e1800fb8ba050a8320b0ba74d1efb092faa19d5c0e32ac5d50a37dd6ff256a5065c3be8506d814cdd0c13aac6ab36860016f52ceb303420b4adc6117b97893f89fc1600b26526a325de13f29f214d2742dfc3a85c8e9f3d07b4ffb5fb563b53e44ddd27cb590d30518af7540051de8251fab27d0b15df595abe387bbee1cde961ccfecc9c60fe0c5db6b640be5576cbf662e8cb832d1a761a874d8a3d6d356127186237882df554e92200000000000000000000000000000000000000000000000000000000000000000000",
    -+      "details": {"version": 3, "txType": 5, "inputs": [{"prevout": {"hash": "0000000000000000000000000000000000000000000000000000000000000000", "index": 4294967295}, "scriptSig": "6a", "sequence": 4294967295}], "outputs": [{"value": 59526603, "scriptPubKey": "76a914b489115851ca07a26a5ad8bac3cec3c7dbebd83188ac"}, {"value": 66966830, "scriptPubKey": "6a"}, {"value": 111612978, "scriptPubKey": "76a91464f2b2b84f62d68a2cd7f7f5fb2b5aa75ef716d788ac"}], "lockTime": 0, "extraPayload": "04003e4e1800fb8ba050a8320b0ba74d1efb092faa19d5c0e32ac5d50a37dd6ff256a5065c3be8506d814cdd0c13aac6ab36860016f52ceb303420b4adc6117b97893f89fc1600b26526a325de13f29f214d2742dfc3a85c8e9f3d07b4ffb5fb563b53e44ddd27cb590d30518af7540051de8251fab27d0b15df595abe387bbee1cde961ccfecc9c60fe0c5db6b640be5576cbf662e8cb832d1a761a874d8a3d6d356127186237882df554e92200000000000000000000000000000000000000000000000000000000000000000000"}
    -+    },
    -+    // First type 0 transaction of these blocks, from testnet block 1592894: inputs 3, outputs 3, extra payload 0 bytes.
    -+    "85a9047e10aa59190dffa5667bed6801d99b2646af96581b3a015d22d9ee9e05": {
    -+      "raw": "0200000003f2d13a03aba96a1011e3be39d0ee6ae6831215b5c5dabbc52392891857cee796000000006a47304402207e562bc9470a065f1ced82320e8072e2596d8f3e030139c7eeec487c8d2a67d402204fa8d4f40d100c0095b8e1e6f9a388f968820c06cc89ad562684d4a8c200e400812103c51a04888b9e957e8704054e0a38f9ede9501093b44021a3bd5779ee67f0691cffffffff56bedbd3621a3ad1ee105d2918edc0030919fd138b3b274a1fa2f0c6806934ab020000006a47304402202ee66d8d29ee8a9124ac0e697c8d37f476add63823d2451fa63a498c9202cbb70220072708a01dea0f88805ec9ee636a014a0f8053b301d58314ba6ac2257455c144812103b4337fdd89b0f872732d51616480506571e1906dcab4de49403357f8303cc2acffffffff16a15201d610acb54c682339dbe1749f62390337ab967040d2fa2405a5ac50b5060000006a4730440220704f235fb0021b44cbfea4bb112fba12071a05e51ba2abd34667638119ccbc4b02206c3620f4b2c7721f71833f3c6a2afac584eb4b9dbe2422d1f922f8b468a7a28d8121030b9622e1ca8310ea3394c25977b90c9058b57afec82e1f30a221be6bea928800ffffffff0310f19a3b000000001976a9144fffb09caab83ed8a12a27d5d9ad162996194d5288ac10f19a3b000000001976a91462f111004a7c77a1a4004c0813b9b37b592b20e188ac10f19a3b000000001976a914889f16de6b2c6846d2794c977f17b23a542793b888ac00000000",
    -+      "details": {"version": 2, "txType": 0, "inputs": [{"prevout": {"hash": "96e7ce5718899223c5bbdac5b5151283e66aeed039bee311106aa9ab033ad1f2", "index": 0}, "scriptSig": "47304402207e562bc9470a065f1ced82320e8072e2596d8f3e030139c7eeec487c8d2a67d402204fa8d4f40d100c0095b8e1e6f9a388f968820c06cc89ad562684d4a8c200e400812103c51a04888b9e957e8704054e0a38f9ede9501093b44021a3bd5779ee67f0691c", "sequence": 4294967295}, {"prevout": {"hash": "ab346980c6f0a21f4a273b8b13fd190903c0ed18295d10eed13a1a62d3dbbe56", "index": 2}, "scriptSig": "47304402202ee66d8d29ee8a9124ac0e697c8d37f476add63823d2451fa63a498c9202cbb70220072708a01dea0f88805ec9ee636a014a0f8053b301d58314ba6ac2257455c144812103b4337fdd89b0f872732d51616480506571e1906dcab4de49403357f8303cc2ac", "sequence": 4294967295}, {"prevout": {"hash": "b550aca50524fad2407096ab370339629f74e1db3923684cb5ac10d60152a116", "index": 6}, "scriptSig": "4730440220704f235fb0021b44cbfea4bb112fba12071a05e51ba2abd34667638119ccbc4b02206c3620f4b2c7721f71833f3c6a2afac584eb4b9dbe2422d1f922f8b468a7a28d8121030b9622e1ca8310ea3394c25977b90c9058b57afec82e1f30a221be6bea928800", "sequence": 4294967295}], "outputs": [{"value": 1000010000, "scriptPubKey": "76a9144fffb09caab83ed8a12a27d5d9ad162996194d5288ac"}, {"value": 1000010000, "scriptPubKey": "76a91462f111004a7c77a1a4004c0813b9b37b592b20e188ac"}, {"value": 1000010000, "scriptPubKey": "76a914889f16de6b2c6846d2794c977f17b23a542793b888ac"}], "lockTime": 0, "extraPayload": ""}
    -+    },
    -+    // First type 6 transaction of these blocks, from testnet block 1592891: inputs 0, outputs 0, extra payload 329 bytes.
    -+    "79ae1778840ac0469d57eaed9b5fb064b632c0b7228c62932f496981929d822b": {
    -+      "raw": "03000600000000000000fd490101003b4e1800030001c96737f5a923a20fa28e9e3785d33d200dc5882e164fa71c8be42ee53600000032fffeffffffff0332fffeffffffff03b7920bc1fa929f99c8703a94e8ae4391a8f1e87577567477fa40550498001bcc1a495bd2b888c9060a0953c6fb6fab1ba6d61e3b06efabda63cc9a14c262b86769756d3ed49f6724a30890577925c1248fed286b469b83ac2ddff15a1cc19da3e93c4deb706a2d1e6c20a035eb53bdf36a5a543e87250ed3667454793d14723516340bbff7384216691cd6fc7bea8a69cd52426cbbad77eda67daa8eee747089985b6f6e0e46c1b673433356f42b7e2aa73c934a6f5e5af93abd7c9967fc400552d2cc47a7e72c56f4e725f99e5060eab6bd31a00f2a614fb2bc944e271cd6aa027795983cde31795934bdd81ee4d3987e2ade80bb4275c059e53af99956243526e486d865930cb3f2b2d714553aa41f",
    -+      "details": {"version": 3, "txType": 6, "inputs": [], "outputs": [], "lockTime": 0, "extraPayload": "01003b4e1800030001c96737f5a923a20fa28e9e3785d33d200dc5882e164fa71c8be42ee53600000032fffeffffffff0332fffeffffffff03b7920bc1fa929f99c8703a94e8ae4391a8f1e87577567477fa40550498001bcc1a495bd2b888c9060a0953c6fb6fab1ba6d61e3b06efabda63cc9a14c262b86769756d3ed49f6724a30890577925c1248fed286b469b83ac2ddff15a1cc19da3e93c4deb706a2d1e6c20a035eb53bdf36a5a543e87250ed3667454793d14723516340bbff7384216691cd6fc7bea8a69cd52426cbbad77eda67daa8eee747089985b6f6e0e46c1b673433356f42b7e2aa73c934a6f5e5af93abd7c9967fc400552d2cc47a7e72c56f4e725f99e5060eab6bd31a00f2a614fb2bc944e271cd6aa027795983cde31795934bdd81ee4d3987e2ade80bb4275c059e53af99956243526e486d865930cb3f2b2d714553aa41f"}
    -+    },
    -+  },
    - }
    +    `block` and `tx` decode with the existing primitive decoders.
     
      ## pkgs/p2p_core/src/msg/blocks.rs ##
     @@ pkgs/p2p_core/src/msg/blocks.rs: mod tests {
        use crate::{CommandString, P2pMsg};
      
        use dash_dev::{assert_serde_rt, check_wire, Corpus};
    -+  use dash_primitives::{Block, Transaction};
    ++  use dash_primitives::{Block, BlockHeader, Transaction, TxType};
    ++  use dash_types::codec::BaseCodec;
        use rstest::rstest;
      
    -+  #[rstest]
    -+  fn corpus_block() {
    -+    let corpus = Corpus::open(env!("CARGO_MANIFEST_DIR"), "blocks");
    -+    let items = corpus.entries::<Block>("block", |raw, details, label| {
    -+      check_wire(raw, details, label);
    -+      let decoded = P2pMsg::decode_payload(&CommandString::BLOCK, raw);
    -+      assert_eq!(decoded, Ok(P2pMsg::Block(details.clone())), "{label}: dispatch");
    -+    });
    -+    assert_serde_rt("block", &items);
    ++  fn tx() -> Transaction {
    ++    Transaction::new(1, TxType::Spend, vec![], vec![], 0, vec![])
    ++  }
    ++
    ++  fn wire(value: &impl BaseCodec) -> Vec<u8> {
    ++    let mut raw = Vec::new();
    ++    value.encode(&mut raw);
    ++    raw
    ++  }
    ++
    ++  fn block() -> Block {
    ++    Block::new(BlockHeader::default(), vec![tx()])
     +  }
     +
     +  #[rstest]
    -+  fn corpus_tx() {
    -+    let corpus = Corpus::open(env!("CARGO_MANIFEST_DIR"), "blocks");
    -+    let items = corpus.entries::<Transaction>("tx", |raw, details, label| {
    -+      check_wire(raw, details, label);
    -+      let decoded = P2pMsg::decode_payload(&CommandString::TX, raw);
    -+      assert_eq!(decoded, Ok(P2pMsg::Tx(details.clone())), "{label}: dispatch");
    -+    });
    -+    assert_serde_rt("tx", &items);
    ++  #[case::block(CommandString::BLOCK, wire(&block()), P2pMsg::Block(block()))]
    ++  #[case::tx(CommandString::TX, wire(&tx()), P2pMsg::Tx(tx()))]
    ++  fn block_and_tx_decode_to_their_variants(#[case] command: CommandString, #[case] raw: Vec<u8>, #[case] msg: P2pMsg) {
    ++    assert_eq!(P2pMsg::decode_payload(&command, &raw), Ok(msg));
     +  }
     +
        #[rstest]
2:  9d117ce0 ! 2:  e22e6a5a p2p_core%feat!: type the BIP152 compact block messages
    @@ pkgs/p2p_core/src/msg/compact.rs (new)
     +use getset::{CopyGetters, Getters};
     +
     +codec_p2p! {
    -+/// A six-byte transaction short ID in little-endian order.
    ++/// A transaction short ID.
     +#[derive(Clone, Copy, CopyGetters, Debug, Eq, Hash, PartialEq, TypeId)]
     +#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
     +pub struct ShortTxId {
    @@ pkgs/p2p_core/src/msg/compact.rs (new)
     +}
     +
     +impl_new! {
    -+/// A transaction and its CompactSize offset from the preceding prefilled
    -+/// index plus one, or its index for the first entry.
    ++/// A transaction sent in full in a compact block.
     +#[derive(Clone, CopyGetters, Debug, Eq, Getters, Hash, PartialEq, TypeId)]
     +#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
     +pub struct PrefilledTransaction {
    -+  /// Differential index, a CompactSize narrowed to 16 bits.
    ++  /// Index in the block, relative to the preceding prefilled transaction.
     +  #[getset(get_copy = "pub")]
     +  idx: u16,
     +  /// The transaction.
    @@ pkgs/p2p_core/src/msg/compact.rs (new)
     +impl_p2p!(PrefilledTransaction);
     +
     +impl BaseCodec for PrefilledTransaction {
    ++  /// Reads the index as a CompactSize offset from the preceding prefilled
    ++  /// index plus one, or the absolute index for the first entry, and refuses
    ++  /// one that does not fit `u16`.
     +  fn decode(data: &mut &[u8]) -> Result<Self, DecodeError> {
     +    Ok(Self {
     +      idx: CompactSize::decode_as(data)?,
    @@ pkgs/p2p_core/src/msg/compact.rs (new)
     +  pub const MAX_TX_COUNT: usize = u16::MAX as usize;
     +}
     +
    -+/// A block hash and strictly increasing transaction indexes encoded as
    -+/// CompactSize differences.
    ++/// A request for some of a block's transactions.
     +#[derive(Clone, CopyGetters, Debug, Eq, Getters, Hash, PartialEq, TypeId)]
     +#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
     +#[cfg_attr(feature = "serde", serde(try_from = "GetBlockTxnFields"))]
    @@ pkgs/p2p_core/src/msg/compact.rs (new)
     +impl_p2p!(GetBlockTxn);
     +
     +impl BaseCodec for GetBlockTxn {
    -+  /// Refuses an absolute index that does not fit `u16`, reporting that index
    -+  /// as the value.
    ++  /// Reads each index as a CompactSize difference from the previous index
    ++  /// plus one. Refuses an absolute index that does not fit `u16`, reporting
    ++  /// that index as the value.
     +  fn decode(data: &mut &[u8]) -> Result<Self, DecodeError> {
     +    let block_hash = BlockHash::decode(data)?;
     +    let count = CompactSize::decode_len(data, dash_types::MAX_SER_SIZE)?;
    @@ pkgs/p2p_core/src/msg/compact.rs (new)
     +}
     +
     +codec_p2p! {
    -+/// A block hash followed by a CompactSize list of transactions.
    ++/// Transactions of one block, sent in reply to a `getblocktxn`.
     +#[derive(Clone, CopyGetters, Debug, Eq, Getters, Hash, PartialEq, TypeId)]
     +#[cfg_attr(feature = "serde", derive(::serde::Serialize, ::serde::Deserialize))]
     +pub struct BlockTxn {
    @@ pkgs/p2p_core/src/msg/compact.rs (new)
     +    raw
     +  }
     +
    -+  #[rstest]
    -+  #[case::short_ids(65_535, 0)]
    -+  #[case::prefilled(0, 65_535)]
    -+  #[case::combined(65_534, 1)]
    -+  fn combined_counts_are_bounded(#[case] shorts: usize, #[case] full: usize) {
    -+    let block = CmpctBlock::new(
    ++  fn compact_block(shorts: usize, full: usize) -> CmpctBlock {
    ++    CmpctBlock::new(
     +      BlockHeader::default(),
     +      u64::default(),
     +      vec![ShortTxId::new([1, 2, 3, 4, 5, 6]); shorts],
     +      vec![PrefilledTransaction::new(0, tx()); full],
    ++    )
    ++  }
    ++
    ++  fn assert_refused(raw: &[u8], err: &DecodeError) {
    ++    assert_eq!(CmpctBlock::decode(&mut &raw[..]), Err(err.clone()));
    ++    assert_eq!(
    ++      P2pMsg::decode_payload(&CommandString::CMPCTBLOCK, raw),
    ++      Err(P2pDecodeError::Consensus(err.clone()))
     +    );
    ++  }
    ++
    ++  #[rstest]
    ++  fn short_id_count_is_bounded() {
    ++    let block = compact_block(65_535, 0);
     +    assert_eq!(CmpctBlock::decode(&mut wire(&block).as_slice()), Ok(block.clone()));
     +    let mut longer = block.clone();
    -+    let (limit, value, bare) = if full == 0 {
    -+      longer.short_ids.push(ShortTxId::new([0; 6]));
    -+      let mut bare = wire(&block.header);
    -+      block.nonce.encode(&mut bare);
    -+      CompactSize::from(shorts + 1).encode(&mut bare);
    -+      (65_535, 65_536, bare)
    -+    } else {
    -+      longer.prefilled_txs.push(PrefilledTransaction::new(0, tx()));
    -+      let mut bare = wire(&block.header);
    -+      block.nonce.encode(&mut bare);
    -+      block.short_ids.encode(&mut bare);
    -+      CompactSize::from(full + 1).encode(&mut bare);
    -+      (65_535 - shorts, full as u64 + 1, bare)
    ++    longer.short_ids.push(ShortTxId::new([0; 6]));
    ++    let mut bare = wire(&block.header);
    ++    block.nonce.encode(&mut bare);
    ++    CompactSize::new(65_536).encode(&mut bare);
    ++    let err = DecodeError::CompactSizeExceedsLimit {
    ++      limit: 65_535,
    ++      value: 65_536,
     +    };
    ++    assert_refused(&wire(&longer), &err);
    ++    assert_refused(&bare, &err);
    ++  }
    ++
    ++  #[rstest]
    ++  #[case::prefilled_only(0, 65_535, 65_535, 65_536)]
    ++  #[case::combined(65_534, 1, 1, 2)]
    ++  fn prefilled_count_is_bounded_by_the_short_ids(
    ++    #[case] shorts: usize,
    ++    #[case] full: usize,
    ++    #[case] limit: usize,
    ++    #[case] value: u64,
    ++  ) {
    ++    let block = compact_block(shorts, full);
    ++    assert_eq!(CmpctBlock::decode(&mut wire(&block).as_slice()), Ok(block.clone()));
    ++    let mut longer = block.clone();
    ++    longer.prefilled_txs.push(PrefilledTransaction::new(0, tx()));
    ++    let mut bare = wire(&block.header);
    ++    block.nonce.encode(&mut bare);
    ++    block.short_ids.encode(&mut bare);
    ++    CompactSize::new(value).encode(&mut bare);
     +    let err = DecodeError::CompactSizeExceedsLimit { limit, value };
    -+    for raw in [wire(&longer), bare] {
    -+      assert_eq!(CmpctBlock::decode(&mut raw.as_slice()), Err(err.clone()));
    -+      assert_eq!(
    -+        P2pMsg::decode_payload(&CommandString::CMPCTBLOCK, &raw),
    -+        Err(P2pDecodeError::Consensus(err.clone()))
    -+      );
    -+    }
    ++    assert_refused(&wire(&longer), &err);
    ++    assert_refused(&bare, &err);
     +  }
     +
     +  #[rstest]

🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

At e22e6a5, the BIP152 count and differential-index checks match Dash Core, and I found no blocking issue; the suggestions address avoidable relay copies and document the SDK's stricter handling of trailing bytes. Lint, P2P MSRV, stable, and cross-platform checks passed; only the review check is pending.

🟡 2 suggestion(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

Follow-up candidates (optional) (1)

New non-blocking observations on code unchanged since the last full review. No inline threads are opened for them and later reviews do not repeat them: fix forward or track separately if they are worth it.

🟡 Suggestion: Encode typed block payloads directly into the caller's buffer
pkgs/p2p_core/src/msg/mod.rs:80-83

Moving Block and Tx from the raw arm to the parsed arm introduces two full-payload copies after serialization. The generated encoder first writes into a VecEncoder buffer, encode_to_vec copies those bytes into a second vector, and encode_payload copies that vector into the caller's buffer. Both copies happen even when the caller has reserved enough capacity. Call dash_types::codec::BaseCodec::encode(m, buf) directly in the parsed arm of define_p2p!; it is the same codec the generated encoder already uses.

source: gpt-6.2-astra (phase2-reviewer: rust-quality)

Review provenance

Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); reviewer 4: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 5: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — The new peer-facing BIP152 decoders in pkgs/p2p_core/src/msg/compact.rs implement differential index arithmetic, integer narrowing, and combined transaction-count checks on untrusted wire data.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Code unchanged since the last final review (681099d4): 1 new suggestion(s) listed as follow-up candidates, not posted inline
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `pkgs/p2p_core/src/msg/compact.rs`:
- [SUGGESTION] pkgs/p2p_core/src/msg/compact.rs:206: Let block reconstruction take ownership of reply transactions
  A relay that owns a decoded `BlockTxn` can check `block_hash()`, but it cannot move the transactions out: the vector is private and `transactions()` only borrows it. Filling an owned `Block` from the reply therefore requires cloning the transactions and their buffers. A consuming accessor lets callers move them into the reconstructed block while preserving the borrowing API.

In `pkgs/p2p_core/src/msg/blocks.rs`:
- [SUGGESTION] pkgs/p2p_core/src/msg/blocks.rs:85-89: Document trailing-byte rejection on the newly typed routes
  The five commands now go through `decode_msg`, which returns `TrailingBytes` even when the message itself decoded successfully. Dash Core at `938fba5028` reads the object without requiring the payload to be exhausted (for example, `tx` at `net_processing.cpp:4896` and `block` at `net_processing.cpp:5375`). Call out this stricter SDK behavior explicitly in Breaking Changes and add a trailing-byte case to the new dispatch test. The existing `ping` test covers the shared guard, but the new `block` and `tx` cases only cover successful dispatch.

#[getset(get = "pub")]
transactions: Vec<Transaction>,
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Suggestion: Let block reconstruction take ownership of reply transactions

A relay that owns a decoded BlockTxn can check block_hash(), but it cannot move the transactions out: the vector is private and transactions() only borrows it. Filling an owned Block from the reply therefore requires cloning the transactions and their buffers. A consuming accessor lets callers move them into the reconstructed block while preserving the borrowing API.

Suggested change
}
}
impl BlockTxn {
/// Consumes the reply and returns its transactions in wire order.
pub fn into_transactions(self) -> Vec<Transaction> {
self.transactions
}
}

source: gpt-6.2-astra (phase2-reviewer: rust-quality)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined for this PR. No message or primitive on develop has a consuming accessor; Headers, Block and the rest only borrow. Adding one here would be the first, and new public API goes in with the consumer that needs it (#92), not ahead of it. If the node's compact relay needs to move the transactions out, it can propose the accessor then, for every message that carries a list.


🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.

Comment on lines +85 to +89
#[rstest]
#[case::block(CommandString::BLOCK, wire(&block()), P2pMsg::Block(block()))]
#[case::tx(CommandString::TX, wire(&tx()), P2pMsg::Tx(tx()))]
fn block_and_tx_decode_to_their_variants(#[case] command: CommandString, #[case] raw: Vec<u8>, #[case] msg: P2pMsg) {
assert_eq!(P2pMsg::decode_payload(&command, &raw), Ok(msg));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Suggestion: Document trailing-byte rejection on the newly typed routes

The five commands now go through decode_msg, which returns TrailingBytes even when the message itself decoded successfully. Dash Core at 938fba5028 reads the object without requiring the payload to be exhausted (for example, tx at net_processing.cpp:4896 and block at net_processing.cpp:5375). Call out this stricter SDK behavior explicitly in Breaking Changes and add a trailing-byte case to the new dispatch test. The existing ping test covers the shared guard, but the new block and tx cases only cover successful dispatch.

source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality); gpt-6.2-astra (phase2-reviewer: general, rust-quality, security-auditor)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined. Refusing trailing bytes is develop's behaviour for every typed command since e12661a, and #128 extended it the same way without a per-command note. It is tested once on the shared guard, and repeating that case per command is the per-struct test the maintainer has declined. The Breaking Changes section already says a payload that does not decode as its message is now refused.


🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.

@PastaPastaPasta
PastaPastaPasta merged commit d93f2a9 into develop Nov 18, 2026
55 checks passed
@PastaPastaPasta
PastaPastaPasta deleted the pasta/p2p-bip152-blocktx branch November 18, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants