Skip to content

Conversation

achow101
Copy link
Member

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 in decodepsbt.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 25, 2019

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

Conflicts

Reviewers, 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.

@laanwj laanwj added this to the 0.20.0 milestone Oct 4, 2019
@achow101 achow101 force-pushed the bip174-xpub branch 2 times, most recently from 242da6e to 53041ea Compare October 9, 2019 18:44
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) {
Copy link
Member

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) {

Copy link
Member

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)

Copy link
Member Author

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.

@laanwj laanwj modified the milestones: 0.20.0, 0.21.0 Mar 26, 2020
@laanwj laanwj added the Feature label Mar 26, 2020
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 9, 2020
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 9, 2020
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 9, 2020
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 9, 2020
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 9, 2020
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 12, 2020
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
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 12, 2020
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 12, 2020
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 12, 2020
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 12, 2020
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 12, 2020
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 12, 2020
@laanwj laanwj removed this from the 0.21.0 milestone Oct 8, 2020
…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.
@achow101
Copy link
Member Author

Combining this PR with #17034

@achow101 achow101 closed this Jan 25, 2021
laanwj added a commit that referenced this pull request Dec 10, 2021
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
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Dec 11, 2021
…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 bitcoin locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants