@@ -17,6 +17,7 @@ use lightning::ln::inbound_payment::{create, create_from_hash, ExpandedKey};
1717use lightning:: routing:: gossip:: RoutingFees ;
1818use lightning:: routing:: router:: { InFlightHtlcs , Route , RouteHint , RouteHintHop } ;
1919use lightning:: util:: logger:: Logger ;
20+ use rgb:: ContractId ;
2021use secp256k1:: PublicKey ;
2122use core:: ops:: Deref ;
2223use core:: time:: Duration ;
@@ -234,7 +235,7 @@ where
234235/// in excess of the current time.
235236pub fn create_invoice_from_channelmanager < M : Deref , T : Deref , K : Deref , F : Deref , L : Deref > (
236237 channelmanager : & ChannelManager < M , T , K , F , L > , keys_manager : K , logger : L ,
237- network : Currency , amt_msat : Option < u64 > , description : String , invoice_expiry_delta_secs : u32
238+ network : Currency , amt_msat : Option < u64 > , description : String , invoice_expiry_delta_secs : u32 , contract_id : Option < ContractId > , amt_rgb : Option < u64 >
238239) -> Result < Invoice , SignOrCreationError < ( ) > >
239240where
240241 M :: Target : chain:: Watch < <K :: Target as KeysInterface >:: Signer > ,
@@ -248,7 +249,7 @@ where
248249 . expect ( "for the foreseeable future this shouldn't happen" ) ;
249250 create_invoice_from_channelmanager_and_duration_since_epoch (
250251 channelmanager, keys_manager, logger, network, amt_msat, description, duration,
251- invoice_expiry_delta_secs
252+ invoice_expiry_delta_secs, contract_id , amt_rgb
252253 )
253254}
254255
@@ -265,7 +266,7 @@ where
265266pub fn create_invoice_from_channelmanager_with_description_hash < M : Deref , T : Deref , K : Deref , F : Deref , L : Deref > (
266267 channelmanager : & ChannelManager < M , T , K , F , L > , keys_manager : K , logger : L ,
267268 network : Currency , amt_msat : Option < u64 > , description_hash : Sha256 ,
268- invoice_expiry_delta_secs : u32
269+ invoice_expiry_delta_secs : u32 , contract_id : Option < ContractId > , amt_rgb : Option < u64 >
269270) -> Result < Invoice , SignOrCreationError < ( ) > >
270271where
271272 M :: Target : chain:: Watch < <K :: Target as KeysInterface >:: Signer > ,
@@ -282,7 +283,7 @@ where
282283
283284 create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch (
284285 channelmanager, keys_manager, logger, network, amt_msat,
285- description_hash, duration, invoice_expiry_delta_secs
286+ description_hash, duration, invoice_expiry_delta_secs, contract_id , amt_rgb
286287 )
287288}
288289
@@ -292,7 +293,7 @@ where
292293pub fn create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch < M : Deref , T : Deref , K : Deref , F : Deref , L : Deref > (
293294 channelmanager : & ChannelManager < M , T , K , F , L > , keys_manager : K , logger : L ,
294295 network : Currency , amt_msat : Option < u64 > , description_hash : Sha256 ,
295- duration_since_epoch : Duration , invoice_expiry_delta_secs : u32
296+ duration_since_epoch : Duration , invoice_expiry_delta_secs : u32 , contract_id : Option < ContractId > , amt_rgb : Option < u64 >
296297) -> Result < Invoice , SignOrCreationError < ( ) > >
297298 where
298299 M :: Target : chain:: Watch < <K :: Target as KeysInterface >:: Signer > ,
@@ -304,7 +305,7 @@ pub fn create_invoice_from_channelmanager_with_description_hash_and_duration_sin
304305 _create_invoice_from_channelmanager_and_duration_since_epoch (
305306 channelmanager, keys_manager, logger, network, amt_msat,
306307 InvoiceDescription :: Hash ( & description_hash) ,
307- duration_since_epoch, invoice_expiry_delta_secs
308+ duration_since_epoch, invoice_expiry_delta_secs, contract_id , amt_rgb
308309 )
309310}
310311
@@ -314,7 +315,7 @@ pub fn create_invoice_from_channelmanager_with_description_hash_and_duration_sin
314315pub fn create_invoice_from_channelmanager_and_duration_since_epoch < M : Deref , T : Deref , K : Deref , F : Deref , L : Deref > (
315316 channelmanager : & ChannelManager < M , T , K , F , L > , keys_manager : K , logger : L ,
316317 network : Currency , amt_msat : Option < u64 > , description : String , duration_since_epoch : Duration ,
317- invoice_expiry_delta_secs : u32
318+ invoice_expiry_delta_secs : u32 , contract_id : Option < ContractId > , amt_rgb : Option < u64 >
318319) -> Result < Invoice , SignOrCreationError < ( ) > >
319320 where
320321 M :: Target : chain:: Watch < <K :: Target as KeysInterface >:: Signer > ,
@@ -328,14 +329,14 @@ pub fn create_invoice_from_channelmanager_and_duration_since_epoch<M: Deref, T:
328329 InvoiceDescription :: Direct (
329330 & Description :: new ( description) . map_err ( SignOrCreationError :: CreationError ) ?,
330331 ) ,
331- duration_since_epoch, invoice_expiry_delta_secs
332+ duration_since_epoch, invoice_expiry_delta_secs, contract_id , amt_rgb
332333 )
333334}
334335
335336fn _create_invoice_from_channelmanager_and_duration_since_epoch < M : Deref , T : Deref , K : Deref , F : Deref , L : Deref > (
336337 channelmanager : & ChannelManager < M , T , K , F , L > , keys_manager : K , logger : L ,
337338 network : Currency , amt_msat : Option < u64 > , description : InvoiceDescription ,
338- duration_since_epoch : Duration , invoice_expiry_delta_secs : u32
339+ duration_since_epoch : Duration , invoice_expiry_delta_secs : u32 , contract_id : Option < ContractId > , amt_rgb : Option < u64 >
339340) -> Result < Invoice , SignOrCreationError < ( ) > >
340341 where
341342 M :: Target : chain:: Watch < <K :: Target as KeysInterface >:: Signer > ,
@@ -350,7 +351,7 @@ fn _create_invoice_from_channelmanager_and_duration_since_epoch<M: Deref, T: Der
350351 . create_inbound_payment ( amt_msat, invoice_expiry_delta_secs)
351352 . map_err ( |( ) | SignOrCreationError :: CreationError ( CreationError :: InvalidAmount ) ) ?;
352353 _create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash (
353- channelmanager, keys_manager, logger, network, amt_msat, description, duration_since_epoch, invoice_expiry_delta_secs, payment_hash, payment_secret)
354+ channelmanager, keys_manager, logger, network, amt_msat, description, duration_since_epoch, invoice_expiry_delta_secs, payment_hash, payment_secret, contract_id , amt_rgb )
354355}
355356
356357/// See [`create_invoice_from_channelmanager_and_duration_since_epoch`]
@@ -360,7 +361,7 @@ fn _create_invoice_from_channelmanager_and_duration_since_epoch<M: Deref, T: Der
360361pub fn create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash < M : Deref , T : Deref , K : Deref , F : Deref , L : Deref > (
361362 channelmanager : & ChannelManager < M , T , K , F , L > , keys_manager : K , logger : L ,
362363 network : Currency , amt_msat : Option < u64 > , description : String , duration_since_epoch : Duration ,
363- invoice_expiry_delta_secs : u32 , payment_hash : PaymentHash
364+ invoice_expiry_delta_secs : u32 , payment_hash : PaymentHash , contract_id : Option < ContractId > , amt_rgb : Option < u64 >
364365) -> Result < Invoice , SignOrCreationError < ( ) > >
365366 where
366367 M :: Target : chain:: Watch < <K :: Target as KeysInterface >:: Signer > ,
@@ -377,14 +378,14 @@ pub fn create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_
377378 InvoiceDescription :: Direct (
378379 & Description :: new ( description) . map_err ( SignOrCreationError :: CreationError ) ?,
379380 ) ,
380- duration_since_epoch, invoice_expiry_delta_secs, payment_hash, payment_secret
381+ duration_since_epoch, invoice_expiry_delta_secs, payment_hash, payment_secret, contract_id , amt_rgb
381382 )
382383}
383384
384385fn _create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash < M : Deref , T : Deref , K : Deref , F : Deref , L : Deref > (
385386 channelmanager : & ChannelManager < M , T , K , F , L > , keys_manager : K , logger : L ,
386387 network : Currency , amt_msat : Option < u64 > , description : InvoiceDescription , duration_since_epoch : Duration ,
387- invoice_expiry_delta_secs : u32 , payment_hash : PaymentHash , payment_secret : PaymentSecret
388+ invoice_expiry_delta_secs : u32 , payment_hash : PaymentHash , payment_secret : PaymentSecret , contract_id : Option < ContractId > , amt_rgb : Option < u64 >
388389) -> Result < Invoice , SignOrCreationError < ( ) > >
389390 where
390391 M :: Target : chain:: Watch < <K :: Target as KeysInterface >:: Signer > ,
@@ -416,6 +417,12 @@ fn _create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_has
416417 if let Some ( amt) = amt_msat {
417418 invoice = invoice. amount_milli_satoshis ( amt) ;
418419 }
420+ if let Some ( cid) = contract_id {
421+ invoice = invoice. rgb_contract_id ( cid) ;
422+ }
423+ if let Some ( amt) = amt_rgb {
424+ invoice = invoice. rgb_amount ( amt) ;
425+ }
419426
420427 let route_hints = filter_channels ( channels, amt_msat, & logger) ;
421428 for hint in route_hints {
0 commit comments