From: LLFourn Date: Tue, 17 Nov 2020 01:30:58 +0000 (+1100) Subject: [wallet] Add test that shwpkh populates witness_utxo X-Git-Tag: v0.2.0~67 X-Git-Url: http://internal-gitweb-vhost/%22https:/parse/scripts/database/-script/enum.FromScriptError.html?a=commitdiff_plain;h=fcc408f346104b30e8d9385325392be5b89241d4;p=bdk [wallet] Add test that shwpkh populates witness_utxo --- diff --git a/src/wallet/mod.rs b/src/wallet/mod.rs index 40f4b083..d09ec152 100644 --- a/src/wallet/mod.rs +++ b/src/wallet/mod.rs @@ -2121,6 +2121,23 @@ mod test { assert!(psbt.inputs[0].witness_utxo.is_some()); } + #[test] + fn test_create_tx_shwpkh_has_witness_utxo() { + let (wallet, _, _) = + get_funded_wallet("sh(wpkh(cVpPVruEDdmutPzisEsYvtST1usBR3ntr8pXSyt6D2YYqXRyPcFW))"); + let addr = wallet.get_new_address().unwrap(); + let (psbt, _) = wallet + .create_tx( + TxBuilder::new() + .set_single_recipient(addr.script_pubkey()) + .drain_wallet(), + ) + .unwrap(); + + assert!(psbt.inputs[0].non_witness_utxo.is_none()); + assert!(psbt.inputs[0].witness_utxo.is_some()); + } + #[test] fn test_create_tx_both_non_witness_utxo_and_witness_utxo() { let (wallet, _, _) =