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
... for ChannelError and APIMisuseError
Before this commit, When rl returns error, we don't know
The actual parameter which caused the error.
By returning parameterised `String` instead of predefined `&'static str`,
We can give a caller improved error message.
Copy file name to clipboardExpand all lines: lightning/src/ln/channel.rs
+15-23Lines changed: 15 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,7 @@ use ln::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, ChannelMonitorUpd
21
21
use ln::channelmanager::{PendingHTLCStatus,HTLCSource,HTLCFailReason,HTLCFailureMsg,PendingHTLCInfo,RAACommitmentOrder,PaymentPreimage,PaymentHash,BREAKDOWN_TIMEOUT,MAX_LOCAL_BREAKDOWN_TIMEOUT};
22
22
use ln::chan_utils::{CounterpartyCommitmentSecrets,LocalCommitmentTransaction,TxCreationKeys,HTLCOutputInCommitment,HTLC_SUCCESS_TX_WEIGHT,HTLC_TIMEOUT_TX_WEIGHT, make_funding_redeemscript,ChannelPublicKeys};
23
23
use ln::chan_utils;
24
+
use ln::checker::{predicates, check_or_close, checker_or_api_misuse, check_or_ignore};
24
25
use chain::chaininterface::{FeeEstimator,ConfirmationTarget};
25
26
use chain::transaction::OutPoint;
26
27
use chain::keysinterface::{ChannelKeys,KeysInterface};
let chan_keys = keys_provider.get_channel_keys(false, channel_value_satoshis);
461
463
462
-
if channel_value_satoshis >= MAX_FUNDING_SATOSHIS{
463
-
returnErr(APIError::APIMisuseError{err:"funding value > 2^24"});
464
-
}
465
-
466
-
if push_msat > channel_value_satoshis *1000{
467
-
returnErr(APIError::APIMisuseError{err:"push value > channel value"});
468
-
}
469
-
if config.own_channel_config.our_to_self_delay < BREAKDOWN_TIMEOUT{
470
-
returnErr(APIError::APIMisuseError{err:"Configured with an unreasonable our_to_self_delay putting user funds at risks"});
471
-
}
472
-
464
+
check_or_api_misuse(channel_value_satoshis,MAX_FUNDING_SATOSHIS, predicates::lt,"Funding value must be smaller than {expected}. it was {actual}")?;
465
+
check_or_api_misuse(push_msat, channel_value_satoshis *1000, predicates::ge,"push value must be greater than or equal to {expected}. it was {actual}")?;
466
+
check_or_api_misuse(config.own_channel_config.our_to_self_delay,BREAKDOWN_TIMEOUT, predicates::ge,"our configs, our_to_self_delay must be greater than or equal to {expected}. it was {actual}")?;
473
467
474
468
let background_feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Background);
0 commit comments