Skip to content

Commit 6e6eb9d

Browse files
begin bitcoin upgrade
This includes a lot of changed paths and method names. We need to change all bdk::x imports to bdk_wallet::x, ::bitcoin::Address now comes with type states to account for the network check, Script now is a [u8], so we should probably use ScriptBuf, etc.
1 parent cc760f0 commit 6e6eb9d

File tree

14 files changed

+184
-148
lines changed

14 files changed

+184
-148
lines changed

Cargo.lock

Lines changed: 48 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swap/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ asynchronous-codec = "0.7.0"
1919
atty = "0.2"
2020
backoff = { version = "0.4", features = [ "tokio" ] }
2121
base64 = "0.22"
22-
bdk = { version = "0.28" }
22+
bdk = { version = "0.29" }
2323
bdk_electrum = { version = "0.19", features = [ "use-rustls" ] }
2424
bdk_wallet = { version = "1.0.0-beta.5", features = [ "rusqlite" ] }
2525
big-bytes = "1"
26-
bitcoin = { version = "0.29", features = [ "rand", "serde" ] }
26+
bitcoin = { version = "0.32", features = [ "rand", "serde" ] }
2727
bmrng = "0.5.2"
2828
comfy-table = "7.1"
2929
config = { version = "0.14", default-features = false, features = [ "toml" ] }

swap/src/asb/command.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,21 +137,14 @@ where
137137
Ok(arguments)
138138
}
139139

140-
fn bitcoin_address(address: Address, is_testnet: bool) -> Result<Address> {
140+
fn bitcoin_address(address: Address<bitcoin::address::NetworkUnchecked>, is_testnet: bool) -> Result<Address<bitcoin::address::NetworkChecked>> {
141141
let network = if is_testnet {
142142
bitcoin::Network::Testnet
143143
} else {
144144
bitcoin::Network::Bitcoin
145145
};
146146

147-
if address.network != network {
148-
bail!(BitcoinAddressNetworkMismatch {
149-
expected: network,
150-
actual: address.network
151-
});
152-
}
153-
154-
Ok(address)
147+
Ok(address.require_network(network)?)
155148
}
156149

157150
fn config_path(config: Option<PathBuf>, is_testnet: bool) -> Result<PathBuf> {
@@ -306,7 +299,7 @@ pub enum RawCommand {
306299
)]
307300
amount: Option<Amount>,
308301
#[structopt(long = "address", help = "The address to receive the Bitcoin.")]
309-
address: Address,
302+
address: Address<bitcoin::address::NetworkUnchecked>,
310303
},
311304
#[structopt(
312305
about = "Prints the Bitcoin and Monero balance. Requires the monero-wallet-rpc to be running."
@@ -451,7 +444,7 @@ mod tests {
451444
env_config: mainnet_env_config,
452445
cmd: Command::WithdrawBtc {
453446
amount: None,
454-
address: Address::from_str(BITCOIN_MAINNET_ADDRESS).unwrap(),
447+
address: bitcoin_address(Address::from_str(BITCOIN_MAINNET_ADDRESS).unwrap(), false).unwrap(),
455448
},
456449
};
457450
let args = parse_args(raw_ars).unwrap();
@@ -628,7 +621,7 @@ mod tests {
628621
env_config: testnet_env_config,
629622
cmd: Command::WithdrawBtc {
630623
amount: None,
631-
address: Address::from_str(BITCOIN_TESTNET_ADDRESS).unwrap(),
624+
address: bitcoin_address(Address::from_str(BITCOIN_TESTNET_ADDRESS).unwrap(), true).unwrap(),
632625
},
633626
};
634627
let args = parse_args(raw_ars).unwrap();

swap/src/asb/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,13 @@ pub struct TorConf {
207207
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
208208
#[serde(deny_unknown_fields)]
209209
pub struct Maker {
210-
#[serde(with = "::bitcoin::util::amount::serde::as_btc")]
210+
#[serde(with = "::bitcoin::amount::serde::as_btc")]
211211
pub min_buy_btc: bitcoin::Amount,
212-
#[serde(with = "::bitcoin::util::amount::serde::as_btc")]
212+
#[serde(with = "::bitcoin::amount::serde::as_btc")]
213213
pub max_buy_btc: bitcoin::Amount,
214214
pub ask_spread: Decimal,
215215
pub price_ticker_ws_url: Url,
216-
pub external_bitcoin_redeem_address: Option<bitcoin::Address>,
216+
pub external_bitcoin_redeem_address: Option<bitcoin::Address<bitcoin::address::NetworkUnchecked>>,
217217
}
218218

219219
impl Default for TorConf {

swap/src/asb/recovery/punish.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub async fn punish(
4747
let txid = state3.punish_btc(&bitcoin_wallet).await?;
4848

4949
let state = AliceState::BtcPunished {
50-
state3: state3.clone(),
50+
state3: Box::new(state3.clone()),
5151
};
5252
db.insert_latest_state(swap_id, state.clone().into())
5353
.await?;

0 commit comments

Comments
 (0)