psbt: add new test vectors #36329

Manually merged
Sjors merged 2 commits from 2026/09/psbt-test-vectors into master 2026-10-05 12:24:44 +00:00 AGit
Sjors commented 2026-09-24 17:22:21 +00:00 (Migrated from github.com)
Add the two new test vectors from: - https://github.com/bitcoin/bips/pull/2275 - https://github.com/bitcoin/bips/pull/1971 https://github.com/bitcoin/bips/pull/2275 additionally requires _existing_ `Combine` vectors to run in both orders, so we do that here too.
DrahtBot commented 2026-09-24 17:22:29 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
ACK brunoerg, aaron-leeb, sedited
Concept ACK fametrano

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36329 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36329.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36329#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [brunoerg](https://github.com/bitcoin/bitcoin/pull/36329#issuecomment-5829322566), [aaron-leeb](https://github.com/bitcoin/bitcoin/pull/36329#issuecomment-5852133072), [sedited](https://github.com/bitcoin/bitcoin/pull/36329#pullrequestreview-5414358273) | | Concept ACK | [fametrano](https://github.com/bitcoin/bitcoin/pull/36329#issuecomment-5952065032) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--5faf32d7da4f0f540f40219e4f7537a3-->
Sjors commented 2026-09-24 17:22:55 +00:00 (Migrated from github.com)

cc @brunoerg

cc @brunoerg
aaron-leeb commented 2026-09-25 04:42:00 +00:00 (Migrated from github.com)

ACK f2a0db6

I tested the code locally and also did some code tracing to understand that the updates to combiner test are meant to run an additional test case where the last psbt is the first processed. The purpose is to ensure that no matter the order the psbts are processed, the underlying merge logic is order-independent

Personal note: I now understand that the combinepsbt method uses dynamic dispatch to handle the RPC command "combinepsbt" received by the node and runs the C++ code from psbt.cpp line 838 where the merge takes place.

The addition of the invalid psbt test data with not matching the expected for the psbt, checks that this code from psbt.h line 134 runs with expected behavior:

