#[macro_export]
macro_rules! impl_client_v17__addmultisigaddress {
() => {
impl Client {
pub fn add_multisig_address_with_keys(
&self,
nrequired: u32,
keys: Vec<PublicKey>,
) -> Result<AddMultisigAddress> {
self.call("addmultisigaddress", &[nrequired.into(), into_json(keys)?])
}
pub fn add_multisig_address_with_addresses(
&self,
nrequired: u32,
keys: Vec<Address>,
) -> Result<AddMultisigAddress> {
self.call("addmultisigaddress", &[nrequired.into(), into_json(keys)?])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__bumpfee {
() => {
impl Client {
pub fn bump_fee(&self, txid: Txid) -> Result<BumpFee> {
self.call("bumpfee", &[into_json(txid)?])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__createwallet {
() => {
impl Client {
pub fn create_wallet(&self, wallet: &str) -> Result<CreateWallet> {
self.call("createwallet", &[wallet.into()])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__dumpprivkey {
() => {
impl Client {
pub fn dump_priv_key(&self, address: &Address) -> Result<DumpPrivKey> {
self.call("dumpprivkey", &[into_json(address)?])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__dumpwallet {
() => {
impl Client {
pub fn dump_wallet(&self, filename: &Path) -> Result<DumpWallet> {
self.call("dumpwallet", &[into_json(filename)?])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__getaddressesbylabel {
() => {
impl Client {
pub fn get_addresses_by_label(&self, label: &str) -> Result<GetAddressesByLabel> {
self.call("getaddressesbylabel", &[label.into()])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__getaddressinfo {
() => {
impl Client {
pub fn get_address_info(&self, address: &Address) -> Result<GetAddressInfo> {
self.call("getaddressinfo", &[into_json(address)?])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__getbalance {
() => {
impl Client {
pub fn get_balance(&self) -> Result<GetBalance> { self.call("getbalance", &[]) }
}
};
}
#[macro_export]
macro_rules! impl_client_v17__getnewaddress {
() => {
impl Client {
pub fn new_address(&self) -> Result<bitcoin::Address> {
let json = self.get_new_address(None, None)?;
let model = json.into_model().unwrap();
Ok(model.0.assume_checked())
}
pub fn new_address_with_type(&self, ty: AddressType) -> Result<bitcoin::Address> {
let json = self.get_new_address(None, Some(ty))?;
let model = json.into_model().unwrap();
Ok(model.0.assume_checked())
}
pub fn new_address_with_label(
&self,
label: &str,
) -> Result<bitcoin::Address<bitcoin::address::NetworkUnchecked>> {
let json = self.get_new_address(Some(label), None)?;
let model = json.into_model().unwrap();
Ok(model.0)
}
pub fn get_new_address(
&self,
label: Option<&str>,
ty: Option<AddressType>,
) -> Result<GetNewAddress> {
match (label, ty) {
(Some(label), Some(ty)) =>
self.call("getnewaddress", &[into_json(label)?, into_json(ty)?]),
(Some(label), None) => self.call("getnewaddress", &[into_json(label)?]),
(None, Some(ty)) => self.call("getnewaddress", &["".into(), into_json(ty)?]),
(None, None) => self.call("getnewaddress", &[]),
}
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__getrawchangeaddress {
() => {
impl Client {
pub fn get_raw_change_address(&self) -> Result<GetRawChangeAddress> {
self.call("getrawchangeaddress", &[])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__getreceivedbyaddress {
() => {
impl Client {
pub fn get_received_by_address(
&self,
address: &Address<NetworkChecked>,
) -> Result<GetReceivedByAddress> {
self.call("getreceivedbyaddress", &[address.to_string().into()])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__gettransaction {
() => {
impl Client {
pub fn get_transaction(&self, txid: Txid) -> Result<GetTransaction> {
self.call("gettransaction", &[into_json(txid)?])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__getunconfirmedbalance {
() => {
impl Client {
pub fn get_unconfirmed_balance(&self) -> Result<GetUnconfirmedBalance> {
self.call("getunconfirmedbalance", &[])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__getwalletinfo {
() => {
impl Client {
pub fn get_wallet_info(&self) -> Result<GetWalletInfo> {
self.call("getwalletinfo", &[])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__listaddressgroupings {
() => {
impl Client {
pub fn list_address_groupings(&self) -> Result<ListAddressGroupings> {
self.call("listaddressgroupings", &[])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__listlabels {
() => {
impl Client {
pub fn list_labels(&self) -> Result<ListLabels> { self.call("listlabels", &[]) }
}
};
}
#[macro_export]
macro_rules! impl_client_v17__listlockunspent {
() => {
impl Client {
pub fn list_lock_unspent(&self) -> Result<ListLockUnspent> {
self.call("listlockunspent", &[])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__listreceivedbyaddress {
() => {
impl Client {
pub fn list_received_by_address(&self) -> Result<ListReceivedByAddress> {
self.call("listreceivedbyaddress", &[])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__listsinceblock {
() => {
impl Client {
pub fn list_since_block(&self) -> Result<ListSinceBlock> {
self.call("listsinceblock", &[])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__listtransactions {
() => {
impl Client {
pub fn list_transactions(&self) -> Result<ListTransactions> {
self.call("listtransactions", &[])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__listunspent {
() => {
impl Client {
pub fn list_unspent(&self) -> Result<ListUnspent> { self.call("listunspent", &[]) }
}
};
}
#[macro_export]
macro_rules! impl_client_v17__listwallets {
() => {
impl Client {
pub fn list_wallets(&self) -> Result<ListWallets> { self.call("listwallets", &[]) }
}
};
}
#[macro_export]
macro_rules! impl_client_v17__loadwallet {
() => {
impl Client {
pub fn load_wallet(&self, filename: &str) -> Result<LoadWallet> {
self.call("loadwallet", &[into_json(filename)?])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__rescanblockchain {
() => {
impl Client {
pub fn rescan_blockchain(&self) -> Result<RescanBlockchain> {
self.call("rescanblockchain", &[])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__sendmany {
() => {
impl Client {
pub fn send_many(&self, amounts: BTreeMap<Address, Amount>) -> Result<SendMany> {
let dummy = ""; self.call("sendmany", &[into_json(dummy)?, into_json(amounts)?])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__sendtoaddress {
() => {
impl Client {
pub fn send_to_address(
&self,
address: &Address<NetworkChecked>,
amount: Amount,
) -> Result<SendToAddress> {
let args = [address.to_string().into(), into_json(amount.to_btc())?];
self.call("sendtoaddress", &args)
}
pub fn send_to_address_rbf(
&self,
address: &Address<NetworkChecked>,
amount: Amount,
) -> Result<SendToAddress> {
let comment = "";
let comment_to = "";
let subtract_fee_from_amount = false;
let replaceable = true;
let args = [
address.to_string().into(),
into_json(amount.to_btc())?,
comment.into(),
comment_to.into(),
subtract_fee_from_amount.into(),
replaceable.into(),
];
self.call("sendtoaddress", &args)
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__signmessage {
() => {
impl Client {
pub fn sign_message(&self, address: &Address, message: &str) -> Result<SignMessage> {
self.call("signmessage", &[into_json(address)?, into_json(message)?])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__signrawtransactionwithwallet {
() => {
impl Client {
pub fn sign_raw_transaction_with_wallet(
&self,
tx: &bitcoin::Transaction,
) -> Result<SignRawTransaction> {
let hex = bitcoin::consensus::encode::serialize_hex(tx);
self.call("signrawtransactionwithwallet", &[into_json(hex)?])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__unloadwallet {
() => {
impl Client {
pub fn unload_wallet(&self, wallet_name: &str) -> Result<()> {
match self.call("unloadwallet", &[into_json(wallet_name)?]) {
Ok(serde_json::Value::Null) => Ok(()),
Ok(res) => Err(Error::Returned(res.to_string())),
Err(err) => Err(err.into()),
}
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__walletcreatefundedpsbt {
() => {
impl Client {
pub fn wallet_create_funded_psbt(
&self,
inputs: Vec<WalletCreateFundedPsbtInput>,
outputs: Vec<BTreeMap<Address, Amount>>,
) -> Result<WalletCreateFundedPsbt> {
self.call("walletcreatefundedpsbt", &[into_json(inputs)?, into_json(outputs)?])
}
}
};
}
#[macro_export]
macro_rules! impl_client_v17__walletprocesspsbt {
() => {
impl Client {
pub fn wallet_process_psbt(&self, psbt: &bitcoin::Psbt) -> Result<WalletProcessPsbt> {
self.call("walletprocesspsbt", &[into_json(psbt)?])
}
}
};
}