mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-28 13:02:38 +02:00
Merge bitcoin/bitcoin#25513: psbt: Check Taproot tree depth and leaf versions
76fb300b63
psbt: Check Taproot tree depth and leaf versions (Andrew Chow) Pull request description: Since TaprootBuilder has assertions for the depth and leaf versions, the PSBT decoder should check these values before calling TaprootBuilder::Add so that the assertions are not triggered on malformed taproot trees. Fixes https://github.com/bitcoin/bitcoin/pull/22558#issuecomment-1170935136 ACKs for top commit: Sjors: utACK76fb300b63
sipa: utACK76fb300b63
w0xlt: ACK76fb300b63
Tree-SHA512: 94b288bc1453d10bce9a8a6389bc866f2c71c76579b7908e22d6b5770ac387086f6221af8597668e62977d4d6861fe2d72ec7b052002a2c36769d056b2e66360
This commit is contained in:
commit
6900162aea
@ -866,6 +866,12 @@ struct PSBTOutput
|
||||
s_tree >> depth;
|
||||
s_tree >> leaf_ver;
|
||||
s_tree >> script;
|
||||
if (depth > TAPROOT_CONTROL_MAX_NODE_COUNT) {
|
||||
throw std::ios_base::failure("Output Taproot tree has as leaf greater than Taproot maximum depth");
|
||||
}
|
||||
if ((leaf_ver & ~TAPROOT_LEAF_MASK) != 0) {
|
||||
throw std::ios_base::failure("Output Taproot tree has a leaf with an invalid leaf version");
|
||||
}
|
||||
m_tap_tree->Add((int)depth, script, (int)leaf_ver, true /* track */);
|
||||
}
|
||||
if (!m_tap_tree->IsComplete()) {
|
||||
|
Loading…
Reference in New Issue
Block a user