Skip to content

Commit 1d521f4

Browse files
committed
Implement version specific types for wallet - methods
1 parent 590661f commit 1d521f4

File tree

38 files changed

+519
-273
lines changed

38 files changed

+519
-273
lines changed

client/src/client_sync/v17/wallet.rs

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -471,11 +471,11 @@ macro_rules! impl_client_v17__walletprocesspsbt {
471471
macro_rules! impl_client_v17__abandontransaction {
472472
() => {
473473
impl Client {
474-
pub fn abandon_transaction(&self, txid: Txid) -> Result<()> {
474+
pub fn abandon_transaction(&self, txid: Txid) -> Result<AbandonTransaction> {
475475
match self.call("abandontransaction", &[into_json(txid)?]) {
476-
Ok(serde_json::Value::Null) => Ok(()),
477-
Ok(ref val) if val.is_null() => Ok(()),
478-
Ok(other) => Err(crate::client_sync::Error::Returned(format!("abandontransaction expected null, got: {}", other))),
476+
Ok(serde_json::Value::Null) => Ok(AbandonTransaction),
477+
Ok(ref val) if val.is_null() => Ok(AbandonTransaction),
478+
Ok(other) => Err(Error::Returned(format!("abandontransaction expected null, got: {}", other))),
479479
Err(e) => Err(e.into()),
480480
}
481481
}
@@ -488,11 +488,11 @@ macro_rules! impl_client_v17__abandontransaction {
488488
macro_rules! impl_client_v17__abortrescan {
489489
() => {
490490
impl Client {
491-
pub fn abort_rescan(&self) -> Result<()> {
491+
pub fn abort_rescan(&self) -> Result<AbortRescan> {
492492
match self.call("abortrescan", &[]) {
493-
Ok(serde_json::Value::Null) => Ok(()),
494-
Ok(ref val) if val.is_null() => Ok(()),
495-
Ok(other) => Err(crate::client_sync::Error::Returned(format!("abortrescan expected null, got: {}", other))),
493+
Ok(serde_json::Value::Null) => Ok(AbortRescan),
494+
Ok(ref val) if val.is_null() => Ok(AbortRescan),
495+
Ok(other) => Err(Error::Returned(format!("abortrescan expected null, got: {}", other))),
496496
Err(e) => Err(e.into()),
497497
}
498498
}
@@ -505,12 +505,12 @@ macro_rules! impl_client_v17__abortrescan {
505505
macro_rules! impl_client_v17__backupwallet {
506506
() => {
507507
impl Client {
508-
pub fn backup_wallet(&self, destination: &Path) -> Result<()> {
508+
pub fn backup_wallet(&self, destination: &Path) -> Result<BackupWallet> {
509509
let dest_str = destination.to_string_lossy();
510510
match self.call("backupwallet", &[dest_str.as_ref().into()]) {
511-
Ok(serde_json::Value::Null) => Ok(()),
512-
Ok(ref val) if val.is_null() => Ok(()),
513-
Ok(other) => Err(crate::client_sync::Error::Returned(format!("backupwallet expected null, got: {}", other))),
511+
Ok(serde_json::Value::Null) => Ok(BackupWallet),
512+
Ok(ref val) if val.is_null() => Ok(BackupWallet),
513+
Ok(other) => Err(Error::Returned(format!("backupwallet expected null, got: {}", other))),
514514
Err(e) => Err(e.into()),
515515
}
516516
}
@@ -523,11 +523,11 @@ macro_rules! impl_client_v17__backupwallet {
523523
macro_rules! impl_client_v17__encryptwallet {
524524
() => {
525525
impl Client {
526-
pub fn encrypt_wallet(&self, passphrase: &str) -> Result<()> {
526+
pub fn encrypt_wallet(&self, passphrase: &str) -> Result<EncryptWallet> {
527527
match self.call("encryptwallet", &[passphrase.into()]) {
528-
Ok(serde_json::Value::Null) => Ok(()),
529-
Ok(ref val) if val.is_null() => Ok(()),
530-
Ok(_) => Ok(()),
528+
Ok(serde_json::Value::Null) => Ok(EncryptWallet),
529+
Ok(ref val) if val.is_null() => Ok(EncryptWallet),
530+
Ok(other) => Err(Error::Returned(format!("encryptwallet v17-v19 expected null, got: {}", other))),
531531
Err(e) => Err(e.into()),
532532
}
533533
}
@@ -546,7 +546,7 @@ macro_rules! impl_client_v17__importaddress {
546546
label: Option<&str>,
547547
rescan: Option<bool>,
548548
p2sh: Option<bool>,
549-
) -> Result<()> {
549+
) -> Result<ImportAddress> {
550550
let mut params = vec![address_or_script.into()];
551551

552552
if label.is_some() || rescan.is_some() || p2sh.is_some() {
@@ -562,9 +562,9 @@ macro_rules! impl_client_v17__importaddress {
562562
}
563563

564564
match self.call("importaddress", &params) {
565-
Ok(serde_json::Value::Null) => Ok(()),
566-
Ok(ref val) if val.is_null() => Ok(()),
567-
Ok(other) => Err(crate::client_sync::Error::Returned(format!(
565+
Ok(serde_json::Value::Null) => Ok(ImportAddress),
566+
Ok(ref val) if val.is_null() => Ok(ImportAddress),
567+
Ok(other) => Err(Error::Returned(format!(
568568
"importaddress expected null, got: {}", other
569569
))),
570570
Err(e) => Err(e.into()),
@@ -583,11 +583,11 @@ macro_rules! impl_client_v17__importprunedfunds {
583583
&self,
584584
raw_transaction: &str,
585585
txout_proof: &str,
586-
) -> Result<()> {
586+
) -> Result<ImportPrunedFunds> {
587587
match self.call("importprunedfunds", &[raw_transaction.into(), txout_proof.into()]) {
588-
Ok(serde_json::Value::Null) => Ok(()),
589-
Ok(ref val) if val.is_null() => Ok(()),
590-
Ok(other) => Err(crate::client_sync::Error::Returned(format!(
588+
Ok(serde_json::Value::Null) => Ok(ImportPrunedFunds),
589+
Ok(ref val) if val.is_null() => Ok(ImportPrunedFunds),
590+
Ok(other) => Err(Error::Returned(format!(
591591
"importprunedfunds expected null, got: {}", other
592592
))),
593593
Err(e) => Err(e.into()),
@@ -607,7 +607,7 @@ macro_rules! impl_client_v17__importpubkey {
607607
pubkey: &PublicKey,
608608
label: Option<&str>,
609609
rescan: Option<bool>,
610-
) -> Result<()> {
610+
) -> Result<ImportPubKey> {
611611
let pubkey_hex = pubkey.to_string();
612612
let mut params = vec![pubkey_hex.into()];
613613

@@ -620,9 +620,9 @@ macro_rules! impl_client_v17__importpubkey {
620620
}
621621

622622
match self.call("importpubkey", &params) {
623-
Ok(serde_json::Value::Null) => Ok(()),
624-
Ok(ref val) if val.is_null() => Ok(()),
625-
Ok(other) => Err(crate::client_sync::Error::Returned(format!(
623+
Ok(serde_json::Value::Null) => Ok(ImportPubKey),
624+
Ok(ref val) if val.is_null() => Ok(ImportPubKey),
625+
Ok(other) => Err(Error::Returned(format!(
626626
"importpubkey expected null, got: {}", other
627627
))),
628628
Err(e) => Err(e.into()),
@@ -637,12 +637,12 @@ macro_rules! impl_client_v17__importpubkey {
637637
macro_rules! impl_client_v17__importwallet {
638638
() => {
639639
impl Client {
640-
pub fn import_wallet(&self, filename: &Path) -> Result<()> {
640+
pub fn import_wallet(&self, filename: &Path) -> Result<ImportWallet> {
641641
let filename_str = filename.to_string_lossy();
642642
match self.call("importwallet", &[filename_str.as_ref().into()]) {
643-
Ok(serde_json::Value::Null) => Ok(()),
644-
Ok(ref val) if val.is_null() => Ok(()),
645-
Ok(other) => Err(crate::client_sync::Error::Returned(format!("importwallet expected null, got: {}", other))),
643+
Ok(serde_json::Value::Null) => Ok(ImportWallet),
644+
Ok(ref val) if val.is_null() => Ok(ImportWallet),
645+
Ok(other) => Err(Error::Returned(format!("importwallet expected null, got: {}", other))),
646646
Err(e) => Err(e.into()),
647647
}
648648
}
@@ -655,16 +655,16 @@ macro_rules! impl_client_v17__importwallet {
655655
macro_rules! impl_client_v17__keypoolrefill {
656656
() => {
657657
impl Client {
658-
pub fn keypool_refill(&self, new_size: Option<usize>) -> Result<()> {
658+
pub fn keypool_refill(&self, new_size: Option<usize>) -> Result<KeypoolRefill> {
659659
let params = match new_size {
660660
Some(size) => vec![size.into()],
661661
None => vec![],
662662
};
663663

664664
match self.call("keypoolrefill", &params) {
665-
Ok(serde_json::Value::Null) => Ok(()),
666-
Ok(ref val) if val.is_null() => Ok(()),
667-
Ok(other) => Err(crate::client_sync::Error::Returned(format!("keypoolrefill expected null, got: {}", other))),
665+
Ok(serde_json::Value::Null) => Ok(KeypoolRefill),
666+
Ok(ref val) if val.is_null() => Ok(KeypoolRefill),
667+
Ok(other) => Err(Error::Returned(format!("keypoolrefill expected null, got: {}", other))),
668668
Err(e) => Err(e.into()),
669669
}
670670
}
@@ -683,7 +683,7 @@ macro_rules! impl_client_v17__lockunspent {
683683
unlock: bool,
684684
outputs: Option<&[LockUnspentOutput]>,
685685
persistent: Option<bool>,
686-
) -> Result<bool> {
686+
) -> Result<LockUnspent> {
687687
let mut params = vec![unlock.into()];
688688

689689
match outputs {
@@ -692,7 +692,7 @@ macro_rules! impl_client_v17__lockunspent {
692692
if unlock {
693693
params.push(serde_json::Value::Array(vec![]));
694694
} else {
695-
return Err(crate::client_sync::Error::Returned("lockunspent requires specific outputs when locking (unlock=false)".to_string()));
695+
return Err(Error::Returned("lockunspent requires specific outputs when locking (unlock=false)".to_string()));
696696
}
697697
}
698698
}
@@ -716,11 +716,11 @@ macro_rules! impl_client_v17__lockunspent {
716716
macro_rules! impl_client_v17__removeprunedfunds {
717717
() => {
718718
impl Client {
719-
pub fn remove_pruned_funds(&self, txid: Txid) -> Result<()> {
719+
pub fn remove_pruned_funds(&self, txid: Txid) -> Result<RemovePrunedFunds> {
720720
match self.call("removeprunedfunds", &[into_json(txid)?]) {
721-
Ok(serde_json::Value::Null) => Ok(()),
722-
Ok(ref val) if val.is_null() => Ok(()),
723-
Ok(other) => Err(crate::client_sync::Error::Returned(format!("removeprunedfunds expected null, got: {}", other))),
721+
Ok(serde_json::Value::Null) => Ok(RemovePrunedFunds),
722+
Ok(ref val) if val.is_null() => Ok(RemovePrunedFunds),
723+
Ok(other) => Err(Error::Returned(format!("removeprunedfunds expected null, got: {}", other))),
724724
Err(e) => Err(e.into()),
725725
}
726726
}
@@ -737,7 +737,7 @@ macro_rules! impl_client_v17__sethdseed {
737737
&self,
738738
new_keypool: Option<bool>,
739739
seed: Option<&PrivateKey>,
740-
) -> Result<()> {
740+
) -> Result<SetHdSeed> {
741741
let mut params = vec![];
742742

743743
if new_keypool.is_some() || seed.is_some() {
@@ -749,9 +749,9 @@ macro_rules! impl_client_v17__sethdseed {
749749
}
750750

751751
match self.call("sethdseed", &params) {
752-
Ok(serde_json::Value::Null) => Ok(()),
753-
Ok(ref val) if val.is_null() => Ok(()),
754-
Ok(other) => Err(crate::client_sync::Error::Returned(format!("sethdseed expected null, got: {}", other))),
752+
Ok(serde_json::Value::Null) => Ok(SetHdSeed),
753+
Ok(ref val) if val.is_null() => Ok(SetHdSeed),
754+
Ok(other) => Err(Error::Returned(format!("sethdseed expected null, got: {}", other))),
755755
Err(e) => Err(e.into()),
756756
}
757757
}
@@ -771,7 +771,7 @@ macro_rules! impl_client_v17__settxfee {
771771
}
772772

773773
impl Client {
774-
pub fn set_tx_fee(&self, fee_rate: bitcoin::FeeRate) -> Result<bool> {
774+
pub fn set_tx_fee(&self, fee_rate: bitcoin::FeeRate) -> Result<SetTxFee> {
775775
let amount_rpc_arg = fee_rate_to_rpc_arg_settxfee(fee_rate);
776776

777777
self.call("settxfee", &[amount_rpc_arg.into()])
@@ -785,11 +785,11 @@ macro_rules! impl_client_v17__settxfee {
785785
macro_rules! impl_client_v17__walletlock {
786786
() => {
787787
impl Client {
788-
pub fn wallet_lock(&self) -> Result<()> {
788+
pub fn wallet_lock(&self) -> Result<WalletLock> {
789789
match self.call("walletlock", &[]) {
790-
Ok(serde_json::Value::Null) => Ok(()),
791-
Ok(ref val) if val.is_null() => Ok(()),
792-
Ok(other) => Err(crate::client_sync::Error::Returned(format!("walletlock expected null, got: {}", other))),
790+
Ok(serde_json::Value::Null) => Ok(WalletLock),
791+
Ok(ref val) if val.is_null() => Ok(WalletLock),
792+
Ok(other) => Err(Error::Returned(format!("walletlock expected null, got: {}", other))),
793793
Err(e) => Err(e.into()),
794794
}
795795
}
@@ -802,11 +802,11 @@ macro_rules! impl_client_v17__walletlock {
802802
macro_rules! impl_client_v17__walletpassphrase {
803803
() => {
804804
impl Client {
805-
pub fn wallet_passphrase(&self, passphrase: &str, timeout: u64) -> Result<()> {
805+
pub fn wallet_passphrase(&self, passphrase: &str, timeout: u64) -> Result<WalletPassPhrase> {
806806
match self.call("walletpassphrase", &[passphrase.into(), timeout.into()]) {
807-
Ok(serde_json::Value::Null) => Ok(()),
808-
Ok(ref val) if val.is_null() => Ok(()),
809-
Ok(other) => Err(crate::client_sync::Error::Returned(format!("walletpassphrase expected null, got: {}", other))),
807+
Ok(serde_json::Value::Null) => Ok(WalletPassPhrase),
808+
Ok(ref val) if val.is_null() => Ok(WalletPassPhrase),
809+
Ok(other) => Err(Error::Returned(format!("walletpassphrase expected null, got: {}", other))),
810810
Err(e) => Err(e.into()),
811811
}
812812
}
@@ -819,11 +819,11 @@ macro_rules! impl_client_v17__walletpassphrase {
819819
macro_rules! impl_client_v17__walletpassphrasechange {
820820
() => {
821821
impl Client {
822-
pub fn wallet_passphrase_change(&self, old_passphrase: &str, new_passphrase: &str) -> Result<()> {
822+
pub fn wallet_passphrase_change(&self, old_passphrase: &str, new_passphrase: &str) -> Result<WalletPassPhraseChange> {
823823
match self.call("walletpassphrasechange", &[old_passphrase.into(), new_passphrase.into()]) {
824-
Ok(serde_json::Value::Null) => Ok(()),
825-
Ok(ref val) if val.is_null() => Ok(()),
826-
Ok(other) => Err(crate::client_sync::Error::Returned(format!("walletpassphrasechange expected null, got: {}", other))),
824+
Ok(serde_json::Value::Null) => Ok(WalletPassPhraseChange),
825+
Ok(ref val) if val.is_null() => Ok(WalletPassPhraseChange),
826+
Ok(other) => Err(Error::Returned(format!("walletpassphrasechange expected null, got: {}", other))),
827827
Err(e) => Err(e.into()),
828828
}
829829
}

client/src/client_sync/v20/wallet.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
macro_rules! impl_client_v20__abortrescan {
1515
() => {
1616
impl Client {
17-
pub fn abort_rescan(&self) -> Result<bool> {
17+
pub fn abort_rescan(&self) -> Result<AbortRescan> {
1818
self.call("abortrescan", &[])
1919
}
2020
}
@@ -26,7 +26,7 @@ macro_rules! impl_client_v20__abortrescan {
2626
macro_rules! impl_client_v20__encryptwallet {
2727
() => {
2828
impl Client {
29-
pub fn encrypt_wallet(&self, passphrase: &str) -> Result<String> {
29+
pub fn encrypt_wallet(&self, passphrase: &str) -> Result<EncryptWallet> {
3030
self.call("encryptwallet", &[passphrase.into()])
3131
}
3232
}

client/src/client_sync/v21/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use bitcoin::{Amount, Block, BlockHash, PublicKey, Txid};
1515
use crate::client_sync::into_json;
1616
use crate::client_sync::{AddNodeCommand, SetBanCommand};
1717
use crate::types::v17::{AddNode, ClearBanned, SetBan, DisconnectNode, Ping, SetNetworkActive, ImportPrivKey, GetConnectionCount};
18+
use crate::types::v20::*;
1819
use crate::types::v21::*;
1920

2021
#[rustfmt::skip] // Keep public re-exports separate.

client/src/client_sync/v22/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use bitcoin::{Amount, Block, BlockHash, PublicKey, Txid};
1616
use crate::client_sync::into_json;
1717
use crate::client_sync::{AddNodeCommand, SetBanCommand};
1818
use crate::types::v17::{AddNode, ClearBanned, SetBan, DisconnectNode, Ping, SetNetworkActive, ImportPrivKey, GetConnectionCount};
19+
use crate::types::v20::EncryptWallet;
1920
use crate::types::v22::*;
2021

2122
#[rustfmt::skip] // Keep public re-exports separate.

client/src/client_sync/v23/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use serde::{Deserialize, Serialize};
1717
use crate::client_sync::into_json;
1818
use crate::client_sync::{AddNodeCommand, SetBanCommand};
1919
use crate::types::v17::{AddNode, ClearBanned, SetBan, DisconnectNode, Ping, SetNetworkActive, ImportPrivKey, GetConnectionCount};
20+
use crate::types::v20::EncryptWallet;
2021
use crate::types::v23::*;
2122

2223
#[rustfmt::skip] // Keep public re-exports separate.

client/src/client_sync/v24.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use bitcoin::{Amount, Block, BlockHash, PublicKey, Txid};
1212

1313
use crate::client_sync::into_json;
1414
use crate::client_sync::{AddNodeCommand, SetBanCommand};
15-
use crate::types::v17::{AddNode, ClearBanned, SetBan, DisconnectNode, Ping, SetNetworkActive, ImportPrivKey, GetConnectionCount};
15+
use crate::types::v17::{AddNode, ClearBanned, SetBan, DisconnectNode, Ping, SetNetworkActive, ImportPrivKey, GetConnectionCount, RemovePrunedFunds};
16+
use crate::types::v20::EncryptWallet;
1617
use crate::types::v24::*;
1718

1819
#[rustfmt::skip] // Keep public re-exports separate.

client/src/client_sync/v25.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use bitcoin::{Amount, Block, BlockHash, PublicKey, Txid};
1313
use crate::client_sync::into_json;
1414
use crate::client_sync::{AddNodeCommand, SetBanCommand};
1515
use crate::types::v17::{AddNode, ClearBanned, SetBan, DisconnectNode, Ping, SetNetworkActive, ImportPrivKey, GetConnectionCount};
16+
use crate::types::v20::EncryptWallet;
1617
use crate::types::v25::*;
1718

1819
#[rustfmt::skip] // Keep public re-exports separate.

client/src/client_sync/v26/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use bitcoin::{Amount, Block, BlockHash, PublicKey, Txid};
1717
use crate::client_sync::into_json;
1818
use crate::client_sync::{AddNodeCommand, SetBanCommand};
1919
use crate::types::v17::{AddNode, ClearBanned, SetBan, DisconnectNode, Ping, SetNetworkActive, ImportPrivKey, GetConnectionCount};
20+
use crate::types::v20::EncryptWallet;
2021
use crate::types::v26::*;
2122

2223
#[rustfmt::skip] // Keep public re-exports separate.

client/src/client_sync/v26/network.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ macro_rules! impl_client_v26__addnode {
2929
match self.call("addnode", &params) {
3030
Ok(serde_json::Value::Null) => Ok(AddNode),
3131
Ok(ref val) if val.is_null() => Ok(AddNode),
32-
Ok(other) => Err(crate::client_sync::Error::Returned(format!("addnode expected null, got: {}", other))),
32+
Ok(other) => Err(Error::Returned(format!("addnode expected null, got: {}", other))),
3333
Err(e) => Err(e.into()),
3434
}
3535
}

client/src/client_sync/v27.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use bitcoin::{Amount, Block, BlockHash, PublicKey, Txid};
1313
use crate::client_sync::into_json;
1414
use crate::client_sync::{AddNodeCommand, SetBanCommand};
1515
use crate::types::v17::{AddNode, ClearBanned, SetBan, DisconnectNode, Ping, SetNetworkActive, ImportPrivKey, GetConnectionCount};
16+
use crate::types::v20::EncryptWallet;
1617
use crate::types::v27::*;
1718

1819
#[rustfmt::skip] // Keep public re-exports separate.

0 commit comments

Comments
 (0)