Skip to content

Commit

Permalink
f Account for Address network types now require checks
Browse files Browse the repository at this point in the history
  • Loading branch information
tnull committed Dec 12, 2023
1 parent 6863fec commit e261ba9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/test/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use bitcoin::{Address, Amount, Network, OutPoint, Txid};

use bitcoind::bitcoincore_rpc::RpcApi;
use electrsd::bitcoind::bitcoincore_rpc::bitcoincore_rpc_json::AddressType;
use electrsd::{bitcoind, bitcoind::BitcoinD, ElectrsD};
use electrsd::electrum_client::ElectrumApi;
use electrsd::{bitcoind, bitcoind::BitcoinD, ElectrsD};

use regex;

Expand Down Expand Up @@ -238,6 +238,8 @@ pub fn generate_blocks_and_wait(bitcoind: &BitcoinD, electrsd: &ElectrsD, num: u
let address = bitcoind
.client
.get_new_address(Some("test"), Some(AddressType::Legacy))
.expect("failed to get new address")
.require_network(Network::Regtest)
.expect("failed to get new address");
// TODO: expect this Result once the WouldBlock issue is resolved upstream.
let _block_hashes_res = bitcoind.client.generate_to_address(num as u64, &address);
Expand Down
2 changes: 1 addition & 1 deletion src/uniffi_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl UniffiCustomTypeConverter for Address {

fn into_custom(val: Self::Builtin) -> uniffi::Result<Self> {
if let Ok(addr) = Address::from_str(&val) {
return Ok(addr);
return Ok(addr.assume_checked());
}

Err(Error::InvalidAddress.into())
Expand Down
2 changes: 2 additions & 0 deletions tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ pub(crate) fn generate_blocks_and_wait(
let cur_height = bitcoind.get_block_count().expect("failed to get current block height");
let address = bitcoind
.get_new_address(Some("test"), Some(AddressType::Legacy))
.expect("failed to get new address")
.require_network(Network::Regtest)
.expect("failed to get new address");
// TODO: expect this Result once the WouldBlock issue is resolved upstream.
let _block_hashes_res = bitcoind.generate_to_address(num as u64, &address);
Expand Down

0 comments on commit e261ba9

Please sign in to comment.