aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2019-07-31 17:24:44 -0400
committerAndrew Chow <achow101-github@achow101.com>2021-12-10 08:29:47 -0500
commit81521173ba830ca1dea204e83897482f8970e519 (patch)
tree56fb16333bc7317b4cc47be34fc29fe4a96028e7
parentd8043ddf640b1bb7a536834618c468334e3eb15f (diff)
Merge global xpubs in joinpsbts and combinepsbts
-rw-r--r--src/psbt.cpp7
-rw-r--r--src/rpc/rawtransaction.cpp7
2 files changed, 14 insertions, 0 deletions
diff --git a/src/psbt.cpp b/src/psbt.cpp
index f3ecbd63d2..4c9b439815 100644
--- a/src/psbt.cpp
+++ b/src/psbt.cpp
@@ -32,6 +32,13 @@ bool PartiallySignedTransaction::Merge(const PartiallySignedTransaction& psbt)
for (unsigned int i = 0; i < outputs.size(); ++i) {
outputs[i].Merge(psbt.outputs[i]);
}
+ for (auto& xpub_pair : psbt.m_xpubs) {
+ if (m_xpubs.count(xpub_pair.first) == 0) {
+ m_xpubs[xpub_pair.first] = xpub_pair.second;
+ } else {
+ m_xpubs[xpub_pair.first].insert(xpub_pair.second.begin(), xpub_pair.second.end());
+ }
+ }
unknown.insert(psbt.unknown.begin(), psbt.unknown.end());
return true;
diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp
index 7535ac02f7..12ade466da 100644
--- a/src/rpc/rawtransaction.cpp
+++ b/src/rpc/rawtransaction.cpp
@@ -1858,6 +1858,13 @@ static RPCHelpMan joinpsbts()
for (unsigned int i = 0; i < psbt.tx->vout.size(); ++i) {
merged_psbt.AddOutput(psbt.tx->vout[i], psbt.outputs[i]);
}
+ for (auto& xpub_pair : psbt.m_xpubs) {
+ if (merged_psbt.m_xpubs.count(xpub_pair.first) == 0) {
+ merged_psbt.m_xpubs[xpub_pair.first] = xpub_pair.second;
+ } else {
+ merged_psbt.m_xpubs[xpub_pair.first].insert(xpub_pair.second.begin(), xpub_pair.second.end());
+ }
+ }
merged_psbt.unknown.insert(psbt.unknown.begin(), psbt.unknown.end());
}