@@ -34,11 +34,11 @@ use lightning::chain::channelmonitor;
34
34
use lightning:: chain:: channelmonitor:: { ChannelMonitor , ChannelMonitorUpdateErr , MonitorEvent } ;
35
35
use lightning:: chain:: transaction:: OutPoint ;
36
36
use lightning:: chain:: chaininterface:: { BroadcasterInterface , ConfirmationTarget , FeeEstimator } ;
37
- use lightning:: chain:: keysinterface:: { KeysInterface , InMemoryChannelKeys } ;
37
+ use lightning:: chain:: keysinterface:: { KeysInterface , InMemorySigner } ;
38
38
use lightning:: ln:: channelmanager:: { ChannelManager , PaymentHash , PaymentPreimage , PaymentSecret , PaymentSendFailure , ChannelManagerReadArgs } ;
39
39
use lightning:: ln:: features:: { ChannelFeatures , InitFeatures , NodeFeatures } ;
40
40
use lightning:: ln:: msgs:: { CommitmentUpdate , ChannelMessageHandler , DecodeError , ErrorAction , UpdateAddHTLC , Init } ;
41
- use lightning:: util:: enforcing_trait_impls:: { EnforcingChannelKeys , INITIAL_REVOKED_COMMITMENT_NUMBER } ;
41
+ use lightning:: util:: enforcing_trait_impls:: { EnforcingSigner , INITIAL_REVOKED_COMMITMENT_NUMBER } ;
42
42
use lightning:: util:: errors:: APIError ;
43
43
use lightning:: util:: events;
44
44
use lightning:: util:: logger:: Logger ;
@@ -87,7 +87,7 @@ impl Writer for VecWriter {
87
87
88
88
struct TestChainMonitor {
89
89
pub logger : Arc < dyn Logger > ,
90
- pub chain_monitor : Arc < chainmonitor:: ChainMonitor < EnforcingChannelKeys , Arc < dyn chain:: Filter > , Arc < TestBroadcaster > , Arc < FuzzEstimator > , Arc < dyn Logger > , Arc < TestPersister > > > ,
90
+ pub chain_monitor : Arc < chainmonitor:: ChainMonitor < EnforcingSigner , Arc < dyn chain:: Filter > , Arc < TestBroadcaster > , Arc < FuzzEstimator > , Arc < dyn Logger > , Arc < TestPersister > > > ,
91
91
pub update_ret : Mutex < Result < ( ) , channelmonitor:: ChannelMonitorUpdateErr > > ,
92
92
// If we reload a node with an old copy of ChannelMonitors, the ChannelManager deserialization
93
93
// logic will automatically force-close our channels for us (as we don't have an up-to-date
@@ -108,10 +108,8 @@ impl TestChainMonitor {
108
108
}
109
109
}
110
110
}
111
- impl chain:: Watch for TestChainMonitor {
112
- type Keys = EnforcingChannelKeys ;
113
-
114
- fn watch_channel ( & self , funding_txo : OutPoint , monitor : channelmonitor:: ChannelMonitor < EnforcingChannelKeys > ) -> Result < ( ) , channelmonitor:: ChannelMonitorUpdateErr > {
111
+ impl chain:: Watch < EnforcingSigner > for TestChainMonitor {
112
+ fn watch_channel ( & self , funding_txo : OutPoint , monitor : channelmonitor:: ChannelMonitor < EnforcingSigner > ) -> Result < ( ) , channelmonitor:: ChannelMonitorUpdateErr > {
115
113
let mut ser = VecWriter ( Vec :: new ( ) ) ;
116
114
monitor. write ( & mut ser) . unwrap ( ) ;
117
115
if let Some ( _) = self . latest_monitors . lock ( ) . unwrap ( ) . insert ( funding_txo, ( monitor. get_latest_update_id ( ) , ser. 0 ) ) {
@@ -128,7 +126,7 @@ impl chain::Watch for TestChainMonitor {
128
126
hash_map:: Entry :: Occupied ( entry) => entry,
129
127
hash_map:: Entry :: Vacant ( _) => panic ! ( "Didn't have monitor on update call" ) ,
130
128
} ;
131
- let mut deserialized_monitor = <( BlockHash , channelmonitor:: ChannelMonitor < EnforcingChannelKeys > ) >::
129
+ let mut deserialized_monitor = <( BlockHash , channelmonitor:: ChannelMonitor < EnforcingSigner > ) >::
132
130
read ( & mut Cursor :: new ( & map_entry. get ( ) . 1 ) , & OnlyReadsKeysInterface { } ) . unwrap ( ) . 1 ;
133
131
deserialized_monitor. update_monitor ( & update, & & TestBroadcaster { } , & & FuzzEstimator { } , & self . logger ) . unwrap ( ) ;
134
132
let mut ser = VecWriter ( Vec :: new ( ) ) ;
@@ -149,7 +147,7 @@ struct KeyProvider {
149
147
revoked_commitments : Mutex < HashMap < [ u8 ; 32 ] , Arc < Mutex < u64 > > > > ,
150
148
}
151
149
impl KeysInterface for KeyProvider {
152
- type ChanKeySigner = EnforcingChannelKeys ;
150
+ type Signer = EnforcingSigner ;
153
151
154
152
fn get_node_secret ( & self ) -> SecretKey {
155
153
SecretKey :: from_slice ( & [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , self . node_id ] ) . unwrap ( )
@@ -167,10 +165,10 @@ impl KeysInterface for KeyProvider {
167
165
PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 3 , self . node_id ] ) . unwrap ( ) )
168
166
}
169
167
170
- fn get_channel_keys ( & self , _inbound : bool , channel_value_satoshis : u64 ) -> EnforcingChannelKeys {
168
+ fn get_channel_signer ( & self , _inbound : bool , channel_value_satoshis : u64 ) -> EnforcingSigner {
171
169
let secp_ctx = Secp256k1 :: signing_only ( ) ;
172
170
let id = self . rand_bytes_id . fetch_add ( 1 , atomic:: Ordering :: Relaxed ) ;
173
- let keys = InMemoryChannelKeys :: new (
171
+ let keys = InMemorySigner :: new (
174
172
& secp_ctx,
175
173
SecretKey :: from_slice ( & [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 4 , self . node_id ] ) . unwrap ( ) ,
176
174
SecretKey :: from_slice ( & [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 5 , self . node_id ] ) . unwrap ( ) ,
@@ -182,23 +180,23 @@ impl KeysInterface for KeyProvider {
182
180
[ 0 ; 32 ] ,
183
181
) ;
184
182
let revoked_commitment = self . make_revoked_commitment_cell ( keys. commitment_seed ) ;
185
- EnforcingChannelKeys :: new_with_revoked ( keys, revoked_commitment, false )
183
+ EnforcingSigner :: new_with_revoked ( keys, revoked_commitment, false )
186
184
}
187
185
188
186
fn get_secure_random_bytes ( & self ) -> [ u8 ; 32 ] {
189
187
let id = self . rand_bytes_id . fetch_add ( 1 , atomic:: Ordering :: Relaxed ) ;
190
188
[ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , id, 11 , self . node_id ]
191
189
}
192
190
193
- fn read_chan_signer ( & self , buffer : & [ u8 ] ) -> Result < Self :: ChanKeySigner , DecodeError > {
191
+ fn read_chan_signer ( & self , buffer : & [ u8 ] ) -> Result < Self :: Signer , DecodeError > {
194
192
let mut reader = std:: io:: Cursor :: new ( buffer) ;
195
193
196
- let inner: InMemoryChannelKeys = Readable :: read ( & mut reader) ?;
194
+ let inner: InMemorySigner = Readable :: read ( & mut reader) ?;
197
195
let revoked_commitment = self . make_revoked_commitment_cell ( inner. commitment_seed ) ;
198
196
199
197
let last_commitment_number = Readable :: read ( & mut reader) ?;
200
198
201
- Ok ( EnforcingChannelKeys {
199
+ Ok ( EnforcingSigner {
202
200
inner,
203
201
last_commitment_number : Arc :: new ( Mutex :: new ( last_commitment_number) ) ,
204
202
revoked_commitment,
@@ -259,7 +257,7 @@ fn check_payment_err(send_err: PaymentSendFailure) {
259
257
}
260
258
}
261
259
262
- type ChanMan = ChannelManager < EnforcingChannelKeys , Arc < TestChainMonitor > , Arc < TestBroadcaster > , Arc < KeyProvider > , Arc < FuzzEstimator > , Arc < dyn Logger > > ;
260
+ type ChanMan = ChannelManager < EnforcingSigner , Arc < TestChainMonitor > , Arc < TestBroadcaster > , Arc < KeyProvider > , Arc < FuzzEstimator > , Arc < dyn Logger > > ;
263
261
264
262
#[ inline]
265
263
fn send_payment ( source : & ChanMan , dest : & ChanMan , dest_chan_id : u64 , amt : u64 , payment_id : & mut u8 ) -> bool {
@@ -339,7 +337,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
339
337
let mut monitors = HashMap :: new( ) ;
340
338
let mut old_monitors = $old_monitors. latest_monitors. lock( ) . unwrap( ) ;
341
339
for ( outpoint, ( update_id, monitor_ser) ) in old_monitors. drain( ) {
342
- monitors. insert( outpoint, <( BlockHash , ChannelMonitor <EnforcingChannelKeys >) >:: read( & mut Cursor :: new( & monitor_ser) , & OnlyReadsKeysInterface { } ) . expect( "Failed to read monitor" ) . 1 ) ;
340
+ monitors. insert( outpoint, <( BlockHash , ChannelMonitor <EnforcingSigner >) >:: read( & mut Cursor :: new( & monitor_ser) , & OnlyReadsKeysInterface { } ) . expect( "Failed to read monitor" ) . 1 ) ;
343
341
chain_monitor. latest_monitors. lock( ) . unwrap( ) . insert( outpoint, ( update_id, monitor_ser) ) ;
344
342
}
345
343
let mut monitor_refs = HashMap :: new( ) ;
0 commit comments