add remove_partial_sigs to SignOptions
This commit is contained in:
parent
17d0ae0f71
commit
c2e4ba8cbd
@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Signing Taproot PSBTs (key spend and script spend)
|
- Signing Taproot PSBTs (key spend and script spend)
|
||||||
- Support for `tr()` descriptors in the `descriptor!()` macro
|
- Support for `tr()` descriptors in the `descriptor!()` macro
|
||||||
- Add support for Bitcoin Core 23.0 when using the `rpc` blockchain
|
- Add support for Bitcoin Core 23.0 when using the `rpc` blockchain
|
||||||
|
- Add `remove_partial_sigs` to `SignOptions`
|
||||||
|
|
||||||
## [v0.18.0] - [v0.17.0]
|
## [v0.18.0] - [v0.17.0]
|
||||||
|
|
||||||
|
@ -1161,6 +1161,9 @@ where
|
|||||||
let psbt_input = &mut psbt.inputs[n];
|
let psbt_input = &mut psbt.inputs[n];
|
||||||
psbt_input.final_script_sig = Some(tmp_input.script_sig);
|
psbt_input.final_script_sig = Some(tmp_input.script_sig);
|
||||||
psbt_input.final_script_witness = Some(tmp_input.witness);
|
psbt_input.final_script_witness = Some(tmp_input.witness);
|
||||||
|
if sign_options.remove_partial_sigs {
|
||||||
|
psbt_input.partial_sigs.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
debug!("satisfy error {:?} for input {}", e, n);
|
debug!("satisfy error {:?} for input {}", e, n);
|
||||||
@ -3878,6 +3881,36 @@ pub(crate) mod test {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_remove_partial_sigs_after_finalize_sign_option() {
|
||||||
|
let (wallet, _, _) = get_funded_wallet("wpkh(tprv8ZgxMBicQKsPd3EupYiPRhaMooHKUHJxNsTfYuScep13go8QFfHdtkG9nRkFGb7busX4isf6X9dURGCoKgitaApQ6MupRhZMcELAxTBRJgS/*)");
|
||||||
|
|
||||||
|
for remove_partial_sigs in &[true, false] {
|
||||||
|
let addr = wallet.get_address(New).unwrap();
|
||||||
|
let mut builder = wallet.build_tx();
|
||||||
|
builder.drain_to(addr.script_pubkey()).drain_wallet();
|
||||||
|
let mut psbt = builder.finish().unwrap().0;
|
||||||
|
|
||||||
|
assert!(wallet
|
||||||
|
.sign(
|
||||||
|
&mut psbt,
|
||||||
|
SignOptions {
|
||||||
|
remove_partial_sigs: *remove_partial_sigs,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.unwrap());
|
||||||
|
|
||||||
|
psbt.inputs.iter().for_each(|input| {
|
||||||
|
if *remove_partial_sigs {
|
||||||
|
assert!(input.partial_sigs.is_empty())
|
||||||
|
} else {
|
||||||
|
assert!(!input.partial_sigs.is_empty())
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_sign_nonstandard_sighash() {
|
fn test_sign_nonstandard_sighash() {
|
||||||
let sighash = EcdsaSighashType::NonePlusAnyoneCanPay;
|
let sighash = EcdsaSighashType::NonePlusAnyoneCanPay;
|
||||||
|
@ -667,6 +667,10 @@ pub struct SignOptions {
|
|||||||
///
|
///
|
||||||
/// Defaults to `false` which will only allow signing using `SIGHASH_ALL`.
|
/// Defaults to `false` which will only allow signing using `SIGHASH_ALL`.
|
||||||
pub allow_all_sighashes: bool,
|
pub allow_all_sighashes: bool,
|
||||||
|
/// Whether to remove partial_sigs from psbt inputs while finalizing psbt.
|
||||||
|
///
|
||||||
|
/// Defaults to `true` which will remove partial_sigs after finalizing.
|
||||||
|
pub remove_partial_sigs: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::derivable_impls)]
|
#[allow(clippy::derivable_impls)]
|
||||||
@ -676,6 +680,7 @@ impl Default for SignOptions {
|
|||||||
trust_witness_utxo: false,
|
trust_witness_utxo: false,
|
||||||
assume_height: None,
|
assume_height: None,
|
||||||
allow_all_sighashes: false,
|
allow_all_sighashes: false,
|
||||||
|
remove_partial_sigs: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user