You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add configuration support for 'their_channel_reserve_satoshis' while channel open/accept [lightningdevkit#1498]
`their_channel_reserve_satoshis` is the minimum amount that the other node is to keep as a direct payment.
This ensures that if our counterparty broadcasts a revoked state, we can punish them by
claiming at least this value on chain.
if holder_selected_contest_delay < BREAKDOWN_TIMEOUT{
913
924
returnErr(APIError::APIMisuseError{err:format!("Configured with an unreasonable our_to_self_delay ({}) putting user funds at risks", holder_selected_contest_delay)});
914
925
}
915
-
let holder_selected_channel_reserve_satoshis = Channel::<Signer>::get_holder_selected_channel_reserve_satoshis(channel_value_satoshis);
926
+
let holder_selected_channel_reserve_satoshis = Channel::<Signer>::get_holder_selected_channel_reserve_satoshis(channel_value_satoshis, config);
916
927
if holder_selected_channel_reserve_satoshis < MIN_CHAN_DUST_LIMIT_SATOSHIS{
let holder_selected_channel_reserve_satoshis = Channel::<Signer>::get_holder_selected_channel_reserve_satoshis(msg.funding_satoshis);
1218
+
let holder_selected_channel_reserve_satoshis = Channel::<Signer>::get_holder_selected_channel_reserve_satoshis(msg.funding_satoshis, config);
1208
1219
if holder_selected_channel_reserve_satoshis < MIN_CHAN_DUST_LIMIT_SATOSHIS{
1209
1220
returnErr(ChannelError::Close(format!("Suitable channel reserve not found. remote_channel_reserve was ({}). dust_limit_satoshis is ({}).", holder_selected_channel_reserve_satoshis,MIN_CHAN_DUST_LIMIT_SATOSHIS)));
1210
1221
}
1211
1222
if holder_selected_channel_reserve_satoshis *1000 >= full_channel_value_msat {
1212
-
returnErr(ChannelError::Close(format!("Suitable channel reserve not found. remote_channel_reserve was ({}). Channel value is ({} - {}).", holder_selected_channel_reserve_satoshis, full_channel_value_msat, msg.push_msat)));
1223
+
returnErr(ChannelError::Close(format!("Suitable channel reserve not found. remote_channel_reserve was ({}). Channel value is ({} - {}).", holder_selected_channel_reserve_satoshis*1000, full_channel_value_msat, msg.push_msat)));
1213
1224
}
1214
1225
if msg.channel_reserve_satoshis < MIN_CHAN_DUST_LIMIT_SATOSHIS{
1215
1226
log_debug!(logger,"channel_reserve_satoshis ({}) is smaller than our dust limit ({}). We can broadcast stale states without any risk, implying this channel is very insecure for our counterparty.",
@@ -6106,7 +6117,7 @@ impl<Signer: Sign> Writeable for Channel<Signer> {
6106
6117
// a different percentage of the channel value then 10%, which older versions of LDK used
6107
6118
// to set it to before the percentage was made configurable.
let chan = Channel::<EnforcingSigner>::new_outbound(&&fee_est,&&keys_provider, outbound_node_id,&InitFeatures::known(), channel_value_satoshis,100000,42,&outbound_node_config,0,42).unwrap();
7012
+
7013
+
let expected_outbound_selected_chan_reserve = cmp::max(MIN_THEIR_CHAN_RESERVE_SATOSHIS,(chan.channel_value_satoshisasf64* outbound_selected_channel_reserve_perc)asu64);
if outbound_selected_channel_reserve_perc + inbound_selected_channel_reserve_perc < 1.0{
7021
+
let chan_inbound_node = Channel::<EnforcingSigner>::new_from_req(&&fee_est,&&keys_provider, inbound_node_id,&InitFeatures::known(),&chan_open_channel_msg,7,&inbound_node_config,0,&&logger,42).unwrap();
7022
+
7023
+
let expected_inbound_selected_chan_reserve = cmp::max(MIN_THEIR_CHAN_RESERVE_SATOSHIS,(chan.channel_value_satoshisasf64* inbound_selected_channel_reserve_perc)asu64);
let result = Channel::<EnforcingSigner>::new_from_req(&&fee_est,&&keys_provider, inbound_node_id,&InitFeatures::known(),&chan_open_channel_msg,7,&inbound_node_config,0,&&logger,42);
7030
+
assert_eq!(true, result.is_err());
7031
+
}
7032
+
}
7033
+
6965
7034
#[test]
6966
7035
fnchannel_update(){
6967
7036
let feeest = LowerBoundedFeeEstimator::new(&TestFeeEstimator{fee_est:15000});
0 commit comments