@@ -9,13 +9,14 @@ use crate::ln::features::ChannelTypeFeatures;
9
9
use crate :: ln:: { ChannelId , PaymentHash } ;
10
10
use crate :: sign:: SignerProvider ;
11
11
12
- use bitcoin:: bip32:: ExtendedPrivKey ;
12
+ use bitcoin:: bip32:: { ExtendedPrivKey , ExtendedPubKey } ;
13
13
use bitcoin:: blockdata:: transaction:: Transaction ;
14
14
use bitcoin:: psbt:: { PartiallySignedTransaction , Psbt } ;
15
15
use bitcoin:: secp256k1:: PublicKey ;
16
16
use bitcoin:: { TxOut , Txid } ;
17
17
use database:: {
18
- ColorDatabaseImpl , ConsignmentBinaryData , ConsignmentHandle , PaymentDirection , PaymentHashKey , ProxyIdKey , RgbInfoKey
18
+ ColorDatabaseImpl , ConsignmentBinaryData , ConsignmentHandle , PaymentDirection , PaymentHashKey ,
19
+ ProxyIdKey , RgbInfoKey ,
19
20
} ;
20
21
use hex:: DisplayHex ;
21
22
use rgb_lib:: wallet:: rust_only:: AssetBeneficiariesMap ;
@@ -70,16 +71,14 @@ pub trait WalletProxy {
70
71
fn consume_fascia ( & self , fascia : Fascia , witness_txid : RgbTxid ) -> Result < ( ) , String > ;
71
72
}
72
73
74
+ #[ derive( Debug ) ]
73
75
pub struct WalletProxyImpl {
74
76
network : BitcoinNetwork ,
77
+ xpub : ExtendedPubKey ,
75
78
xprv : ExtendedPrivKey ,
76
79
ldk_data_dir : PathBuf ,
77
80
}
78
- impl fmt:: Debug for WalletProxyImpl {
79
- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
80
- f. debug_struct ( "WalletProxyImpl" ) . field ( "xpub_getter" , & "Function" ) . finish ( )
81
- }
82
- }
81
+
83
82
impl WalletProxy for WalletProxyImpl {
84
83
fn consume_fascia ( & self , fascia : Fascia , witness_txid : RgbTxid ) -> Result < ( ) , String > {
85
84
println ! ( "block_on consume_fascia" ) ;
@@ -89,8 +88,10 @@ impl WalletProxy for WalletProxyImpl {
89
88
}
90
89
91
90
impl WalletProxyImpl {
92
- fn new ( network : BitcoinNetwork , xprv : ExtendedPrivKey , ldk_data_dir : PathBuf ) -> Self {
93
- Self { network, xprv, ldk_data_dir }
91
+ fn new (
92
+ network : BitcoinNetwork , xpub : ExtendedPubKey , xprv : ExtendedPrivKey , ldk_data_dir : PathBuf ,
93
+ ) -> Self {
94
+ Self { network, xpub, xprv, ldk_data_dir }
94
95
}
95
96
96
97
pub fn color_psbt (
@@ -109,8 +110,7 @@ impl WalletProxyImpl {
109
110
// }
110
111
111
112
pub fn xpub ( & self ) -> String {
112
- bitcoin:: bip32:: ExtendedPubKey :: from_priv ( & bitcoin:: key:: Secp256k1 :: new ( ) , & self . xprv )
113
- . to_string ( )
113
+ self . xpub . to_string ( )
114
114
}
115
115
116
116
async fn _get_rgb_wallet ( & self , ldk_data_dir : & Path ) -> Wallet {
@@ -154,14 +154,17 @@ impl ColorSource for ColorSourceImpl {
154
154
}
155
155
156
156
impl ColorSourceImpl {
157
- pub fn new ( ldk_data_dir : PathBuf , network : BitcoinNetwork , xprv : ExtendedPrivKey ) -> Self {
157
+ pub fn new (
158
+ ldk_data_dir : PathBuf , network : BitcoinNetwork , xpub : ExtendedPubKey , xprv : ExtendedPrivKey ,
159
+ ) -> Self {
158
160
let ldk_data_dir = Arc :: new ( ldk_data_dir) ;
159
161
160
162
let instance = Self {
161
163
ldk_data_dir : Arc :: clone ( & ldk_data_dir) . to_path_buf ( ) ,
162
164
network,
163
165
wallet_proxy : WalletProxyImpl :: new (
164
166
network,
167
+ xpub,
165
168
xprv,
166
169
Arc :: clone ( & ldk_data_dir) . to_path_buf ( ) ,
167
170
) ,
@@ -624,7 +627,10 @@ impl ColorSourceImpl {
624
627
) -> Result < ( ) , MsgHandleErrInternal > {
625
628
let handle = Handle :: current ( ) ;
626
629
let _ = handle. enter ( ) ;
627
- println ! ( "block_on handle_funding" ) ;
630
+ println ! (
631
+ "block_on handle_funding txid: {}, temporary_channel_id {}" ,
632
+ funding_txid, temporary_channel_id
633
+ ) ;
628
634
let accept_res = futures:: executor:: block_on (
629
635
self . _accept_transfer ( funding_txid. clone ( ) , consignment_endpoint) ,
630
636
) ;
@@ -656,6 +662,8 @@ impl ColorSourceImpl {
656
662
} ,
657
663
} ;
658
664
665
+ println ! ( "accept consignment with contract id {}" , consignment. contract_id( ) ) ;
666
+
659
667
let funding_txid = Txid :: from_str ( & funding_txid) . unwrap ( ) ;
660
668
let mut consignment_data = ConsignmentBinaryData :: default ( ) ;
661
669
let ret = consignment. save ( & mut consignment_data) ;
@@ -680,7 +688,8 @@ impl ColorSourceImpl {
680
688
pub fn get_consignment_by_funding_txid (
681
689
& self , funding_txid : & Txid ,
682
690
) -> Option < ConsignmentBinaryData > {
683
- let handle = self . database . consignment ( ) . lock ( ) . unwrap ( ) . get_by_funding_txid ( funding_txid) ?;
691
+ let handle =
692
+ self . database . consignment ( ) . lock ( ) . unwrap ( ) . get_by_funding_txid ( funding_txid) ?;
684
693
self . database . consignment ( ) . lock ( ) . unwrap ( ) . resolve ( handle) . cloned ( )
685
694
}
686
695
0 commit comments