@@ -25,7 +25,7 @@ use bitcoin::secp256k1;
25
25
use crate :: ln:: { PaymentPreimage , PaymentHash } ;
26
26
use crate :: ln:: features:: { ChannelTypeFeatures , InitFeatures } ;
27
27
use crate :: ln:: msgs;
28
- use crate :: ln:: msgs:: { DecodeError , OptionalField , DataLossProtect } ;
28
+ use crate :: ln:: msgs:: { DecodeError , OptionalField , DataLossProtect , MAX_VALUE_MSAT } ;
29
29
use crate :: ln:: script:: { self , ShutdownScript } ;
30
30
use crate :: ln:: channelmanager:: { self , CounterpartyForwardingInfo , PendingHTLCStatus , HTLCSource , HTLCFailReason , HTLCFailureMsg , PendingHTLCInfo , RAACommitmentOrder , BREAKDOWN_TIMEOUT , MIN_CLTV_EXPIRY_DELTA , MAX_LOCAL_BREAKDOWN_TIMEOUT } ;
31
31
use crate :: ln:: chan_utils:: { CounterpartyCommitmentSecrets , TxCreationKeys , HTLCOutputInCommitment , htlc_success_tx_weight, htlc_timeout_tx_weight, make_funding_redeemscript, ChannelPublicKeys , CommitmentTransaction , HolderCommitmentTransaction , ChannelTransactionParameters , CounterpartyChannelTransactionParameters , MAX_HTLCS , get_commitment_transaction_number_obscure_factor, ClosingTransaction } ;
@@ -776,9 +776,6 @@ pub const MAX_IN_FLIGHT_PERCENT_LEGACY: u8 = 10;
776
776
/// It's 2^24 - 1.
777
777
pub const MAX_FUNDING_SATOSHIS_NO_WUMBO : u64 = ( 1 << 24 ) - 1 ;
778
778
779
- /// Total bitcoin supply in satoshis.
780
- pub const TOTAL_BITCOIN_SUPPLY_SATOSHIS : u64 = 21_000_000 * 1_0000_0000 ;
781
-
782
779
/// The maximum network dust limit for standard script formats. This currently represents the
783
780
/// minimum output value for a P2SH output before Bitcoin Core 22 considers the entire
784
781
/// transaction non-standard and thus refuses to relay it.
@@ -917,7 +914,7 @@ impl<Signer: Sign> Channel<Signer> {
917
914
if !their_features. supports_wumbo ( ) && channel_value_satoshis > MAX_FUNDING_SATOSHIS_NO_WUMBO {
918
915
return Err ( APIError :: APIMisuseError { err : format ! ( "funding_value must not exceed {}, it was {}" , MAX_FUNDING_SATOSHIS_NO_WUMBO , channel_value_satoshis) } ) ;
919
916
}
920
- if channel_value_satoshis >= TOTAL_BITCOIN_SUPPLY_SATOSHIS {
917
+ if channel_value_satoshis >= MAX_VALUE_MSAT {
921
918
return Err ( APIError :: APIMisuseError { err : format ! ( "funding_value must be smaller than the total bitcoin supply, it was {}" , channel_value_satoshis) } ) ;
922
919
}
923
920
let channel_value_msat = channel_value_satoshis * 1000 ;
@@ -1163,7 +1160,7 @@ impl<Signer: Sign> Channel<Signer> {
1163
1160
if msg. funding_satoshis > config. channel_handshake_limits . max_funding_satoshis {
1164
1161
return Err ( ChannelError :: Close ( format ! ( "Per our config, funding must be at most {}. It was {}" , config. channel_handshake_limits. max_funding_satoshis, msg. funding_satoshis) ) ) ;
1165
1162
}
1166
- if msg. funding_satoshis >= TOTAL_BITCOIN_SUPPLY_SATOSHIS {
1163
+ if msg. funding_satoshis >= MAX_VALUE_MSAT {
1167
1164
return Err ( ChannelError :: Close ( format ! ( "Funding must be smaller than the total bitcoin supply. It was {}" , msg. funding_satoshis) ) ) ;
1168
1165
}
1169
1166
if msg. channel_reserve_satoshis > msg. funding_satoshis {
@@ -4332,7 +4329,7 @@ impl<Signer: Sign> Channel<Signer> {
4332
4329
if !self . pending_inbound_htlcs . is_empty ( ) || !self . pending_outbound_htlcs . is_empty ( ) {
4333
4330
return Err ( ChannelError :: Close ( "Remote end sent us a closing_signed while there were still pending HTLCs" . to_owned ( ) ) ) ;
4334
4331
}
4335
- if msg. fee_satoshis > TOTAL_BITCOIN_SUPPLY_SATOSHIS { // this is required to stop potential overflow in build_closing_transaction
4332
+ if msg. fee_satoshis > MAX_VALUE_MSAT { // this is required to stop potential overflow in build_closing_transaction
4336
4333
return Err ( ChannelError :: Close ( "Remote tried to send us a closing tx with > 21 million BTC fee" . to_owned ( ) ) ) ;
4337
4334
}
4338
4335
@@ -6710,7 +6707,7 @@ mod tests {
6710
6707
use crate :: ln:: PaymentHash ;
6711
6708
use crate :: ln:: channelmanager:: { self , HTLCSource , PaymentId } ;
6712
6709
use crate :: ln:: channel:: { Channel , InboundHTLCOutput , OutboundHTLCOutput , InboundHTLCState , OutboundHTLCState , HTLCCandidate , HTLCInitiator } ;
6713
- use crate :: ln:: channel:: { MAX_FUNDING_SATOSHIS_NO_WUMBO , TOTAL_BITCOIN_SUPPLY_SATOSHIS , MIN_THEIR_CHAN_RESERVE_SATOSHIS } ;
6710
+ use crate :: ln:: channel:: { MAX_FUNDING_SATOSHIS_NO_WUMBO , MIN_THEIR_CHAN_RESERVE_SATOSHIS } ;
6714
6711
use crate :: ln:: features:: ChannelTypeFeatures ;
6715
6712
use crate :: ln:: msgs:: { ChannelUpdate , DataLossProtect , DecodeError , OptionalField , UnsignedChannelUpdate , MAX_VALUE_MSAT } ;
6716
6713
use crate :: ln:: script:: ShutdownScript ;
@@ -6749,8 +6746,8 @@ mod tests {
6749
6746
6750
6747
#[ test]
6751
6748
fn test_max_funding_satoshis_no_wumbo ( ) {
6752
- assert_eq ! ( TOTAL_BITCOIN_SUPPLY_SATOSHIS , 21_000_000 * 100_000_000 ) ;
6753
- assert ! ( MAX_FUNDING_SATOSHIS_NO_WUMBO <= TOTAL_BITCOIN_SUPPLY_SATOSHIS ,
6749
+ assert_eq ! ( MAX_VALUE_MSAT , 21_000_000 * 100_000_000 ) ;
6750
+ assert ! ( MAX_FUNDING_SATOSHIS_NO_WUMBO <= MAX_VALUE_MSAT ,
6754
6751
"MAX_FUNDING_SATOSHIS_NO_WUMBO is greater than all satoshis in existence" ) ;
6755
6752
}
6756
6753
0 commit comments