Skip to content

Commit 1219d3d

Browse files
committed
Update create_wallet to support Core v0.23.0
1 parent 657eebd commit 1219d3d

File tree

3 files changed

+41
-13
lines changed

3 files changed

+41
-13
lines changed

client/src/client.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -271,22 +271,28 @@ pub trait RpcApi: Sized {
271271

272272
fn create_wallet(
273273
&self,
274-
wallet: &str,
274+
wallet_name: &str,
275275
disable_private_keys: Option<bool>,
276276
blank: Option<bool>,
277277
passphrase: Option<&str>,
278278
avoid_reuse: Option<bool>,
279+
descriptors: Option<bool>,
280+
load_on_startup: Option<bool>,
281+
external_signer: Option<bool>,
279282
) -> Result<json::LoadWalletResult> {
280283
let mut args = [
281-
wallet.into(),
284+
wallet_name.into(),
282285
opt_into_json(disable_private_keys)?,
283286
opt_into_json(blank)?,
284287
opt_into_json(passphrase)?,
285288
opt_into_json(avoid_reuse)?,
289+
opt_into_json(descriptors)?,
290+
opt_into_json(load_on_startup)?,
291+
opt_into_json(external_signer)?,
286292
];
287293
self.call(
288294
"createwallet",
289-
handle_defaults(&mut args, &[false.into(), false.into(), into_json("")?, false.into()]),
295+
handle_defaults(&mut args, &[false.into(), false.into(), into_json("")?, false.into(), true.into(), false.into(), false.into()]),
290296
)
291297
}
292298

integration_test/run.sh

+4
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,15 @@ sleep 3
2121
BLOCKFILTERARG=""
2222
if bitcoind -version | grep -q "v0\.\(19\|2\)"; then
2323
BLOCKFILTERARG="-blockfilterindex=1"
24+
elif bitcoind -version | grep -q "v\(22\|23\)"; then
25+
BLOCKFILTERARG="-blockfilterindex=1"
2426
fi
2527

2628
FALLBACKFEEARG=""
2729
if bitcoind -version | grep -q "v0\.2"; then
2830
FALLBACKFEEARG="-fallbackfee=0.00001000"
31+
elif bitcoind -version | grep -q "v\(22\|23\)"; then
32+
FALLBACKFEEARG="-fallbackfee=0.00001000"
2933
fi
3034

3135
bitcoind -regtest $BLOCKFILTERARG $FALLBACKFEEARG \

integration_test/src/main.rs

+28-10
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ use bitcoin::hashes::hex::{FromHex, ToHex};
2727
use bitcoin::hashes::Hash;
2828
use bitcoin::secp256k1;
2929
use bitcoin::{
30-
Address, Amount, Network, OutPoint, PrivateKey, Script, EcdsaSighashType, SignedAmount, Transaction,
31-
TxIn, TxOut, Txid, Witness,
30+
Address, Amount, EcdsaSighashType, Network, OutPoint, PrivateKey, Script, SignedAmount,
31+
Transaction, TxIn, TxOut, Txid, Witness,
3232
};
3333
use bitcoincore_rpc::bitcoincore_rpc_json::{
3434
GetBlockTemplateModes, GetBlockTemplateRules, ScanTxOutRequest,
@@ -134,7 +134,7 @@ fn main() {
134134
unsafe { VERSION = cl.version().unwrap() };
135135
println!("Version: {}", version());
136136

137-
cl.create_wallet("testwallet", None, None, None, None).unwrap();
137+
cl.create_wallet("testwallet", None, None, None, None, Some(false), None, None).unwrap();
138138

139139
test_get_mining_info(&cl);
140140
test_get_blockchain_info(&cl);
@@ -596,8 +596,9 @@ fn test_sign_raw_transaction_with_send_raw_transaction(cl: &Client) {
596596
}],
597597
};
598598

599-
let res =
600-
cl.sign_raw_transaction_with_key(&tx, &[sk], None, Some(EcdsaSighashType::All.into())).unwrap();
599+
let res = cl
600+
.sign_raw_transaction_with_key(&tx, &[sk], None, Some(EcdsaSighashType::All.into()))
601+
.unwrap();
601602
assert!(res.complete);
602603
let _ = cl.send_raw_transaction(&res.transaction().unwrap()).unwrap();
603604
}
@@ -936,6 +937,9 @@ fn test_create_wallet(cl: &Client) {
936937
blank: Option<bool>,
937938
passphrase: Option<&'a str>,
938939
avoid_reuse: Option<bool>,
940+
descriptors: Option<bool>,
941+
load_on_startup: Option<bool>,
942+
external_signer: Option<bool>,
939943
}
940944

941945
let mut wallet_params = vec![
@@ -945,20 +949,29 @@ fn test_create_wallet(cl: &Client) {
945949
blank: None,
946950
passphrase: None,
947951
avoid_reuse: None,
952+
descriptors: None,
953+
load_on_startup: None,
954+
external_signer: None,
948955
},
949956
WalletParams {
950957
name: wallet_names[1],
951958
disable_private_keys: Some(true),
952959
blank: None,
953960
passphrase: None,
954961
avoid_reuse: None,
962+
descriptors: None,
963+
load_on_startup: None,
964+
external_signer: None,
955965
},
956966
WalletParams {
957967
name: wallet_names[2],
958968
disable_private_keys: None,
959969
blank: Some(true),
960970
passphrase: None,
961971
avoid_reuse: None,
972+
descriptors: None,
973+
load_on_startup: None,
974+
external_signer: None,
962975
},
963976
];
964977

@@ -969,13 +982,19 @@ fn test_create_wallet(cl: &Client) {
969982
blank: None,
970983
passphrase: Some("pass"),
971984
avoid_reuse: None,
985+
descriptors: None,
986+
load_on_startup: None,
987+
external_signer: None,
972988
});
973989
wallet_params.push(WalletParams {
974990
name: wallet_names[4],
975991
disable_private_keys: None,
976992
blank: None,
977993
passphrase: None,
978994
avoid_reuse: Some(true),
995+
descriptors: None,
996+
load_on_startup: None,
997+
external_signer: None,
979998
});
980999
}
9811000

@@ -987,6 +1006,9 @@ fn test_create_wallet(cl: &Client) {
9871006
wallet_param.blank,
9881007
wallet_param.passphrase,
9891008
wallet_param.avoid_reuse,
1009+
wallet_param.descriptors,
1010+
wallet_param.load_on_startup,
1011+
wallet_param.external_signer,
9901012
)
9911013
.unwrap();
9921014

@@ -1081,11 +1103,7 @@ fn test_add_ban(cl: &Client) {
10811103
let res = cl.list_banned().unwrap();
10821104
assert_eq!(res.len(), 0);
10831105

1084-
assert_error_message!(
1085-
cl.add_ban("INVALID_STRING", 0, false),
1086-
-30,
1087-
"Error: Invalid IP/Subnet"
1088-
);
1106+
assert_error_message!(cl.add_ban("INVALID_STRING", 0, false), -30, "Error: Invalid IP/Subnet");
10891107
}
10901108

10911109
fn test_set_network_active(cl: &Client) {

0 commit comments

Comments
 (0)