if (remaining_after + expected_size != remaining_before) { throw std::ios_base::failure("Size of value was not the stated size");

ACK [f2a0db6](https://github.com/bitcoin/bitcoin/pull/36329/commits/f2a0db6309681c8ddc2963f34fb8519441f6668f) I tested the code locally and also did some code tracing to understand that the updates to combiner test are meant to run an additional test case where the last psbt is the first processed. The purpose is to ensure that no matter the order the psbts are processed, the underlying merge logic is order-independent Personal note: I now understand that the combinepsbt method uses dynamic dispatch to handle the RPC command "combinepsbt" received by the node and runs the C++ code from psbt.cpp line 838 where the merge takes place. The addition of the invalid psbt test data with <valuesize> not matching the expected <valuedata> for the psbt, checks that this code from psbt.h line 134 runs with expected behavior: `if (remaining_after + expected_size != remaining_before) { throw std::ios_base::failure("Size of value was not the stated size");`
brunoerg (Migrated from github.com) reviewed 2026-09-25 07:49:53 +00:00
brunoerg (Migrated from github.com) commented 2026-09-25 07:49:53 +00:00

nit: could move it to invalid_with_msg with its expected error.

diff --git a/test/functional/data/rpc_psbt.json b/test/functional/data/rpc_psbt.json
--- a/test/functional/data/rpc_psbt.json
+++ b/test/functional/data/rpc_psbt.json
@@ -1,6 +1,5 @@
 {
     "invalid" : [
-        "cHNidP8BADN0Af8HAAEAAAABAP8BAApzMXQo/wAAAAAB/wEDAQAAAQAAAAAAAAAAdgEAAABBAAkAAAAAAA==",
         "AgAAAAEmgXE3Ht/yhek3re6ks3t4AAwFZsuzrWRkFxPKQhcb9gAAAABqRzBEAiBwsiRRI+a/R01gxbUMBD1MaRpd...
         "cHNidP8BAHUCAAAAASaBcTce3/KF6Tet7qSze3gADAVmy7OtZGQXE8pCFxv2AAAAAAD+////AtPf9QUAAAAAGXap...
         "cHNidP8BAP0KAQIAAAACqwlJoIxa98SbghL0F+LxWrP1wz3PFTghqBOfh3pbe+QAAAAAakcwRAIgR1lmF5fAGwNr...
@@ -157,6 +156,10 @@
         [
             "cHNidP8BAgQCAAAAAQMEAAAAAAEEAQEBBQECAQYBBwH7BAIAAAAAAQBSAgAAAAHBqiVuIUuWoYIvk95Cv/O18/+N...
             "Required height based locktime is invalid (0)"
+        ],
+        [
+            "cHNidP8BADN0Af8HAAEAAAABAP8BAApzMXQo/wAAAAAB/wEDAQAAAQAAAAAAAAAAdgEAAABBAAkAAAAAAA==",
+            "Size of value was not the stated size"
         ]
     ],
     "valid" : [
nit: could move it to `invalid_with_msg` with its expected error. ```diff diff --git a/test/functional/data/rpc_psbt.json b/test/functional/data/rpc_psbt.json --- a/test/functional/data/rpc_psbt.json +++ b/test/functional/data/rpc_psbt.json @@ -1,6 +1,5 @@ { "invalid" : [ - "cHNidP8BADN0Af8HAAEAAAABAP8BAApzMXQo/wAAAAAB/wEDAQAAAQAAAAAAAAAAdgEAAABBAAkAAAAAAA==", "AgAAAAEmgXE3Ht/yhek3re6ks3t4AAwFZsuzrWRkFxPKQhcb9gAAAABqRzBEAiBwsiRRI+a/R01gxbUMBD1MaRpd... "cHNidP8BAHUCAAAAASaBcTce3/KF6Tet7qSze3gADAVmy7OtZGQXE8pCFxv2AAAAAAD+////AtPf9QUAAAAAGXap... "cHNidP8BAP0KAQIAAAACqwlJoIxa98SbghL0F+LxWrP1wz3PFTghqBOfh3pbe+QAAAAAakcwRAIgR1lmF5fAGwNr... @@ -157,6 +156,10 @@ [ "cHNidP8BAgQCAAAAAQMEAAAAAAEEAQEBBQECAQYBBwH7BAIAAAAAAQBSAgAAAAHBqiVuIUuWoYIvk95Cv/O18/+N... "Required height based locktime is invalid (0)" + ], + [ + "cHNidP8BADN0Af8HAAEAAAABAP8BAApzMXQo/wAAAAAB/wEDAQAAAQAAAAAAAAAAdgEAAABBAAkAAAAAAA==", + "Size of value was not the stated size" ] ], "valid" : [ ```
brunoerg (Migrated from github.com) approved these changes 2026-09-25 07:53:32 +00:00
brunoerg (Migrated from github.com) left a comment

ACK f2a0db6309

I'm re-running a mutation analysis for psbt, will have a result soon.

ACK f2a0db6309681c8ddc2963f34fb8519441f6668f I'm re-running a mutation analysis for psbt, will have a result soon.
Sjors (Migrated from github.com) reviewed 2026-09-25 08:16:40 +00:00
Sjors (Migrated from github.com) commented 2026-09-25 08:16:40 +00:00

Done

Done
brunoerg commented 2026-09-25 08:25:46 +00:00 (Migrated from github.com)

reACK 6fa2f3974c

reACK 6fa2f3974cbb69fb2086a8f89d300deec4486662
aaron-leeb (Migrated from github.com) reviewed 2026-09-27 02:57:19 +00:00
aaron-leeb (Migrated from github.com) commented 2026-09-27 02:57:19 +00:00

Would there be any reason to do the same for the other "invalid" without a message for further clarity?

Would there be any reason to do the same for the other "invalid" without a message for further clarity?
aaron-leeb commented 2026-09-27 02:59:06 +00:00 (Migrated from github.com)

reACK 6fa2f39

reACK [6fa2f39](https://github.com/bitcoin/bitcoin/pull/36329/commits/6fa2f3974cbb69fb2086a8f89d300deec4486662)
fametrano commented 2026-10-02 12:13:38 +00:00 (Migrated from github.com)

For what it's worth, I ran the two new vectors at 6fa2f3974c through btclib-wallet: combining the sighash vector gives the expected PSBT byte for byte in both orders, and the new invalid PSBT is rejected.

ACK

For what it's worth, I ran the two new vectors at 6fa2f3974cbb69fb2086a8f89d300deec4486662 through btclib-wallet: combining the sighash vector gives the expected PSBT byte for byte in both orders, and the new invalid PSBT is rejected. ACK
First-time contributor

Base: a829aeaac1aff6cb786aab7d2514b49eb233334b
Head: 6fa2f3974cbb69fb2086a8f89d300deec4486662

No verified findings are available from this partial review.

Review coverage was incomplete. The adversarial review had incomplete evidence. The adversarial_glm review did not complete.

Full review report

<!-- forgejo-review-bot:bitcoin/bitcoin --> Base: `a829aeaac1aff6cb786aab7d2514b49eb233334b` Head: `6fa2f3974cbb69fb2086a8f89d300deec4486662` No verified findings are available from this partial review. Review coverage was incomplete. The adversarial review had incomplete evidence. The adversarial_glm review did not complete. [Full review report](<https://review.fish.foo/traces/36329-6fa2f3974cbb69fb2086a8f89d300deec4486662-269-1.html>)
sedited (Migrated from github.com) approved these changes 2026-10-05 12:17:58 +00:00
sedited (Migrated from github.com) left a comment
ACK 6fa2f3974cbb69fb2086a8f89d300deec4486662
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36329
No description provided.