@@ -17,6 +17,7 @@ use lightning::ln::inbound_payment::{create, create_from_hash, ExpandedKey};
17
17
use lightning:: routing:: gossip:: RoutingFees ;
18
18
use lightning:: routing:: router:: { InFlightHtlcs , Route , RouteHint , RouteHintHop } ;
19
19
use lightning:: util:: logger:: Logger ;
20
+ use rgb:: ContractId ;
20
21
use secp256k1:: PublicKey ;
21
22
use core:: ops:: Deref ;
22
23
use core:: time:: Duration ;
@@ -234,7 +235,7 @@ where
234
235
/// in excess of the current time.
235
236
pub fn create_invoice_from_channelmanager < M : Deref , T : Deref , K : Deref , F : Deref , L : Deref > (
236
237
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 >
238
239
) -> Result < Invoice , SignOrCreationError < ( ) > >
239
240
where
240
241
M :: Target : chain:: Watch < <K :: Target as KeysInterface >:: Signer > ,
@@ -248,7 +249,7 @@ where
248
249
. expect ( "for the foreseeable future this shouldn't happen" ) ;
249
250
create_invoice_from_channelmanager_and_duration_since_epoch (
250
251
channelmanager, keys_manager, logger, network, amt_msat, description, duration,
251
- invoice_expiry_delta_secs
252
+ invoice_expiry_delta_secs, contract_id , amt_rgb
252
253
)
253
254
}
254
255
@@ -265,7 +266,7 @@ where
265
266
pub fn create_invoice_from_channelmanager_with_description_hash < M : Deref , T : Deref , K : Deref , F : Deref , L : Deref > (
266
267
channelmanager : & ChannelManager < M , T , K , F , L > , keys_manager : K , logger : L ,
267
268
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 >
269
270
) -> Result < Invoice , SignOrCreationError < ( ) > >
270
271
where
271
272
M :: Target : chain:: Watch < <K :: Target as KeysInterface >:: Signer > ,
@@ -282,7 +283,7 @@ where
282
283
283
284
create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch (
284
285
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
286
287
)
287
288
}
288
289
@@ -292,7 +293,7 @@ where
292
293
pub fn create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch < M : Deref , T : Deref , K : Deref , F : Deref , L : Deref > (
293
294
channelmanager : & ChannelManager < M , T , K , F , L > , keys_manager : K , logger : L ,
294
295
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 >
296
297
) -> Result < Invoice , SignOrCreationError < ( ) > >
297
298
where
298
299
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
304
305
_create_invoice_from_channelmanager_and_duration_since_epoch (
305
306
channelmanager, keys_manager, logger, network, amt_msat,
306
307
InvoiceDescription :: Hash ( & description_hash) ,
307
- duration_since_epoch, invoice_expiry_delta_secs
308
+ duration_since_epoch, invoice_expiry_delta_secs, contract_id , amt_rgb
308
309
)
309
310
}
310
311
@@ -314,7 +315,7 @@ pub fn create_invoice_from_channelmanager_with_description_hash_and_duration_sin
314
315
pub fn create_invoice_from_channelmanager_and_duration_since_epoch < M : Deref , T : Deref , K : Deref , F : Deref , L : Deref > (
315
316
channelmanager : & ChannelManager < M , T , K , F , L > , keys_manager : K , logger : L ,
316
317
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 >
318
319
) -> Result < Invoice , SignOrCreationError < ( ) > >
319
320
where
320
321
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:
328
329
InvoiceDescription :: Direct (
329
330
& Description :: new ( description) . map_err ( SignOrCreationError :: CreationError ) ?,
330
331
) ,
331
- duration_since_epoch, invoice_expiry_delta_secs
332
+ duration_since_epoch, invoice_expiry_delta_secs, contract_id , amt_rgb
332
333
)
333
334
}
334
335
335
336
fn _create_invoice_from_channelmanager_and_duration_since_epoch < M : Deref , T : Deref , K : Deref , F : Deref , L : Deref > (
336
337
channelmanager : & ChannelManager < M , T , K , F , L > , keys_manager : K , logger : L ,
337
338
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 >
339
340
) -> Result < Invoice , SignOrCreationError < ( ) > >
340
341
where
341
342
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
350
351
. create_inbound_payment ( amt_msat, invoice_expiry_delta_secs)
351
352
. map_err ( |( ) | SignOrCreationError :: CreationError ( CreationError :: InvalidAmount ) ) ?;
352
353
_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 )
354
355
}
355
356
356
357
/// 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
360
361
pub fn create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash < M : Deref , T : Deref , K : Deref , F : Deref , L : Deref > (
361
362
channelmanager : & ChannelManager < M , T , K , F , L > , keys_manager : K , logger : L ,
362
363
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 >
364
365
) -> Result < Invoice , SignOrCreationError < ( ) > >
365
366
where
366
367
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_
377
378
InvoiceDescription :: Direct (
378
379
& Description :: new ( description) . map_err ( SignOrCreationError :: CreationError ) ?,
379
380
) ,
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
381
382
)
382
383
}
383
384
384
385
fn _create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash < M : Deref , T : Deref , K : Deref , F : Deref , L : Deref > (
385
386
channelmanager : & ChannelManager < M , T , K , F , L > , keys_manager : K , logger : L ,
386
387
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 >
388
389
) -> Result < Invoice , SignOrCreationError < ( ) > >
389
390
where
390
391
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
416
417
if let Some ( amt) = amt_msat {
417
418
invoice = invoice. amount_milli_satoshis ( amt) ;
418
419
}
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
+ }
419
426
420
427
let route_hints = filter_channels ( channels, amt_msat, & logger) ;
421
428
for hint in route_hints {
0 commit comments