Skip to content

Commit 559cfc4

Browse files
LLFournnotmandatory
authored andcommitted
Fix pre-segwit inputs with esplora
1 parent 52bcd10 commit 559cfc4

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/blockchain/esplora/api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub struct Vin {
1717
// None if coinbase
1818
pub prevout: Option<PrevOut>,
1919
pub scriptsig: Script,
20-
#[serde(deserialize_with = "deserialize_witness")]
20+
#[serde(deserialize_with = "deserialize_witness", default)]
2121
pub witness: Vec<Vec<u8>>,
2222
pub sequence: u32,
2323
pub is_coinbase: bool,

src/testutils/blockchain_tests.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,36 @@ macro_rules! bdk_blockchain_tests {
11241124
assert_eq!(tx_2.received, 10_000);
11251125
assert_eq!(tx_2.sent, 0);
11261126
}
1127+
1128+
#[test]
1129+
fn test_send_receive_pkh() {
1130+
let descriptors = ("pkh(cVpPVruEDdmutPzisEsYvtST1usBR3ntr8pXSyt6D2YYqXRyPcFW)".to_string(), None);
1131+
let mut test_client = TestClient::default();
1132+
let blockchain = get_blockchain(&test_client);
1133+
1134+
let wallet = get_wallet_from_descriptors(&descriptors);
1135+
#[cfg(feature = "test-rpc")]
1136+
wallet.sync(&blockchain, SyncOptions::default()).unwrap();
1137+
1138+
let _ = test_client.receive(testutils! {
1139+
@tx ( (@external descriptors, 0) => 50_000 )
1140+
});
1141+
1142+
wallet.sync(&blockchain, SyncOptions::default()).unwrap();
1143+
1144+
assert_eq!(wallet.get_balance().unwrap(), 50_000);
1145+
1146+
let tx = {
1147+
let mut builder = wallet.build_tx();
1148+
builder.add_recipient(test_client.get_node_address(None).script_pubkey(), 25_000);
1149+
let (mut psbt, _details) = builder.finish().unwrap();
1150+
wallet.sign(&mut psbt, Default::default()).unwrap();
1151+
psbt.extract_tx()
1152+
};
1153+
blockchain.broadcast(&tx).unwrap();
1154+
1155+
wallet.sync(&blockchain, SyncOptions::default()).unwrap();
1156+
}
11271157
}
11281158
};
11291159

0 commit comments

Comments
 (0)