Skip to content

Commit 259f6c6

Browse files
committed
nits
1 parent 028f250 commit 259f6c6

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

lightning/src/chain/keysinterface.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ pub trait ChannelKeys : Send {
161161
/// Set the remote funding key. This is done immediately on incoming channels
162162
/// and as soon as the channel is accepted on outgoing channels.
163163
///
164-
/// Must be called before any signatures are applied.
164+
/// Will be called before any signatures are applied.
165165
fn set_remote_funding_pubkey(&mut self, key: &PublicKey);
166166
}
167167

@@ -196,7 +196,7 @@ impl ChannelKeys for InMemoryChannelKeys {
196196
if commitment_tx.input.len() != 1 { return Err(()); }
197197

198198
let funding_pubkey = PublicKey::from_secret_key(secp_ctx, &self.funding_key);
199-
let channel_funding_redeemscript = make_funding_redeemscript(funding_pubkey, self.remote_funding_pubkey.expect("must set remote funding key before signing"));
199+
let channel_funding_redeemscript = make_funding_redeemscript(&funding_pubkey, &self.remote_funding_pubkey.expect("must set remote funding key before signing"));
200200

201201
let commitment_sighash = hash_to_message!(&bip143::SighashComponents::new(&commitment_tx).sighash_all(&commitment_tx.input[0], &channel_funding_redeemscript, channel_value_satoshis)[..]);
202202
let commitment_sig = secp_ctx.sign(&commitment_sighash, &self.funding_key);
@@ -389,7 +389,6 @@ impl KeysInterface for KeysManager {
389389
let payment_base_key = key_step!(b"payment base key", revocation_base_key);
390390
let delayed_payment_base_key = key_step!(b"delayed payment base key", payment_base_key);
391391
let htlc_base_key = key_step!(b"HTLC base key", delayed_payment_base_key);
392-
let remote_funding_pubkey = None;
393392

394393
InMemoryChannelKeys {
395394
funding_key,
@@ -398,7 +397,7 @@ impl KeysInterface for KeysManager {
398397
delayed_payment_base_key,
399398
htlc_base_key,
400399
commitment_seed,
401-
remote_funding_pubkey,
400+
remote_funding_pubkey: None,
402401
}
403402
}
404403

lightning/src/ln/chan_utils.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,11 @@ pub fn get_htlc_redeemscript(htlc: &HTLCOutputInCommitment, keys: &TxCreationKey
255255
get_htlc_redeemscript_with_explicit_keys(htlc, &keys.a_htlc_key, &keys.b_htlc_key, &keys.revocation_key)
256256
}
257257

258-
/// redeem script for funding transaction output
259-
pub fn make_funding_redeemscript(our_funding_pubkey: PublicKey, their_funding_pubkey: PublicKey) -> Script {
260-
let our_funding_key = our_funding_pubkey.serialize();
261-
let their_funding_key = their_funding_pubkey.serialize();
258+
/// Gets the redeemscript for a funding output from the two funding public keys.
259+
/// Note that the order of funding public keys does not matter.
260+
pub fn make_funding_redeemscript(a: &PublicKey, b: &PublicKey) -> Script {
261+
let our_funding_key = a.serialize();
262+
let their_funding_key = b.serialize();
262263

263264
let builder = Builder::new().push_opcode(opcodes::all::OP_PUSHNUM_2);
264265
if our_funding_key[..] < their_funding_key[..] {

lightning/src/ln/channel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
11141114
pub fn get_funding_redeemscript(&self) -> Script {
11151115
let our_funding_key = PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.funding_key());
11161116
let their_funding_key = self.their_funding_pubkey.expect("get_funding_redeemscript only allowed after accept_channel");
1117-
make_funding_redeemscript(our_funding_key, their_funding_key)
1117+
make_funding_redeemscript(&our_funding_key, &their_funding_key)
11181118
}
11191119

11201120
/// Builds the htlc-success or htlc-timeout transaction which spends a given HTLC output

0 commit comments

Comments
 (0)