Skip to content

Commit 6ed4cfb

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 2d2c8ca commit 6ed4cfb

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
@@ -686,7 +686,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
686686
}
687687
} else { None };
688688

689-
let mut chan = Channel {
689+
let chan = Channel {
690690
user_id: user_id,
691691
config: local_config,
692692

@@ -762,10 +762,6 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
762762
logger,
763763
};
764764

765-
let obscure_factor = chan.get_commitment_transaction_number_obscure_factor();
766-
let funding_redeemscript = chan.get_funding_redeemscript();
767-
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);
768-
769765
Ok(chan)
770766
}
771767

@@ -1435,10 +1431,6 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
14351431
self.their_cur_commitment_point = Some(msg.first_per_commitment_point);
14361432
self.their_shutdown_scriptpubkey = their_shutdown_scriptpubkey;
14371433

1438-
let obscure_factor = self.get_commitment_transaction_number_obscure_factor();
1439-
let funding_redeemscript = self.get_funding_redeemscript();
1440-
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);
1441-
14421434
self.channel_state = ChannelState::OurInitSent as u32 | ChannelState::TheirInitSent as u32;
14431435

14441436
Ok(())
@@ -1496,7 +1488,11 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
14961488
}
14971489
};
14981490

1499-
let funding_txo_script = self.get_funding_redeemscript().to_v0_p2wsh();
1491+
let their_pubkeys = self.their_pubkeys.as_ref().unwrap();
1492+
let funding_redeemscript = self.get_funding_redeemscript();
1493+
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());
1494+
1495+
let funding_txo_script = funding_redeemscript.to_v0_p2wsh();
15001496
self.channel_monitor.set_funding_info((funding_txo, funding_txo_script));
15011497

15021498
// Now that we're past error-generating stuff, update our local state:
@@ -3314,7 +3310,11 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
33143310
}
33153311
};
33163312

3317-
let funding_txo_script = self.get_funding_redeemscript().to_v0_p2wsh();
3313+
let their_pubkeys = self.their_pubkeys.as_ref().unwrap();
3314+
let funding_redeemscript = self.get_funding_redeemscript();
3315+
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());
3316+
3317+
let funding_txo_script = funding_redeemscript.to_v0_p2wsh();
33183318
self.channel_monitor.set_funding_info((funding_txo, funding_txo_script));
33193319
let temporary_channel_id = self.channel_id;
33203320

0 commit comments

Comments
 (0)