Skip to content

Commit e8849bc

Browse files
committed
run cargo fmt
1 parent 960164a commit e8849bc

File tree

1 file changed

+21
-25
lines changed
  • examples/example_wallet_hwi_signer/src

1 file changed

+21
-25
lines changed

examples/example_wallet_hwi_signer/src/main.rs

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,50 @@ use std::sync::Arc;
33
use async_hwi::bitbox::api::runtime::TokioRuntime;
44
use async_hwi::bitbox::api::{usb, BitBox};
55
use async_hwi::bitbox::NoiseConfigNoCache;
6+
use bdk_wallet::bitcoin::secp256k1::{All, Secp256k1};
67
use bdk_wallet::bitcoin::{Network, Psbt};
7-
use bdk_wallet::bitcoin::secp256k1::{Secp256k1, All};
88
use bdk_wallet::signer::{SignerError, SignerOrdering, TransactionSigner};
99
use bdk_wallet::KeychainKind;
1010
use bdk_wallet::{signer::SignerCommon, signer::SignerId, Wallet};
11-
12-
use async_hwi::{HWI, bitbox::BitBox02};
11+
12+
use async_hwi::{bitbox::BitBox02, HWI};
1313
use tokio::runtime::Runtime;
1414

1515
#[derive(Debug)]
1616
struct HwiSigner<T: HWI> {
17-
hw_device: T
17+
hw_device: T,
1818
}
1919

2020
impl<T: HWI> HwiSigner<T> {
21-
2221
async fn sign_tx(&self, psbt: &mut Psbt) -> Result<(), SignerError> {
23-
if let Err(e) = self.hw_device.sign_tx(psbt).await {
22+
if let Err(e) = self.hw_device.sign_tx(psbt).await {
2423
return Err(SignerError::External(e.to_string()));
2524
}
2625
Ok(())
2726
}
2827

2928
fn new(hw_device: T) -> Self {
30-
HwiSigner {
31-
hw_device
32-
}
29+
HwiSigner { hw_device }
3330
}
3431

3532
fn get_id(&self) -> SignerId {
3633
SignerId::Dummy(0)
3734
}
3835
}
3936

40-
impl<T> SignerCommon for HwiSigner<T>
41-
where T: Sync + Send + HWI {
42-
37+
impl<T> SignerCommon for HwiSigner<T>
38+
where
39+
T: Sync + Send + HWI,
40+
{
4341
fn id(&self, _secp: &Secp256k1<All>) -> SignerId {
4442
self.get_id()
4543
}
46-
4744
}
4845

49-
impl<T> TransactionSigner for HwiSigner<T>
50-
where T: Sync + Send + HWI {
51-
46+
impl<T> TransactionSigner for HwiSigner<T>
47+
where
48+
T: Sync + Send + HWI,
49+
{
5250
fn sign_transaction(
5351
&self,
5452
psbt: &mut Psbt,
@@ -62,16 +60,14 @@ where T: Sync + Send + HWI {
6260
}
6361

6462
#[tokio::main]
65-
async fn main() -> Result<(), anyhow::Error> {
66-
63+
async fn main() -> Result<(), anyhow::Error> {
6764
let descriptor = "wpkh(tpubD6NzVbkrYhZ4Xferm7Pz4VnjdcDPFyjVu5K4iZXQ4pVN8Cks4pHVowTBXBKRhX64pkRyJZJN5xAKj4UDNnLPb5p2sSKXhewoYx5GbTdUFWq/0/*)";
6865
let change_descriptor = "wpkh(tpubD6NzVbkrYhZ4Xferm7Pz4VnjdcDPFyjVu5K4iZXQ4pVN8Cks4pHVowTBXBKRhX64pkRyJZJN5xAKj4UDNnLPb5p2sSKXhewoYx5GbTdUFWq/1/*)";
6966

7067
let noise_config = Box::new(NoiseConfigNoCache {});
71-
let bitbox = BitBox::<TokioRuntime>::from_hid_device(
72-
usb::get_any_bitbox02().unwrap(),
73-
noise_config,
74-
).await?;
68+
let bitbox =
69+
BitBox::<TokioRuntime>::from_hid_device(usb::get_any_bitbox02().unwrap(), noise_config)
70+
.await?;
7571

7672
let pairing_device = bitbox.unlock_and_pair().await?;
7773
let paired_device = pairing_device.wait_confirm().await?;
@@ -80,15 +76,15 @@ async fn main() -> Result<(), anyhow::Error> {
8076
let _ = bb.register_wallet("test-wallet", descriptor).await.unwrap();
8177

8278
let bitbox_signer = HwiSigner::new(bb);
83-
79+
8480
let mut wallet = Wallet::create(descriptor, change_descriptor)
8581
.network(Network::Testnet)
8682
.create_wallet_no_persist()?;
87-
83+
8884
wallet.add_signer(
8985
KeychainKind::External,
9086
SignerOrdering(100),
91-
Arc::new(bitbox_signer)
87+
Arc::new(bitbox_signer),
9288
);
9389

9490
Ok(())

0 commit comments

Comments
 (0)