Change PSBT::AddOutput to take just PSBTOutput

This commit is contained in:
Andrew Chow 2021-01-11 16:59:29 -05:00
parent 90cd7ec5d5
commit cd5515a266
3 changed files with 14 additions and 7 deletions

View file

@ -153,11 +153,18 @@ bool PartiallySignedTransaction::AddInput(PSBTInput& psbtin)
return false;
}
bool PartiallySignedTransaction::AddOutput(const CTxOut& txout, const PSBTOutput& psbtout)
bool PartiallySignedTransaction::AddOutput(const PSBTOutput& psbtout)
{
tx->vout.push_back(txout);
outputs.push_back(psbtout);
return true;
if (tx != nullopt) {
// This is a v0 psbt, do the v0 AddOutput
CTxOut txout(CAsset(), *psbtout.amount, psbtout.script);
tx->vout.push_back(txout);
outputs.push_back(psbtout);
return true;
}
// TOOD: Do PSBTv2
return false;
}
bool PSBTInput::GetUTXO(CTxOut& utxo) const

View file

@ -738,7 +738,7 @@ struct PartiallySignedTransaction
* same actual Bitcoin transaction.) Returns true if the merge succeeded, false otherwise. */
[[nodiscard]] bool Merge(const PartiallySignedTransaction& psbt);
bool AddInput(PSBTInput& psbtin);
bool AddOutput(const CTxOut& txout, const PSBTOutput& psbtout);
bool AddOutput(const PSBTOutput& psbtout);
void SetupFromTx(const CMutableTransaction& tx);
void CacheUnsignedTxPieces();
bool ComputeTimeLock(uint32_t& locktime) const;

View file

@ -2152,7 +2152,7 @@ static RPCHelpMan joinpsbts()
}
}
for (unsigned int i = 0; i < psbt.tx->vout.size(); ++i) {
merged_psbt.AddOutput(psbt.tx->vout[i], psbt.outputs[i]);
merged_psbt.AddOutput(psbt.outputs[i]);
}
for (auto& xpub_pair : psbt.m_xpubs) {
if (merged_psbt.m_xpubs.count(xpub_pair.first) == 0) {
@ -2182,7 +2182,7 @@ static RPCHelpMan joinpsbts()
shuffled_psbt.AddInput(merged_psbt.inputs[i]);
}
for (int i : output_indices) {
shuffled_psbt.AddOutput(merged_psbt.tx->vout[i], merged_psbt.outputs[i]);
shuffled_psbt.AddOutput(merged_psbt.outputs[i]);
}
shuffled_psbt.unknown.insert(merged_psbt.unknown.begin(), merged_psbt.unknown.end());