Skip to content

Commit 50c502f

Browse files
committed
Merge bitcoin#17034: [BIP 174] PSBT version, proprietary, and xpub fields
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
2 parents a063647 + 8152117 commit 50c502f

File tree

12 files changed

+469
-101
lines changed

12 files changed

+469
-101
lines changed

src/psbt.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ bool PartiallySignedTransaction::Merge(const PartiallySignedTransaction& psbt)
3232
for (unsigned int i = 0; i < outputs.size(); ++i) {
3333
outputs[i].Merge(psbt.outputs[i]);
3434
}
35+
for (auto& xpub_pair : psbt.m_xpubs) {
36+
if (m_xpubs.count(xpub_pair.first) == 0) {
37+
m_xpubs[xpub_pair.first] = xpub_pair.second;
38+
} else {
39+
m_xpubs[xpub_pair.first].insert(xpub_pair.second.begin(), xpub_pair.second.end());
40+
}
41+
}
3542
unknown.insert(psbt.unknown.begin(), psbt.unknown.end());
3643

3744
return true;
@@ -401,3 +408,11 @@ bool DecodeRawPSBT(PartiallySignedTransaction& psbt, const std::string& tx_data,
401408
}
402409
return true;
403410
}
411+
412+
uint32_t PartiallySignedTransaction::GetVersion() const
413+
{
414+
if (m_version != std::nullopt) {
415+
return *m_version;
416+
}
417+
return 0;
418+
}

0 commit comments

Comments
 (0)