Skip to content

Commit b748ed4

Browse files
committed
Set ChannelMonitor basic_channel_info on funding, not on accept
This prepares for only creating the ChannelMonitor on funding by removing any channel_monitor calls from Channel open/accept-time to funding-signed time.
1 parent 0fd57f5 commit b748ed4

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

lightning/src/ln/channel.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
689689
}
690690
} else { None };
691691

692-
let mut chan = Channel {
692+
let chan = Channel {
693693
user_id: user_id,
694694
config: local_config,
695695

@@ -765,10 +765,6 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
765765
logger,
766766
};
767767

768-
let obscure_factor = chan.get_commitment_transaction_number_obscure_factor();
769-
let funding_redeemscript = chan.get_funding_redeemscript();
770-
chan.channel_monitor.set_basic_channel_info(&msg.htlc_basepoint, &msg.delayed_payment_basepoint, msg.to_self_delay, funding_redeemscript, msg.funding_satoshis, obscure_factor);
771-
772768
Ok(chan)
773769
}
774770

@@ -1438,10 +1434,6 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
14381434
self.their_cur_commitment_point = Some(msg.first_per_commitment_point);
14391435
self.their_shutdown_scriptpubkey = their_shutdown_scriptpubkey;
14401436

1441-
let obscure_factor = self.get_commitment_transaction_number_obscure_factor();
1442-
let funding_redeemscript = self.get_funding_redeemscript();
1443-
self.channel_monitor.set_basic_channel_info(&msg.htlc_basepoint, &msg.delayed_payment_basepoint, msg.to_self_delay, funding_redeemscript, self.channel_value_satoshis, obscure_factor);
1444-
14451437
self.channel_state = ChannelState::OurInitSent as u32 | ChannelState::TheirInitSent as u32;
14461438

14471439
Ok(())
@@ -1499,7 +1491,11 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
14991491
}
15001492
};
15011493

1502-
let funding_txo_script = self.get_funding_redeemscript().to_v0_p2wsh();
1494+
let their_pubkeys = self.their_pubkeys.as_ref().unwrap();
1495+
let funding_redeemscript = self.get_funding_redeemscript();
1496+
self.channel_monitor.set_basic_channel_info(&their_pubkeys.htlc_basepoint, &their_pubkeys.delayed_payment_basepoint, self.their_to_self_delay, funding_redeemscript.clone(), self.channel_value_satoshis, self.get_commitment_transaction_number_obscure_factor());
1497+
1498+
let funding_txo_script = funding_redeemscript.to_v0_p2wsh();
15031499
self.channel_monitor.set_funding_info((funding_txo, funding_txo_script));
15041500

15051501
// Now that we're past error-generating stuff, update our local state:
@@ -3330,7 +3326,11 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
33303326
}
33313327
};
33323328

3333-
let funding_txo_script = self.get_funding_redeemscript().to_v0_p2wsh();
3329+
let their_pubkeys = self.their_pubkeys.as_ref().unwrap();
3330+
let funding_redeemscript = self.get_funding_redeemscript();
3331+
self.channel_monitor.set_basic_channel_info(&their_pubkeys.htlc_basepoint, &their_pubkeys.delayed_payment_basepoint, self.their_to_self_delay, funding_redeemscript.clone(), self.channel_value_satoshis, self.get_commitment_transaction_number_obscure_factor());
3332+
3333+
let funding_txo_script = funding_redeemscript.to_v0_p2wsh();
33343334
self.channel_monitor.set_funding_info((funding_txo, funding_txo_script));
33353335
let temporary_channel_id = self.channel_id;
33363336

0 commit comments

Comments
 (0)