@@ -101,7 +101,7 @@ use crate::{
101101 core_types:: {
102102 HTLCStatus , SwapStatus , UnlockRequest as CoreUnlockRequest ,
103103 DEFAULT_FINAL_CLTV_EXPIRY_DELTA , DUST_LIMIT_MSAT , FEE_RATE , HTLC_MIN_MSAT ,
104- MAX_SWAP_FEE_MSAT , MIN_CHANNEL_CONFIRMATIONS , UTXO_SIZE_SAT ,
104+ MAX_SWAP_FEE_MSAT , MIN_CHANNEL_CONFIRMATIONS , UTXO_SIZE_SAT , VIRTUAL_HTLC_MIN_MSAT ,
105105 } ,
106106 rgb:: { check_rgb_proxy_endpoint, get_rgb_channel_info_optional} ,
107107} ;
@@ -121,8 +121,6 @@ const OPENCHANNEL_MAX_SAT: u64 = 16777215;
121121const OPENCHANNEL_MIN_RGB_AMT : u64 = 1 ;
122122const VIRTUAL_OPEN_MODE_TRUSTED_NO_BROADCAST : & str = "trusted_no_broadcast" ;
123123
124- const INVOICE_MIN_MSAT : u64 = HTLC_MIN_MSAT ;
125-
126124#[ derive( Deserialize , Serialize ) ]
127125pub ( crate ) struct AddressResponse {
128126 pub ( crate ) address : String ,
@@ -2853,9 +2851,10 @@ pub(crate) async fn keysend(
28532851 } ;
28542852
28552853 let amt_msat = payload. amt_msat ;
2856- if amt_msat < HTLC_MIN_MSAT {
2854+ let htlc_min_msat = unlocked_state. htlc_min_msat_for_peer ( dest_pubkey) ;
2855+ if amt_msat < htlc_min_msat {
28572856 return Err ( APIError :: InvalidAmount ( format ! (
2858- "amt_msat cannot be less than {HTLC_MIN_MSAT }"
2857+ "amt_msat cannot be less than {htlc_min_msat }"
28592858 ) ) ) ;
28602859 }
28612860
@@ -3472,10 +3471,15 @@ pub(crate) async fn ln_invoice(
34723471 None
34733472 } ;
34743473
3475- if contract_id. is_some ( ) && payload. amt_msat . unwrap_or ( 0 ) < INVOICE_MIN_MSAT {
3476- return Err ( APIError :: InvalidAmount ( format ! (
3477- "amt_msat cannot be less than {INVOICE_MIN_MSAT} when transferring an RGB asset"
3478- ) ) ) ;
3474+ if let Some ( contract_id) = & contract_id {
3475+ // Only lower the floor when the asset is held in a virtual channel; a regular channel
3476+ // carrying this asset keeps the standard floor.
3477+ let invoice_min_msat = unlocked_state. htlc_min_msat_for_asset ( contract_id) ;
3478+ if payload. amt_msat . unwrap_or ( 0 ) < invoice_min_msat {
3479+ return Err ( APIError :: InvalidAmount ( format ! (
3480+ "amt_msat cannot be less than {invoice_min_msat} when transferring an RGB asset"
3481+ ) ) ) ;
3482+ }
34793483 }
34803484
34813485 let created_at = get_current_timestamp ( ) ;
@@ -4156,7 +4160,11 @@ pub(crate) async fn open_channel(
41564160 } else {
41574161 payload. public
41584162 } ,
4159- our_htlc_minimum_msat : HTLC_MIN_MSAT ,
4163+ our_htlc_minimum_msat : if is_virtual_open {
4164+ VIRTUAL_HTLC_MIN_MSAT
4165+ } else {
4166+ HTLC_MIN_MSAT
4167+ } ,
41604168 minimum_depth : if is_virtual_open {
41614169 0
41624170 } else {
@@ -4297,6 +4305,7 @@ pub(crate) async fn open_channel(
42974305 Some ( config) ,
42984306 consignment_endpoint,
42994307 payload. push_asset_amount ,
4308+ is_virtual_open,
43004309 )
43014310 . map_err ( |e| {
43024311 if let Some ( temp_id_str) = rgb_metadata_temp_id_str. as_deref ( ) {
@@ -4693,19 +4702,23 @@ pub(crate) async fn send_payment(
46934702 invoice. amount_milli_satoshis ( ) . unwrap_or ( 0 )
46944703 } ;
46954704
4705+ // A trusted never-broadcast (virtual) channel to the payee allows a sub-dust asset
4706+ // HTLC; otherwise the standard floor applies.
4707+ let send_min_msat =
4708+ unlocked_state. htlc_min_msat_for_peer ( invoice. recover_payee_pub_key ( ) ) ;
46964709 let rgb_payment = match ( invoice. rgb_contract_id ( ) , invoice. rgb_amount ( ) ) {
46974710 ( Some ( rgb_contract_id) , Some ( rgb_amount) ) => {
4698- if amt_msat < INVOICE_MIN_MSAT {
4711+ if amt_msat < send_min_msat {
46994712 return Err ( APIError :: InvalidAmount ( format ! (
4700- "amt_msat in invoice sending an RGB asset cannot be less than {INVOICE_MIN_MSAT }"
4713+ "amt_msat in invoice sending an RGB asset cannot be less than {send_min_msat }"
47014714 ) ) ) ;
47024715 }
47034716 Some ( ( rgb_contract_id, rgb_amount) )
47044717 } ,
47054718 ( Some ( rgb_contract_id) , None ) => {
4706- if amt_msat < INVOICE_MIN_MSAT {
4719+ if amt_msat < send_min_msat {
47074720 return Err ( APIError :: InvalidAmount ( format ! (
4708- "amt_msat in invoice sending an RGB asset cannot be less than {INVOICE_MIN_MSAT }"
4721+ "amt_msat in invoice sending an RGB asset cannot be less than {send_min_msat }"
47094722 ) ) ) ;
47104723 }
47114724 if let Some ( asset_id) = payload. asset_id . as_ref ( ) {
0 commit comments