-
Notifications
You must be signed in to change notification settings - Fork 37.7k
[BIP 174] Implement serialization support for GLOBAL_XPUB field. #16463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
242da6e
to
53041ea
Compare
52473e9
to
951f5ee
Compare
src/psbt.h
Outdated
@@ -424,6 +516,18 @@ struct PartiallySignedTransaction | |||
OverrideStream<Stream> os(&s, s.GetType(), s.GetVersion() | SERIALIZE_TRANSACTION_NO_WITNESS); | |||
SerializeToVector(os, *tx); | |||
|
|||
// Write xpubs | |||
for (const auto xpub_pair : xpubs) { | |||
for (const auto xpub : xpub_pair.second) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggested change to reference instead of copy in range loops:
- for (const auto xpub_pair : xpubs) {
- for (const auto xpub : xpub_pair.second) {
+ for (const auto& xpub_pair : xpubs) {
+ for (const auto& xpub : xpub_pair.second) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(this also fixes warnings if you build with -Wrange-loop-analysis)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, also in a few other places.
Github-Pull: bitcoin#16463 Rebased-From: 391e26f
Github-Pull: bitcoin#16463 Rebased-From: 303d0bc
Github-Pull: bitcoin#16463 Rebased-From: 5d23641
Github-Pull: bitcoin#16463 Rebased-From: 52adc78
Github-Pull: bitcoin#16463 Rebased-From: ef3b959
CExtPubKey does not store the version bytes for the extended public key. We store these so that a CExtPubKey can be serialized and deserialized with the same version bytes. Github-Pull: bitcoin#16463 Rebased-From: 812ff94
Github-Pull: bitcoin#16463 Rebased-From: 55ab6bf
Github-Pull: bitcoin#16463 Rebased-From: 391e26f
Github-Pull: bitcoin#16463 Rebased-From: 303d0bc
Github-Pull: bitcoin#16463 Rebased-From: 5d23641
Github-Pull: bitcoin#16463 Rebased-From: 52adc78
Github-Pull: bitcoin#16463 Rebased-From: ef3b959
…to psbt module SerializeToVector, UnserializeFromVector, DeserializeHDKeypaths, and SerializeHDKeypaths were in sign.h where PSBT was originally implemented. Since all of the PSBT serialization has moved to its own file, these functions should follow.
CExtPubKey does not store the version bytes for the extended public key. We store these so that a CExtPubKey can be serialized and deserialized with the same version bytes.
Combining this PR with #17034 |
8152117 Merge global xpubs in joinpsbts and combinepsbts (Andrew Chow) d8043dd Add global xpub test vectors from BIP (Andrew Chow) 35670df Add global_xpubs to decodepsbt (Andrew Chow) 9038485 Implement serializations for PSBT_GLOBAL_XPUB (Andrew Chow) c5c63b8 Implement operator< for KeyOriginInfo and CExtPubKey (Andrew Chow) d3dbb16 Separate individual HD Keypath serialization into separate functions (Andrew Chow) a69332f Store version bytes and be able to serialize them in CExtPubKey (Andrew Chow) 5fdaf6a moveonly: Move (Un)Serialize(To/From)Vector, (De)SerializeHDKeypaths to psbt module (Andrew Chow) 94065cc Test for proprietary field (Andrew Chow) a4cf810 Output proprietary type info in decodepsbt (Andrew Chow) aebe758 Implement PSBT proprietary type (Andrew Chow) 10ba0b5 Output psbt version in decodepsbt (Andrew Chow) df84fa9 Add GetVersion helper to PSBT (Andrew Chow) c3eb416 Implement PSBT versions (Andrew Chow) 3235847 Types are compact size uints (Andrew Chow) Pull request description: Implements the changes to BIP 174 proposed in bitcoin/bips#849 and bitcoin/bips#784 Implements `PSBT_GLOBAL_VERSION`, `PSBT_GLOBAL_PROPRIETARY`, `PSBT_IN_PROPRIETARY`, `PSBT_OUT_PROPRIETARY`, and `PSBT_GLOBAL_XPUB`. The `PSBT_GLOBAL_XPUB` changes are merged in from #16463. Also includes the test vectors added to BIP 174 for these fields. A number of additional changes to keypath and xpub serialization are made to support `PSBT_GLOBAL_XPUB`. ACKs for top commit: laanwj: Code review ACK 8152117 Tree-SHA512: bd71c3f26030fc23824e76a30d3d346a753e1db224ecee163d6813348feb52d3f4cf4e739a4699e2cff381197ce2a7ea4a92a054f2c3e1db579e91e92a0945e0
…elds 8152117 Merge global xpubs in joinpsbts and combinepsbts (Andrew Chow) d8043dd Add global xpub test vectors from BIP (Andrew Chow) 35670df Add global_xpubs to decodepsbt (Andrew Chow) 9038485 Implement serializations for PSBT_GLOBAL_XPUB (Andrew Chow) c5c63b8 Implement operator< for KeyOriginInfo and CExtPubKey (Andrew Chow) d3dbb16 Separate individual HD Keypath serialization into separate functions (Andrew Chow) a69332f Store version bytes and be able to serialize them in CExtPubKey (Andrew Chow) 5fdaf6a moveonly: Move (Un)Serialize(To/From)Vector, (De)SerializeHDKeypaths to psbt module (Andrew Chow) 94065cc Test for proprietary field (Andrew Chow) a4cf810 Output proprietary type info in decodepsbt (Andrew Chow) aebe758 Implement PSBT proprietary type (Andrew Chow) 10ba0b5 Output psbt version in decodepsbt (Andrew Chow) df84fa9 Add GetVersion helper to PSBT (Andrew Chow) c3eb416 Implement PSBT versions (Andrew Chow) 3235847 Types are compact size uints (Andrew Chow) Pull request description: Implements the changes to BIP 174 proposed in bitcoin/bips#849 and bitcoin/bips#784 Implements `PSBT_GLOBAL_VERSION`, `PSBT_GLOBAL_PROPRIETARY`, `PSBT_IN_PROPRIETARY`, `PSBT_OUT_PROPRIETARY`, and `PSBT_GLOBAL_XPUB`. The `PSBT_GLOBAL_XPUB` changes are merged in from bitcoin#16463. Also includes the test vectors added to BIP 174 for these fields. A number of additional changes to keypath and xpub serialization are made to support `PSBT_GLOBAL_XPUB`. ACKs for top commit: laanwj: Code review ACK 8152117 Tree-SHA512: bd71c3f26030fc23824e76a30d3d346a753e1db224ecee163d6813348feb52d3f4cf4e739a4699e2cff381197ce2a7ea4a92a054f2c3e1db579e91e92a0945e0
bitcoin/bips#784 added a new global field
GLOBAL_XPUB
to BIP 174. This PR adds support for (de)serializing this field and displaying it indecodepsbt
.