From 08f749c9147a5f3fdbbd880e0974b97084429002 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Fri, 20 Jul 2018 18:24:16 -0700 Subject: Implement joinpsbts RPC and tests Adds a joinpsbts RPC which combines multiple distinct PSBTs into one PSBT. --- src/psbt.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/psbt.cpp') diff --git a/src/psbt.cpp b/src/psbt.cpp index 81633c0cc7..424b92cfb5 100644 --- a/src/psbt.cpp +++ b/src/psbt.cpp @@ -42,6 +42,26 @@ bool PartiallySignedTransaction::IsSane() const return true; } +bool PartiallySignedTransaction::AddInput(const CTxIn& txin, PSBTInput& psbtin) +{ + if (std::find(tx->vin.begin(), tx->vin.end(), txin) != tx->vin.end()) { + return false; + } + tx->vin.push_back(txin); + psbtin.partial_sigs.clear(); + psbtin.final_script_sig.clear(); + psbtin.final_script_witness.SetNull(); + inputs.push_back(psbtin); + return true; +} + +bool PartiallySignedTransaction::AddOutput(const CTxOut& txout, const PSBTOutput& psbtout) +{ + tx->vout.push_back(txout); + outputs.push_back(psbtout); + return true; +} + bool PSBTInput::IsNull() const { return !non_witness_utxo && witness_utxo.IsNull() && partial_sigs.empty() && unknown.empty() && hd_keypaths.empty() && redeem_script.empty() && witness_script.empty(); -- cgit v1.2.3