Skip to content

Commit 6cd3b2b

Browse files
committed
Universally Require Writeable for ChannelKeys
It doesn't make sense to ever build a lightning node which doesn't ever write ChannelMonitors to disk, so having a ChannelKeys object which doesn't implement Writeable is nonsense. Here we require Writeable for all ChannelKeys objects, simplifying code generation for C bindings somewhat.
1 parent 72e9dd5 commit 6cd3b2b

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

lightning-persister/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ trait DiskWriteable {
4343
fn write(&self, writer: &mut fs::File) -> Result<(), Error>;
4444
}
4545

46-
impl<ChanSigner: ChannelKeys + Writeable> DiskWriteable for ChannelMonitor<ChanSigner> {
46+
impl<ChanSigner: ChannelKeys> DiskWriteable for ChannelMonitor<ChanSigner> {
4747
fn write(&self, writer: &mut fs::File) -> Result<(), Error> {
4848
self.serialize_for_disk(writer)
4949
}
@@ -94,7 +94,7 @@ impl FilesystemPersister {
9494
}
9595

9696
#[cfg(test)]
97-
fn load_channel_data<ChanSigner: ChannelKeys + Readable + Writeable>(&self) ->
97+
fn load_channel_data<ChanSigner: ChannelKeys + Readable>(&self) ->
9898
Result<HashMap<OutPoint, ChannelMonitor<ChanSigner>>, ChannelMonitorUpdateErr> {
9999
if let Err(_) = fs::create_dir_all(&self.path_to_channel_data) {
100100
return Err(ChannelMonitorUpdateErr::PermanentFailure);
@@ -128,7 +128,7 @@ impl FilesystemPersister {
128128
}
129129
}
130130

131-
impl<ChanSigner: ChannelKeys + Readable + Writeable + Send + Sync> channelmonitor::Persist<ChanSigner> for FilesystemPersister {
131+
impl<ChanSigner: ChannelKeys + Readable + Send + Sync> channelmonitor::Persist<ChanSigner> for FilesystemPersister {
132132
fn persist_new_channel(&self, funding_txo: OutPoint, monitor: &ChannelMonitor<ChanSigner>) -> Result<(), ChannelMonitorUpdateErr> {
133133
self.write_channel_data(funding_txo, monitor)
134134
.map_err(|_| ChannelMonitorUpdateErr::PermanentFailure)

lightning/src/chain/channelmonitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ impl<ChanSigner: ChannelKeys> PartialEq for ChannelMonitor<ChanSigner> {
755755
}
756756
}
757757

758-
impl<ChanSigner: ChannelKeys + Writeable> ChannelMonitor<ChanSigner> {
758+
impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
759759
/// Writes this monitor into the given writer, suitable for writing to disk.
760760
///
761761
/// Note that the deserializer is only implemented for (Sha256dHash, ChannelMonitor), which

lightning/src/chain/keysinterface.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ impl Readable for SpendableOutputDescriptor {
204204
// routine).
205205
// TODO: We should remove Clone by instead requesting a new ChannelKeys copy when we create
206206
// ChannelMonitors instead of expecting to clone the one out of the Channel into the monitors.
207-
pub trait ChannelKeys : Send+Clone {
207+
pub trait ChannelKeys : Send+Clone + Writeable {
208208
/// Gets the per-commitment point for a specific commitment number
209209
///
210210
/// Note that the commitment number starts at (1 << 48) - 1 and counts backwards.

lightning/src/ln/channel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4074,7 +4074,7 @@ impl Readable for InboundHTLCRemovalReason {
40744074
}
40754075
}
40764076

4077-
impl<ChanSigner: ChannelKeys + Writeable> Writeable for Channel<ChanSigner> {
4077+
impl<ChanSigner: ChannelKeys> Writeable for Channel<ChanSigner> {
40784078
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), ::std::io::Error> {
40794079
// Note that we write out as if remove_uncommitted_htlcs_and_mark_paused had just been
40804080
// called but include holding cell updates (and obviously we don't modify self).

lightning/src/ln/onchaintx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ pub struct OnchainTxHandler<ChanSigner: ChannelKeys> {
287287
secp_ctx: Secp256k1<secp256k1::All>,
288288
}
289289

290-
impl<ChanSigner: ChannelKeys + Writeable> OnchainTxHandler<ChanSigner> {
290+
impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
291291
pub(crate) fn write<W: Writer>(&self, writer: &mut W) -> Result<(), ::std::io::Error> {
292292
self.destination_script.write(writer)?;
293293
self.holder_commitment.write(writer)?;

0 commit comments

Comments
 (0)