Skip to content

Commit 1bbd13b

Browse files
committed
Allow non_witness_utxo for segwit PSBTs
Some PSBT may only contain the `non_witness_utxo` to save space, since the `witness_utxo` would be strictly redundant. This should not be considered an error.
1 parent 9f63165 commit 1bbd13b

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

src/psbt/mod.rs

+9-16
Original file line numberDiff line numberDiff line change
@@ -549,10 +549,9 @@ pub trait PsbtExt {
549549
///
550550
/// This is the checked version of [`update_with_descriptor_unchecked`]. It checks that the
551551
/// `witness_utxo` and `non_witness_utxo` are sane and have a `script_pubkey` that matches the
552-
/// descriptor. In particular, it makes sure segwit descriptors always have `witness_utxo`
553-
/// present and pre-segwit descriptors always have `non_witness_utxo` present (and the txid
554-
/// matches). If both `witness_utxo` and `non_witness_utxo` are present then it also checks they
555-
/// are consistent with each other.
552+
/// descriptor. In particular, it makes sure pre-segwit descriptors always have `non_witness_utxo`
553+
/// present (and the txid matches). If both `witness_utxo` and `non_witness_utxo` are present
554+
/// then it also checks they are consistent with each other.
556555
///
557556
/// Hint: because of the *[segwit bug]* some PSBT signers require that `non_witness_utxo` is
558557
/// present on segwitv0 inputs regardless but this function doesn't enforce this so you will
@@ -779,18 +778,12 @@ impl PsbtExt for Psbt {
779778
return Err(UtxoUpdateError::UtxoCheck);
780779
}
781780
}
782-
(None, Some(non_witness_utxo)) => {
783-
if desc_type.segwit_version().is_some() {
784-
return Err(UtxoUpdateError::UtxoCheck);
785-
}
786-
787-
non_witness_utxo
788-
.output
789-
.get(txin.previous_output.vout as usize)
790-
.ok_or(UtxoUpdateError::UtxoCheck)?
791-
.script_pubkey
792-
.clone()
793-
}
781+
(None, Some(non_witness_utxo)) => non_witness_utxo
782+
.output
783+
.get(txin.previous_output.vout as usize)
784+
.ok_or(UtxoUpdateError::UtxoCheck)?
785+
.script_pubkey
786+
.clone(),
794787
(Some(witness_utxo), Some(non_witness_utxo)) => {
795788
if witness_utxo
796789
!= non_witness_utxo

0 commit comments

Comments
 (0)