@@ -11,28 +11,24 @@ use std::path::Path;
11
11
12
12
use bitcoin:: hashes:: { sha256d, Hash } ;
13
13
use bitcoin:: psbt:: Psbt ;
14
- use bitcoin:: secp256k1:: { self , Secp256k1 } ;
15
- use bitcoin:: { psbt, Amount , OutPoint , Sequence , Transaction , TxIn , TxOut , Txid } ;
14
+ use bitcoin:: { psbt, secp256k1, Amount , OutPoint , Sequence , Transaction , TxIn , TxOut , Txid } ;
16
15
use bitcoind:: bitcoincore_rpc:: { json, Client , RpcApi } ;
17
16
use miniscript:: bitcoin:: absolute;
18
17
use miniscript:: psbt:: PsbtExt ;
19
- use miniscript:: { bitcoin, Descriptor } ;
18
+ use miniscript:: { bitcoin, DefiniteDescriptorKey , Descriptor } ;
20
19
21
20
mod setup;
22
21
use setup:: test_util:: { self , PubData , TestData } ;
23
22
24
23
// parse ~30 miniscripts from file
25
- pub ( crate ) fn parse_miniscripts (
26
- secp : & Secp256k1 < secp256k1:: All > ,
27
- pubdata : & PubData ,
28
- ) -> Vec < Descriptor < bitcoin:: PublicKey > > {
24
+ pub ( crate ) fn parse_miniscripts ( pubdata : & PubData ) -> Vec < Descriptor < DefiniteDescriptorKey > > {
29
25
// File must exist in current path before this produces output
30
26
let mut desc_vec = vec ! [ ] ;
31
27
// Consumes the iterator, returns an (Optional) String
32
28
for line in read_lines ( "tests/data/random_ms.txt" ) {
33
29
let ms = test_util:: parse_insane_ms ( & line. unwrap ( ) , pubdata) ;
34
30
let wsh = Descriptor :: new_wsh ( ms) . unwrap ( ) ;
35
- desc_vec. push ( wsh. derived_descriptor ( secp , 0 ) . unwrap ( ) ) ;
31
+ desc_vec. push ( wsh. at_derivation_index ( 0 ) . unwrap ( ) ) ;
36
32
}
37
33
desc_vec
38
34
}
@@ -71,7 +67,7 @@ fn get_vout(cl: &Client, txid: Txid, value: u64) -> (OutPoint, TxOut) {
71
67
72
68
pub fn test_from_cpp_ms ( cl : & Client , testdata : & TestData ) {
73
69
let secp = secp256k1:: Secp256k1 :: new ( ) ;
74
- let desc_vec = parse_miniscripts ( & secp , & testdata. pubdata ) ;
70
+ let desc_vec = parse_miniscripts ( & testdata. pubdata ) ;
75
71
let sks = & testdata. secretdata . sks ;
76
72
let pks = & testdata. pubdata . pks ;
77
73
// Generate some blocks
@@ -152,6 +148,7 @@ pub fn test_from_cpp_ms(cl: &Client, testdata: &TestData) {
152
148
input. witness_utxo = Some ( witness_utxo) ;
153
149
input. witness_script = Some ( desc. explicit_script ( ) . unwrap ( ) ) ;
154
150
psbt. inputs . push ( input) ;
151
+ psbt. update_input_with_descriptor ( 0 , & desc) . unwrap ( ) ;
155
152
psbt. outputs . push ( psbt:: Output :: default ( ) ) ;
156
153
psbts. push ( psbt) ;
157
154
}
@@ -160,7 +157,8 @@ pub fn test_from_cpp_ms(cl: &Client, testdata: &TestData) {
160
157
// Sign the transactions with all keys
161
158
// AKA the signer role of psbt
162
159
for i in 0 ..psbts. len ( ) {
163
- let ms = if let Descriptor :: Wsh ( wsh) = & desc_vec[ i] {
160
+ let wsh_derived = desc_vec[ i] . derived_descriptor ( & secp) . unwrap ( ) ;
161
+ let ms = if let Descriptor :: Wsh ( wsh) = & wsh_derived {
164
162
match wsh. as_inner ( ) {
165
163
miniscript:: descriptor:: WshInner :: Ms ( ms) => ms,
166
164
_ => unreachable ! ( ) ,
0 commit comments