Skip to content

Commit 8152117

Browse files
committed
Merge global xpubs in joinpsbts and combinepsbts
1 parent d8043dd commit 8152117

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/psbt.cpp

Lines changed: 7 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;

src/rpc/rawtransaction.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,6 +1858,13 @@ static RPCHelpMan joinpsbts()
18581858
for (unsigned int i = 0; i < psbt.tx->vout.size(); ++i) {
18591859
merged_psbt.AddOutput(psbt.tx->vout[i], psbt.outputs[i]);
18601860
}
1861+
for (auto& xpub_pair : psbt.m_xpubs) {
1862+
if (merged_psbt.m_xpubs.count(xpub_pair.first) == 0) {
1863+
merged_psbt.m_xpubs[xpub_pair.first] = xpub_pair.second;
1864+
} else {
1865+
merged_psbt.m_xpubs[xpub_pair.first].insert(xpub_pair.second.begin(), xpub_pair.second.end());
1866+
}
1867+
}
18611868
merged_psbt.unknown.insert(psbt.unknown.begin(), psbt.unknown.end());
18621869
}
18631870

0 commit comments

Comments
 (0)