]> Untitled Git - bdk/commitdiff
[wallet] Add test that shwpkh populates witness_utxo
authorLLFourn <lloyd.fourn@gmail.com>
Tue, 17 Nov 2020 01:30:58 +0000 (12:30 +1100)
committerLLFourn <lloyd.fourn@gmail.com>
Tue, 17 Nov 2020 04:11:47 +0000 (15:11 +1100)
src/wallet/mod.rs

index 40f4b083d0dc1b23b9a59e5622fb7898875a7539..d09ec1526ffbf4ce1de41088dabf14c69b0ace8f 100644 (file)
@@ -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, _, _) =