Skip to content

Commit 94bb0c9

Browse files
authored
Merge pull request #799 from TheBlueMatt/2021-02-chansigner-rename
Rename ChannelKeys -> Sign and generic it consistently
2 parents ee68ffa + 4b6f0a3 commit 94bb0c9

33 files changed

+748
-747
lines changed

background-processor/src/lib.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
use lightning::chain;
44
use lightning::chain::chaininterface::{BroadcasterInterface, FeeEstimator};
5-
use lightning::chain::keysinterface::{ChannelKeys, KeysInterface};
5+
use lightning::chain::keysinterface::{Sign, KeysInterface};
66
use lightning::ln::channelmanager::ChannelManager;
77
use lightning::util::logger::Logger;
8-
use lightning::util::ser::Writeable;
98
use std::sync::Arc;
109
use std::sync::atomic::{AtomicBool, Ordering};
1110
use std::thread;
@@ -53,14 +52,14 @@ impl BackgroundProcessor {
5352
/// [`thread_handle`]: struct.BackgroundProcessor.html#structfield.thread_handle
5453
/// [`ChannelManager::write`]: ../lightning/ln/channelmanager/struct.ChannelManager.html#method.write
5554
/// [`FilesystemPersister::persist_manager`]: ../lightning_persister/struct.FilesystemPersister.html#impl
56-
pub fn start<PM, ChanSigner, M, T, K, F, L>(persist_manager: PM, manager: Arc<ChannelManager<ChanSigner, Arc<M>, Arc<T>, Arc<K>, Arc<F>, Arc<L>>>, logger: Arc<L>) -> Self
57-
where ChanSigner: 'static + ChannelKeys + Writeable,
58-
M: 'static + chain::Watch<Keys=ChanSigner>,
55+
pub fn start<PM, Signer, M, T, K, F, L>(persist_manager: PM, manager: Arc<ChannelManager<Signer, Arc<M>, Arc<T>, Arc<K>, Arc<F>, Arc<L>>>, logger: Arc<L>) -> Self
56+
where Signer: 'static + Sign,
57+
M: 'static + chain::Watch<Signer>,
5958
T: 'static + BroadcasterInterface,
60-
K: 'static + KeysInterface<ChanKeySigner=ChanSigner>,
59+
K: 'static + KeysInterface<Signer=Signer>,
6160
F: 'static + FeeEstimator,
6261
L: 'static + Logger,
63-
PM: 'static + Send + Fn(&ChannelManager<ChanSigner, Arc<M>, Arc<T>, Arc<K>, Arc<F>, Arc<L>>) -> Result<(), std::io::Error>,
62+
PM: 'static + Send + Fn(&ChannelManager<Signer, Arc<M>, Arc<T>, Arc<K>, Arc<F>, Arc<L>>) -> Result<(), std::io::Error>,
6463
{
6564
let stop_thread = Arc::new(AtomicBool::new(false));
6665
let stop_thread_clone = stop_thread.clone();
@@ -104,7 +103,7 @@ mod tests {
104103
use lightning::chain;
105104
use lightning::chain::chaininterface::{BroadcasterInterface, FeeEstimator};
106105
use lightning::chain::chainmonitor;
107-
use lightning::chain::keysinterface::{ChannelKeys, InMemoryChannelKeys, KeysInterface, KeysManager};
106+
use lightning::chain::keysinterface::{Sign, InMemorySigner, KeysInterface, KeysManager};
108107
use lightning::chain::transaction::OutPoint;
109108
use lightning::get_event_msg;
110109
use lightning::ln::channelmanager::{ChannelManager, SimpleArcChannelManager};
@@ -122,7 +121,7 @@ mod tests {
122121
use std::time::Duration;
123122
use super::BackgroundProcessor;
124123

125-
type ChainMonitor = chainmonitor::ChainMonitor<InMemoryChannelKeys, Arc<test_utils::TestChainSource>, Arc<test_utils::TestBroadcaster>, Arc<test_utils::TestFeeEstimator>, Arc<test_utils::TestLogger>, Arc<FilesystemPersister>>;
124+
type ChainMonitor = chainmonitor::ChainMonitor<InMemorySigner, Arc<test_utils::TestChainSource>, Arc<test_utils::TestBroadcaster>, Arc<test_utils::TestFeeEstimator>, Arc<test_utils::TestLogger>, Arc<FilesystemPersister>>;
126125

127126
struct Node {
128127
node: SimpleArcChannelManager<ChainMonitor, test_utils::TestBroadcaster, test_utils::TestFeeEstimator, test_utils::TestLogger>,
@@ -203,7 +202,7 @@ mod tests {
203202

204203
// Initiate the background processors to watch each node.
205204
let data_dir = nodes[0].persister.get_data_dir();
206-
let callback = move |node: &ChannelManager<InMemoryChannelKeys, Arc<ChainMonitor>, Arc<test_utils::TestBroadcaster>, Arc<KeysManager>, Arc<test_utils::TestFeeEstimator>, Arc<test_utils::TestLogger>>| FilesystemPersister::persist_manager(data_dir.clone(), node);
205+
let callback = move |node: &ChannelManager<InMemorySigner, Arc<ChainMonitor>, Arc<test_utils::TestBroadcaster>, Arc<KeysManager>, Arc<test_utils::TestFeeEstimator>, Arc<test_utils::TestLogger>>| FilesystemPersister::persist_manager(data_dir.clone(), node);
207206
let bg_processor = BackgroundProcessor::start(callback, nodes[0].node.clone(), nodes[0].logger.clone());
208207

209208
// Go through the channel creation process until each node should have something persisted.
@@ -258,7 +257,7 @@ mod tests {
258257
// `CHAN_FRESHNESS_TIMER`.
259258
let nodes = create_nodes(1, "test_chan_freshness_called".to_string());
260259
let data_dir = nodes[0].persister.get_data_dir();
261-
let callback = move |node: &ChannelManager<InMemoryChannelKeys, Arc<ChainMonitor>, Arc<test_utils::TestBroadcaster>, Arc<KeysManager>, Arc<test_utils::TestFeeEstimator>, Arc<test_utils::TestLogger>>| FilesystemPersister::persist_manager(data_dir.clone(), node);
260+
let callback = move |node: &ChannelManager<InMemorySigner, Arc<ChainMonitor>, Arc<test_utils::TestBroadcaster>, Arc<KeysManager>, Arc<test_utils::TestFeeEstimator>, Arc<test_utils::TestLogger>>| FilesystemPersister::persist_manager(data_dir.clone(), node);
262261
let bg_processor = BackgroundProcessor::start(callback, nodes[0].node.clone(), nodes[0].logger.clone());
263262
loop {
264263
let log_entries = nodes[0].logger.lines.lock().unwrap();
@@ -274,11 +273,11 @@ mod tests {
274273
#[test]
275274
fn test_persist_error() {
276275
// Test that if we encounter an error during manager persistence, the thread panics.
277-
fn persist_manager<ChanSigner, M, T, K, F, L>(_data: &ChannelManager<ChanSigner, Arc<M>, Arc<T>, Arc<K>, Arc<F>, Arc<L>>) -> Result<(), std::io::Error>
278-
where ChanSigner: 'static + ChannelKeys + Writeable,
279-
M: 'static + chain::Watch<Keys=ChanSigner>,
276+
fn persist_manager<Signer, M, T, K, F, L>(_data: &ChannelManager<Signer, Arc<M>, Arc<T>, Arc<K>, Arc<F>, Arc<L>>) -> Result<(), std::io::Error>
277+
where Signer: 'static + Sign,
278+
M: 'static + chain::Watch<Signer>,
280279
T: 'static + BroadcasterInterface,
281-
K: 'static + KeysInterface<ChanKeySigner=ChanSigner>,
280+
K: 'static + KeysInterface<Signer=Signer>,
282281
F: 'static + FeeEstimator,
283282
L: 'static + Logger,
284283
{

fuzz/src/chanmon_consistency.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ use lightning::chain::channelmonitor;
3434
use lightning::chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdateErr, MonitorEvent};
3535
use lightning::chain::transaction::OutPoint;
3636
use lightning::chain::chaininterface::{BroadcasterInterface, ConfirmationTarget, FeeEstimator};
37-
use lightning::chain::keysinterface::{KeysInterface, InMemoryChannelKeys};
37+
use lightning::chain::keysinterface::{KeysInterface, InMemorySigner};
3838
use lightning::ln::channelmanager::{ChannelManager, PaymentHash, PaymentPreimage, PaymentSecret, PaymentSendFailure, ChannelManagerReadArgs};
3939
use lightning::ln::features::{ChannelFeatures, InitFeatures, NodeFeatures};
4040
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};
4242
use lightning::util::errors::APIError;
4343
use lightning::util::events;
4444
use lightning::util::logger::Logger;
@@ -87,7 +87,7 @@ impl Writer for VecWriter {
8787

8888
struct TestChainMonitor {
8989
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>>>,
9191
pub update_ret: Mutex<Result<(), channelmonitor::ChannelMonitorUpdateErr>>,
9292
// If we reload a node with an old copy of ChannelMonitors, the ChannelManager deserialization
9393
// logic will automatically force-close our channels for us (as we don't have an up-to-date
@@ -108,10 +108,8 @@ impl TestChainMonitor {
108108
}
109109
}
110110
}
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> {
115113
let mut ser = VecWriter(Vec::new());
116114
monitor.write(&mut ser).unwrap();
117115
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 {
128126
hash_map::Entry::Occupied(entry) => entry,
129127
hash_map::Entry::Vacant(_) => panic!("Didn't have monitor on update call"),
130128
};
131-
let mut deserialized_monitor = <(BlockHash, channelmonitor::ChannelMonitor<EnforcingChannelKeys>)>::
129+
let mut deserialized_monitor = <(BlockHash, channelmonitor::ChannelMonitor<EnforcingSigner>)>::
132130
read(&mut Cursor::new(&map_entry.get().1), &OnlyReadsKeysInterface {}).unwrap().1;
133131
deserialized_monitor.update_monitor(&update, &&TestBroadcaster{}, &&FuzzEstimator{}, &self.logger).unwrap();
134132
let mut ser = VecWriter(Vec::new());
@@ -149,7 +147,7 @@ struct KeyProvider {
149147
revoked_commitments: Mutex<HashMap<[u8;32], Arc<Mutex<u64>>>>,
150148
}
151149
impl KeysInterface for KeyProvider {
152-
type ChanKeySigner = EnforcingChannelKeys;
150+
type Signer = EnforcingSigner;
153151

154152
fn get_node_secret(&self) -> SecretKey {
155153
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 {
167165
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())
168166
}
169167

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 {
171169
let secp_ctx = Secp256k1::signing_only();
172170
let id = self.rand_bytes_id.fetch_add(1, atomic::Ordering::Relaxed);
173-
let keys = InMemoryChannelKeys::new(
171+
let keys = InMemorySigner::new(
174172
&secp_ctx,
175173
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(),
176174
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 {
182180
[0; 32],
183181
);
184182
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)
186184
}
187185

188186
fn get_secure_random_bytes(&self) -> [u8; 32] {
189187
let id = self.rand_bytes_id.fetch_add(1, atomic::Ordering::Relaxed);
190188
[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]
191189
}
192190

193-
fn read_chan_signer(&self, buffer: &[u8]) -> Result<Self::ChanKeySigner, DecodeError> {
191+
fn read_chan_signer(&self, buffer: &[u8]) -> Result<Self::Signer, DecodeError> {
194192
let mut reader = std::io::Cursor::new(buffer);
195193

196-
let inner: InMemoryChannelKeys = Readable::read(&mut reader)?;
194+
let inner: InMemorySigner = Readable::read(&mut reader)?;
197195
let revoked_commitment = self.make_revoked_commitment_cell(inner.commitment_seed);
198196

199197
let last_commitment_number = Readable::read(&mut reader)?;
200198

201-
Ok(EnforcingChannelKeys {
199+
Ok(EnforcingSigner {
202200
inner,
203201
last_commitment_number: Arc::new(Mutex::new(last_commitment_number)),
204202
revoked_commitment,
@@ -259,7 +257,7 @@ fn check_payment_err(send_err: PaymentSendFailure) {
259257
}
260258
}
261259

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>>;
263261

264262
#[inline]
265263
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) {
339337
let mut monitors = HashMap::new();
340338
let mut old_monitors = $old_monitors.latest_monitors.lock().unwrap();
341339
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);
343341
chain_monitor.latest_monitors.lock().unwrap().insert(outpoint, (update_id, monitor_ser));
344342
}
345343
let mut monitor_refs = HashMap::new();

fuzz/src/chanmon_deser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use bitcoin::hash_types::BlockHash;
55

66
use lightning::chain::channelmonitor;
7-
use lightning::util::enforcing_trait_impls::EnforcingChannelKeys;
7+
use lightning::util::enforcing_trait_impls::EnforcingSigner;
88
use lightning::util::ser::{ReadableArgs, Writer, Writeable};
99
use lightning::util::test_utils::OnlyReadsKeysInterface;
1010

@@ -25,10 +25,10 @@ impl Writer for VecWriter {
2525

2626
#[inline]
2727
pub fn do_test<Out: test_logger::Output>(data: &[u8], _out: Out) {
28-
if let Ok((latest_block_hash, monitor)) = <(BlockHash, channelmonitor::ChannelMonitor<EnforcingChannelKeys>)>::read(&mut Cursor::new(data), &OnlyReadsKeysInterface {}) {
28+
if let Ok((latest_block_hash, monitor)) = <(BlockHash, channelmonitor::ChannelMonitor<EnforcingSigner>)>::read(&mut Cursor::new(data), &OnlyReadsKeysInterface {}) {
2929
let mut w = VecWriter(Vec::new());
3030
monitor.write(&mut w).unwrap();
31-
let deserialized_copy = <(BlockHash, channelmonitor::ChannelMonitor<EnforcingChannelKeys>)>::read(&mut Cursor::new(&w.0), &OnlyReadsKeysInterface {}).unwrap();
31+
let deserialized_copy = <(BlockHash, channelmonitor::ChannelMonitor<EnforcingSigner>)>::read(&mut Cursor::new(&w.0), &OnlyReadsKeysInterface {}).unwrap();
3232
assert!(latest_block_hash == deserialized_copy.0);
3333
assert!(monitor == deserialized_copy.1);
3434
}

fuzz/src/full_stack.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ use lightning::chain;
3030
use lightning::chain::chaininterface::{BroadcasterInterface, ConfirmationTarget, FeeEstimator};
3131
use lightning::chain::chainmonitor;
3232
use lightning::chain::transaction::OutPoint;
33-
use lightning::chain::keysinterface::{InMemoryChannelKeys, KeysInterface};
33+
use lightning::chain::keysinterface::{InMemorySigner, KeysInterface};
3434
use lightning::ln::channelmanager::{ChannelManager, PaymentHash, PaymentPreimage, PaymentSecret};
3535
use lightning::ln::peer_handler::{MessageHandler,PeerManager,SocketDescriptor};
3636
use lightning::ln::msgs::DecodeError;
3737
use lightning::routing::router::get_route;
3838
use lightning::routing::network_graph::NetGraphMsgHandler;
3939
use lightning::util::config::UserConfig;
4040
use lightning::util::events::{EventsProvider,Event};
41-
use lightning::util::enforcing_trait_impls::EnforcingChannelKeys;
41+
use lightning::util::enforcing_trait_impls::EnforcingSigner;
4242
use lightning::util::logger::Logger;
4343
use lightning::util::ser::Readable;
4444

@@ -148,14 +148,14 @@ impl<'a> std::hash::Hash for Peer<'a> {
148148
}
149149

150150
type ChannelMan = ChannelManager<
151-
EnforcingChannelKeys,
152-
Arc<chainmonitor::ChainMonitor<EnforcingChannelKeys, Arc<dyn chain::Filter>, Arc<TestBroadcaster>, Arc<FuzzEstimator>, Arc<dyn Logger>, Arc<TestPersister>>>,
151+
EnforcingSigner,
152+
Arc<chainmonitor::ChainMonitor<EnforcingSigner, Arc<dyn chain::Filter>, Arc<TestBroadcaster>, Arc<FuzzEstimator>, Arc<dyn Logger>, Arc<TestPersister>>>,
153153
Arc<TestBroadcaster>, Arc<KeyProvider>, Arc<FuzzEstimator>, Arc<dyn Logger>>;
154154
type PeerMan<'a> = PeerManager<Peer<'a>, Arc<ChannelMan>, Arc<NetGraphMsgHandler<Arc<dyn chain::Access>, Arc<dyn Logger>>>, Arc<dyn Logger>>;
155155

156156
struct MoneyLossDetector<'a> {
157157
manager: Arc<ChannelMan>,
158-
monitor: Arc<chainmonitor::ChainMonitor<EnforcingChannelKeys, Arc<dyn chain::Filter>, Arc<TestBroadcaster>, Arc<FuzzEstimator>, Arc<dyn Logger>, Arc<TestPersister>>>,
158+
monitor: Arc<chainmonitor::ChainMonitor<EnforcingSigner, Arc<dyn chain::Filter>, Arc<TestBroadcaster>, Arc<FuzzEstimator>, Arc<dyn Logger>, Arc<TestPersister>>>,
159159
handler: PeerMan<'a>,
160160

161161
peers: &'a RefCell<[bool; 256]>,
@@ -169,7 +169,7 @@ struct MoneyLossDetector<'a> {
169169
impl<'a> MoneyLossDetector<'a> {
170170
pub fn new(peers: &'a RefCell<[bool; 256]>,
171171
manager: Arc<ChannelMan>,
172-
monitor: Arc<chainmonitor::ChainMonitor<EnforcingChannelKeys, Arc<dyn chain::Filter>, Arc<TestBroadcaster>, Arc<FuzzEstimator>, Arc<dyn Logger>, Arc<TestPersister>>>,
172+
monitor: Arc<chainmonitor::ChainMonitor<EnforcingSigner, Arc<dyn chain::Filter>, Arc<TestBroadcaster>, Arc<FuzzEstimator>, Arc<dyn Logger>, Arc<TestPersister>>>,
173173
handler: PeerMan<'a>) -> Self {
174174
MoneyLossDetector {
175175
manager,
@@ -248,7 +248,7 @@ struct KeyProvider {
248248
counter: AtomicU64,
249249
}
250250
impl KeysInterface for KeyProvider {
251-
type ChanKeySigner = EnforcingChannelKeys;
251+
type Signer = EnforcingSigner;
252252

253253
fn get_node_secret(&self) -> SecretKey {
254254
self.node_secret.clone()
@@ -266,11 +266,11 @@ impl KeysInterface for KeyProvider {
266266
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, 0, 0]).unwrap())
267267
}
268268

269-
fn get_channel_keys(&self, inbound: bool, channel_value_satoshis: u64) -> EnforcingChannelKeys {
269+
fn get_channel_signer(&self, inbound: bool, channel_value_satoshis: u64) -> EnforcingSigner {
270270
let ctr = self.counter.fetch_add(1, Ordering::Relaxed) as u8;
271271
let secp_ctx = Secp256k1::signing_only();
272-
EnforcingChannelKeys::new(if inbound {
273-
InMemoryChannelKeys::new(
272+
EnforcingSigner::new(if inbound {
273+
InMemorySigner::new(
274274
&secp_ctx,
275275
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, ctr]).unwrap(),
276276
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, 2, ctr]).unwrap(),
@@ -282,7 +282,7 @@ impl KeysInterface for KeyProvider {
282282
[0; 32]
283283
)
284284
} else {
285-
InMemoryChannelKeys::new(
285+
InMemorySigner::new(
286286
&secp_ctx,
287287
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, 7, ctr]).unwrap(),
288288
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, 8, ctr]).unwrap(),
@@ -302,8 +302,8 @@ impl KeysInterface for KeyProvider {
302302
(ctr >> 8*7) as u8, (ctr >> 8*6) as u8, (ctr >> 8*5) as u8, (ctr >> 8*4) as u8, (ctr >> 8*3) as u8, (ctr >> 8*2) as u8, (ctr >> 8*1) as u8, 14, (ctr >> 8*0) as u8]
303303
}
304304

305-
fn read_chan_signer(&self, data: &[u8]) -> Result<EnforcingChannelKeys, DecodeError> {
306-
EnforcingChannelKeys::read(&mut std::io::Cursor::new(data))
305+
fn read_chan_signer(&self, data: &[u8]) -> Result<EnforcingSigner, DecodeError> {
306+
EnforcingSigner::read(&mut std::io::Cursor::new(data))
307307
}
308308
}
309309

fuzz/src/utils/test_persister.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
use lightning::chain::channelmonitor;
22
use lightning::chain::transaction::OutPoint;
3-
use lightning::util::enforcing_trait_impls::EnforcingChannelKeys;
3+
use lightning::util::enforcing_trait_impls::EnforcingSigner;
44

55
pub struct TestPersister {}
6-
impl channelmonitor::Persist<EnforcingChannelKeys> for TestPersister {
7-
fn persist_new_channel(&self, _funding_txo: OutPoint, _data: &channelmonitor::ChannelMonitor<EnforcingChannelKeys>) -> Result<(), channelmonitor::ChannelMonitorUpdateErr> {
6+
impl channelmonitor::Persist<EnforcingSigner> for TestPersister {
7+
fn persist_new_channel(&self, _funding_txo: OutPoint, _data: &channelmonitor::ChannelMonitor<EnforcingSigner>) -> Result<(), channelmonitor::ChannelMonitorUpdateErr> {
88
Ok(())
99
}
1010

11-
fn update_persisted_channel(&self, _funding_txo: OutPoint, _update: &channelmonitor::ChannelMonitorUpdate, _data: &channelmonitor::ChannelMonitor<EnforcingChannelKeys>) -> Result<(), channelmonitor::ChannelMonitorUpdateErr> {
11+
fn update_persisted_channel(&self, _funding_txo: OutPoint, _update: &channelmonitor::ChannelMonitorUpdate, _data: &channelmonitor::ChannelMonitor<EnforcingSigner>) -> Result<(), channelmonitor::ChannelMonitorUpdateErr> {
1212
Ok(())
1313
}
1414
}

0 commit comments

Comments
 (0)