1
1
use std:: { thread:: sleep, time:: Duration } ;
2
2
3
3
use anyhow:: Result ;
4
- use bdk:: bitcoin:: psbt:: serialize:: Serialize ;
5
- use reqwest:: blocking:: Client ;
6
- use sbtc_cli:: commands:: {
7
- broadcast:: { broadcast_tx, BroadcastArgs } ,
8
- deposit:: { build_deposit_tx, DepositArgs } ,
9
- } ;
10
-
11
- use super :: bitcoin_client:: { electrs_url, generate_blocks} ;
12
-
13
- const WALLET_0_P2TR_ADDRESS : & str =
14
- "bcrt1pte5zmd7qzj4hdu45lh9mmdm0nwq3z35pwnxmzkwld6y0a8g83nnqhj6vc0" ;
15
- const WALLET_0_P2WPKH_ADDRESS : & str =
16
- "bcrt1q3tj2fr9scwmcw3rq5m6jslva65f2rqjxfrjz47" ;
17
- const WALLET_0_P2WPKH_WIF : & str =
18
- "cTyHitzs3VRnNxrpwxo3fXTTe569wHNUs57tQM7Z1FrzUDNB5mqm" ;
19
- const WALLET_1_P2WPKH_WIF : & str =
20
- "cNcXK2r8bNdWJQymtAW8tGS7QHNtFFvG5CdXqhhT752u29WspXRM" ;
21
- const WALLET_1_STX_ADDRESS : & str = "ST2ST2H80NP5C9SPR4ENJ1Z9CDM9PKAJVPYWPQZ50" ;
22
- const WALLET_1_P2WPKH_ADDRESS : & str =
23
- "bcrt1q3zl64vadtuh3vnsuhdgv6pm93n82ye8q6cr4ch" ;
24
-
25
4
use bdk:: {
26
- bitcoin:: PrivateKey ,
5
+ bitcoin:: { psbt :: serialize :: Serialize , PrivateKey } ,
27
6
blockchain:: {
28
7
ConfigurableBlockchain , ElectrumBlockchain , ElectrumBlockchainConfig ,
29
8
} ,
30
9
database:: MemoryDatabase ,
31
10
template:: P2Wpkh ,
32
11
SyncOptions , Wallet ,
33
12
} ;
13
+ use reqwest:: blocking:: Client ;
14
+ use sbtc_cli:: commands:: {
15
+ broadcast:: { broadcast_tx, BroadcastArgs } ,
16
+ deposit:: { build_deposit_tx, DepositArgs } ,
17
+ } ;
18
+
19
+ use super :: {
20
+ bitcoin_client:: { electrs_url, generate_blocks} ,
21
+ KeyType :: * ,
22
+ WALLETS ,
23
+ } ;
34
24
35
25
#[ test]
36
26
fn broadcast_deposit ( ) -> Result < ( ) > {
37
27
let client = Client :: new ( ) ;
38
28
{
39
- generate_blocks ( 1 , & client, WALLET_0_P2WPKH_ADDRESS ) ;
40
- generate_blocks ( 1 , & client, WALLET_1_P2WPKH_ADDRESS ) ;
29
+ generate_blocks ( 1 , & client, WALLETS [ 0 ] [ P2wpkh ] . address ) ;
30
+ generate_blocks ( 1 , & client, WALLETS [ 1 ] [ P2wpkh ] . address ) ;
41
31
// pads blocks to get rewards.
42
- generate_blocks ( 100 , & client, WALLET_0_P2WPKH_ADDRESS ) ;
32
+ generate_blocks ( 100 , & client, WALLETS [ 0 ] [ P2wpkh ] . address ) ;
43
33
} ;
44
34
45
35
let electrum_url = electrs_url ( ) ;
@@ -57,7 +47,7 @@ fn broadcast_deposit() -> Result<()> {
57
47
} )
58
48
. unwrap ( ) ;
59
49
60
- let private_key = PrivateKey :: from_wif ( WALLET_0_P2WPKH_WIF ) ?;
50
+ let private_key = PrivateKey :: from_wif ( WALLETS [ 0 ] [ P2wpkh ] . wif ) ?;
61
51
62
52
let wallet = Wallet :: new (
63
53
P2Wpkh ( private_key) ,
@@ -82,11 +72,11 @@ fn broadcast_deposit() -> Result<()> {
82
72
let tx = {
83
73
let args = DepositArgs {
84
74
node_url : electrum_url. clone ( ) ,
85
- wif : WALLET_1_P2WPKH_WIF . into ( ) ,
75
+ wif : WALLETS [ 1 ] [ P2wpkh ] . wif . into ( ) ,
86
76
network : bdk:: bitcoin:: Network :: Regtest ,
87
- recipient : WALLET_1_STX_ADDRESS . into ( ) ,
77
+ recipient : WALLETS [ 1 ] [ Stacks ] . address . into ( ) ,
88
78
amount,
89
- sbtc_wallet : WALLET_0_P2TR_ADDRESS . into ( ) ,
79
+ sbtc_wallet : WALLETS [ 0 ] [ P2tr ] . address . into ( ) ,
90
80
} ;
91
81
92
82
build_deposit_tx ( & args) . unwrap ( )
0 commit comments