mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
Change PSBT::AddOutput to take just PSBTOutput
This commit is contained in:
parent
8f65e12211
commit
b980898dfd
4 changed files with 16 additions and 9 deletions
|
@ -157,11 +157,18 @@ bool PartiallySignedTransaction::AddInput(PSBTInput& psbtin)
|
|||
Assert(false);
|
||||
}
|
||||
|
||||
bool PartiallySignedTransaction::AddOutput(const CTxOut& txout, const PSBTOutput& psbtout)
|
||||
bool PartiallySignedTransaction::AddOutput(const PSBTOutput& psbtout)
|
||||
{
|
||||
if (tx != std::nullopt) {
|
||||
// This is a v0 psbt, do the v0 AddOutput
|
||||
CTxOut txout(*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
|
||||
|
|
|
@ -1324,7 +1324,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;
|
||||
|
|
|
@ -1865,7 +1865,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) {
|
||||
|
@ -1895,7 +1895,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());
|
||||
|
||||
|
|
|
@ -87,8 +87,8 @@ FUZZ_TARGET(psbt)
|
|||
for (auto& psbt_in : psbt_merge.inputs) {
|
||||
(void)psbt_mut.AddInput(psbt_in);
|
||||
}
|
||||
for (unsigned int i = 0; i < psbt_merge.tx->vout.size(); ++i) {
|
||||
Assert(psbt_mut.AddOutput(psbt_merge.tx->vout[i], psbt_merge.outputs[i]));
|
||||
for (const auto& psbt_out : psbt_merge.outputs) {
|
||||
Assert(psbt_mut.AddOutput(psbt_out));
|
||||
}
|
||||
psbt_mut.unknown.insert(psbt_merge.unknown.begin(), psbt_merge.unknown.end());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue