1+ use std:: str:: FromStr ;
12use std:: sync:: Arc ;
23use std:: time:: Duration ;
34
@@ -12,7 +13,7 @@ use boltz_client::swaps::SwapTransactionParams;
1213use boltz_client:: swaps:: TransactionOptions ;
1314use boltz_client:: util:: secrets:: Preimage ;
1415use boltz_client:: Secp256k1 ;
15- use boltz_client:: { Keypair , PublicKey } ;
16+ use boltz_client:: { Bolt11Invoice , Keypair , PublicKey } ;
1617use lwk_wollet:: elements;
1718use lwk_wollet:: secp256k1:: rand:: thread_rng;
1819
@@ -23,7 +24,7 @@ pub struct InvoiceResponse {
2324 pub swap_id : String ,
2425 /// The invoice to show to the payer, the invoice amount will be exactly like the amount parameter,
2526 /// However, the receiver will receive `amount - fee`
26- pub bolt11_invoice : String ,
27+ pub bolt11_invoice : Bolt11Invoice ,
2728
2829 /// The fee of the swap provider
2930 pub fee : u64 ,
@@ -69,16 +70,17 @@ impl LightningSession {
6970 } ;
7071
7172 let reverse_resp = self . api . post_reverse_req ( create_reverse_req) . await ?;
72- let invoice = reverse_resp
73+ let invoice_str = reverse_resp
7374 . invoice
7475 . as_ref ( )
7576 . ok_or ( Error :: MissingInvoiceInResponse ( reverse_resp. id . clone ( ) ) ) ?
7677 . clone ( ) ;
78+ let invoice = Bolt11Invoice :: from_str ( & invoice_str) ?;
7779 let fee = amount. checked_sub ( reverse_resp. onchain_amount ) . ok_or (
7880 Error :: ExpectedAmountLowerThanInvoice ( amount, reverse_resp. id . clone ( ) ) ,
7981 ) ?;
8082
81- let _ = check_for_mrh ( & self . api , & invoice , chain) . await ?. ok_or (
83+ let _ = check_for_mrh ( & self . api , & invoice_str , chain) . await ?. ok_or (
8284 Error :: InvoiceWithoutMagicRoutingHint ( reverse_resp. id . clone ( ) ) ,
8385 ) ?;
8486
0 commit comments