diff --git a/bitcoin-rpc-provider/src/lib.rs b/bitcoin-rpc-provider/src/lib.rs index 112a4b00..b8153ba5 100644 --- a/bitcoin-rpc-provider/src/lib.rs +++ b/bitcoin-rpc-provider/src/lib.rs @@ -227,6 +227,10 @@ impl Wallet for BitcoinCoreProvider { .map_err(rpc_err_to_manager_err) } + fn get_new_change_address(&self) -> Result { + self.get_new_address() + } + fn get_new_secret_key(&self) -> Result { let sk = SecretKey::new(&mut thread_rng()); let network = self.get_network()?; diff --git a/dlc-manager/src/lib.rs b/dlc-manager/src/lib.rs index d6707ec8..0ffc4154 100644 --- a/dlc-manager/src/lib.rs +++ b/dlc-manager/src/lib.rs @@ -94,6 +94,8 @@ pub trait Signer { pub trait Wallet: Signer { /// Returns a new (unused) address. fn get_new_address(&self) -> Result; + /// Returns a new (unused) change address. + fn get_new_change_address(&self) -> Result; /// Generate a new secret key and store it in the wallet so that it can later /// be retrieved. fn get_new_secret_key(&self) -> Result; diff --git a/dlc-manager/src/utils.rs b/dlc-manager/src/utils.rs index 6066a764..fe2c4f81 100644 --- a/dlc-manager/src/utils.rs +++ b/dlc-manager/src/utils.rs @@ -76,7 +76,7 @@ where let payout_addr = wallet.get_new_address()?; let payout_spk = payout_addr.script_pubkey(); let payout_serial_id = get_new_serial_id(); - let change_addr = wallet.get_new_address()?; + let change_addr = wallet.get_new_change_address()?; let change_spk = change_addr.script_pubkey(); let change_serial_id = get_new_serial_id(); diff --git a/mocks/src/mock_wallet.rs b/mocks/src/mock_wallet.rs index b83b60d0..591acb87 100644 --- a/mocks/src/mock_wallet.rs +++ b/mocks/src/mock_wallet.rs @@ -68,6 +68,10 @@ impl Wallet for MockWallet { Ok(get_address()) } + fn get_new_change_address(&self) -> Result { + Ok(get_address()) + } + fn get_new_secret_key(&self) -> Result { Ok(get_secret_key()) } diff --git a/simple-wallet/src/lib.rs b/simple-wallet/src/lib.rs index 3f835866..3717e821 100644 --- a/simple-wallet/src/lib.rs +++ b/simple-wallet/src/lib.rs @@ -219,6 +219,10 @@ where Ok(address) } + fn get_new_change_address(&self) -> Result
{ + self.get_new_address() + } + fn get_new_secret_key(&self) -> Result { let seckey = SecretKey::new(&mut thread_rng()); let pubkey = PublicKey::from_secret_key(&self.secp_ctx, &seckey);