@@ -15,7 +15,7 @@ use secp256k1::{Secp256k1,Signature};
15
15
use secp256k1;
16
16
17
17
use ln:: msgs;
18
- use ln:: msgs:: DecodeError ;
18
+ use ln:: msgs:: { DecodeError , OptionalField } ;
19
19
use ln:: channelmonitor:: ChannelMonitor ;
20
20
use ln:: channelmanager:: { PendingHTLCStatus , HTLCSource , HTLCFailReason , HTLCFailureMsg , PendingForwardHTLCInfo , RAACommitmentOrder , PaymentPreimage , PaymentHash } ;
21
21
use ln:: chan_utils:: { TxCreationKeys , HTLCOutputInCommitment , HTLC_SUCCESS_TX_WEIGHT , HTLC_TIMEOUT_TX_WEIGHT } ;
@@ -2943,7 +2943,7 @@ impl Channel {
2943
2943
htlc_basepoint : PublicKey :: from_secret_key ( & self . secp_ctx , & self . local_keys . htlc_base_key ) ,
2944
2944
first_per_commitment_point : PublicKey :: from_secret_key ( & self . secp_ctx , & local_commitment_secret) ,
2945
2945
channel_flags : if self . config . announced_channel { 1 } else { 0 } ,
2946
- shutdown_scriptpubkey : None ,
2946
+ shutdown_scriptpubkey : OptionalField :: Absent
2947
2947
}
2948
2948
}
2949
2949
@@ -2975,7 +2975,7 @@ impl Channel {
2975
2975
delayed_payment_basepoint : PublicKey :: from_secret_key ( & self . secp_ctx , & self . local_keys . delayed_payment_base_key ) ,
2976
2976
htlc_basepoint : PublicKey :: from_secret_key ( & self . secp_ctx , & self . local_keys . htlc_base_key ) ,
2977
2977
first_per_commitment_point : PublicKey :: from_secret_key ( & self . secp_ctx , & local_commitment_secret) ,
2978
- shutdown_scriptpubkey : None ,
2978
+ shutdown_scriptpubkey : OptionalField :: Absent
2979
2979
}
2980
2980
}
2981
2981
@@ -3103,7 +3103,7 @@ impl Channel {
3103
3103
// dropped this channel on disconnect as it hasn't yet reached FundingSent so we can't
3104
3104
// overflow here.
3105
3105
next_remote_commitment_number : INITIAL_COMMITMENT_NUMBER - self . cur_remote_commitment_transaction_number - 1 ,
3106
- data_loss_protect : None ,
3106
+ data_loss_protect : OptionalField :: Absent ,
3107
3107
}
3108
3108
}
3109
3109
@@ -3688,14 +3688,6 @@ impl<R : ::std::io::Read> ReadableArgs<R, Arc<Logger>> for Channel {
3688
3688
} ) ;
3689
3689
}
3690
3690
3691
- macro_rules! read_option { ( ) => {
3692
- match <u8 as Readable <R >>:: read( reader) ? {
3693
- 0 => None ,
3694
- 1 => Some ( Readable :: read( reader) ?) ,
3695
- _ => return Err ( DecodeError :: InvalidValue ) ,
3696
- }
3697
- } }
3698
-
3699
3691
let pending_outbound_htlc_count: u64 = Readable :: read ( reader) ?;
3700
3692
let mut pending_outbound_htlcs = Vec :: with_capacity ( cmp:: min ( pending_outbound_htlc_count as usize , OUR_MAX_HTLCS as usize ) ) ;
3701
3693
for _ in 0 ..pending_outbound_htlc_count {
@@ -3705,7 +3697,7 @@ impl<R : ::std::io::Read> ReadableArgs<R, Arc<Logger>> for Channel {
3705
3697
cltv_expiry : Readable :: read ( reader) ?,
3706
3698
payment_hash : Readable :: read ( reader) ?,
3707
3699
source : Readable :: read ( reader) ?,
3708
- fail_reason : read_option ! ( ) ,
3700
+ fail_reason : Readable :: read ( reader ) ? ,
3709
3701
state : match <u8 as Readable < R > >:: read ( reader) ? {
3710
3702
0 => OutboundHTLCState :: LocalAnnounced ( Box :: new ( Readable :: read ( reader) ?) ) ,
3711
3703
1 => OutboundHTLCState :: Committed ,
@@ -3763,8 +3755,8 @@ impl<R : ::std::io::Read> ReadableArgs<R, Arc<Logger>> for Channel {
3763
3755
monitor_pending_failures. push ( ( Readable :: read ( reader) ?, Readable :: read ( reader) ?, Readable :: read ( reader) ?) ) ;
3764
3756
}
3765
3757
3766
- let pending_update_fee = read_option ! ( ) ;
3767
- let holding_cell_update_fee = read_option ! ( ) ;
3758
+ let pending_update_fee = Readable :: read ( reader ) ? ;
3759
+ let holding_cell_update_fee = Readable :: read ( reader ) ? ;
3768
3760
3769
3761
let next_local_htlc_id = Readable :: read ( reader) ?;
3770
3762
let next_remote_htlc_id = Readable :: read ( reader) ?;
@@ -3786,8 +3778,8 @@ impl<R : ::std::io::Read> ReadableArgs<R, Arc<Logger>> for Channel {
3786
3778
_ => return Err ( DecodeError :: InvalidValue ) ,
3787
3779
} ;
3788
3780
3789
- let funding_tx_confirmed_in = read_option ! ( ) ;
3790
- let short_channel_id = read_option ! ( ) ;
3781
+ let funding_tx_confirmed_in = Readable :: read ( reader ) ? ;
3782
+ let short_channel_id = Readable :: read ( reader ) ? ;
3791
3783
3792
3784
let last_block_connected = Readable :: read ( reader) ?;
3793
3785
let funding_tx_confirmations = Readable :: read ( reader) ?;
@@ -3802,17 +3794,17 @@ impl<R : ::std::io::Read> ReadableArgs<R, Arc<Logger>> for Channel {
3802
3794
let their_max_accepted_htlcs = Readable :: read ( reader) ?;
3803
3795
let minimum_depth = Readable :: read ( reader) ?;
3804
3796
3805
- let their_funding_pubkey = read_option ! ( ) ;
3806
- let their_revocation_basepoint = read_option ! ( ) ;
3807
- let their_payment_basepoint = read_option ! ( ) ;
3808
- let their_delayed_payment_basepoint = read_option ! ( ) ;
3809
- let their_htlc_basepoint = read_option ! ( ) ;
3810
- let their_cur_commitment_point = read_option ! ( ) ;
3797
+ let their_funding_pubkey = Readable :: read ( reader ) ? ;
3798
+ let their_revocation_basepoint = Readable :: read ( reader ) ? ;
3799
+ let their_payment_basepoint = Readable :: read ( reader ) ? ;
3800
+ let their_delayed_payment_basepoint = Readable :: read ( reader ) ? ;
3801
+ let their_htlc_basepoint = Readable :: read ( reader ) ? ;
3802
+ let their_cur_commitment_point = Readable :: read ( reader ) ? ;
3811
3803
3812
- let their_prev_commitment_point = read_option ! ( ) ;
3804
+ let their_prev_commitment_point = Readable :: read ( reader ) ? ;
3813
3805
let their_node_id = Readable :: read ( reader) ?;
3814
3806
3815
- let their_shutdown_scriptpubkey = read_option ! ( ) ;
3807
+ let their_shutdown_scriptpubkey = Readable :: read ( reader ) ? ;
3816
3808
let ( monitor_last_block, channel_monitor) = ReadableArgs :: read ( reader, logger. clone ( ) ) ?;
3817
3809
// We drop the ChannelMonitor's last block connected hash cause we don't actually bother
3818
3810
// doing full block connection operations on the internal CHannelMonitor copies
0 commit comments