mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-11 09:42:17 +01:00
psbt: Allow both non_witness_utxo and witness_utxo
This commit is contained in:
29
src/psbt.cpp
29
src/psbt.cpp
@@ -35,14 +35,6 @@ bool PartiallySignedTransaction::Merge(const PartiallySignedTransaction& psbt)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PartiallySignedTransaction::IsSane() const
|
||||
{
|
||||
for (PSBTInput input : inputs) {
|
||||
if (!input.IsSane()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PartiallySignedTransaction::AddInput(const CTxIn& txin, PSBTInput& psbtin)
|
||||
{
|
||||
if (std::find(tx->vin.begin(), tx->vin.end(), txin) != tx->vin.end()) {
|
||||
@@ -158,18 +150,6 @@ void PSBTInput::Merge(const PSBTInput& input)
|
||||
if (final_script_witness.IsNull() && !input.final_script_witness.IsNull()) final_script_witness = input.final_script_witness;
|
||||
}
|
||||
|
||||
bool PSBTInput::IsSane() const
|
||||
{
|
||||
// Cannot have both witness and non-witness utxos
|
||||
if (!witness_utxo.IsNull() && non_witness_utxo) return false;
|
||||
|
||||
// If we have a witness_script or a scriptWitness, we must also have a witness utxo
|
||||
if (!witness_script.empty() && witness_utxo.IsNull()) return false;
|
||||
if (!final_script_witness.IsNull() && witness_utxo.IsNull()) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void PSBTOutput::FillSignatureData(SignatureData& sigdata) const
|
||||
{
|
||||
if (!redeem_script.empty()) {
|
||||
@@ -261,11 +241,6 @@ bool SignPSBTInput(const SigningProvider& provider, PartiallySignedTransaction&
|
||||
bool require_witness_sig = false;
|
||||
CTxOut utxo;
|
||||
|
||||
// Verify input sanity, which checks that at most one of witness or non-witness utxos is provided.
|
||||
if (!input.IsSane()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (input.non_witness_utxo) {
|
||||
// If we're taking our information from a non-witness UTXO, verify that it matches the prevout.
|
||||
COutPoint prevout = tx.vin[index].prevout;
|
||||
@@ -356,10 +331,6 @@ TransactionError CombinePSBTs(PartiallySignedTransaction& out, const std::vector
|
||||
return TransactionError::PSBT_MISMATCH;
|
||||
}
|
||||
}
|
||||
if (!out.IsSane()) {
|
||||
return TransactionError::INVALID_PSBT;
|
||||
}
|
||||
|
||||
return TransactionError::OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user