You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lightning/src/ln/channel.rs
+23-51Lines changed: 23 additions & 51 deletions
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ use ln::msgs;
19
19
use ln::msgs::{DecodeError,OptionalField,LocalFeatures,DataLossProtect};
20
20
use ln::channelmonitor::ChannelMonitor;
21
21
use ln::channelmanager::{PendingHTLCStatus,HTLCSource,HTLCFailReason,HTLCFailureMsg,PendingForwardHTLCInfo,RAACommitmentOrder,PaymentPreimage,PaymentHash,BREAKDOWN_TIMEOUT,MAX_LOCAL_BREAKDOWN_TIMEOUT};
22
-
use ln::chan_utils::{TxCreationKeys,HTLCOutputInCommitment,HTLC_SUCCESS_TX_WEIGHT,HTLC_TIMEOUT_TX_WEIGHT};
22
+
use ln::chan_utils::{LocalCommitmentTransaction,TxCreationKeys,HTLCOutputInCommitment,HTLC_SUCCESS_TX_WEIGHT,HTLC_TIMEOUT_TX_WEIGHT};
23
23
use ln::chan_utils;
24
24
use chain::chaininterface::{FeeEstimator,ConfirmationTarget};
let local_initial_commitment_tx = self.build_commitment_transaction(self.cur_local_commitment_transaction_number,&local_keys,true,false,self.feerate_per_kw).0;
1500
1468
let local_sighash = hash_to_message!(&bip143::SighashComponents::new(&local_initial_commitment_tx).sighash_all(&local_initial_commitment_tx.input[0],&funding_script,self.channel_value_satoshis)[..]);
1501
1469
1502
1470
// They sign the "local" commitment transaction...
1503
1471
secp_check!(self.secp_ctx.verify(&local_sighash,&sig,&self.their_funding_pubkey.unwrap()),"Invalid funding_created signature from peer");
1504
1472
1505
-
// ...and we sign it, allowing us to broadcast the tx if we wish
let localtx = LocalCommitmentTransaction::new_missing_local_sig(local_initial_commitment_tx, sig,&PublicKey::from_secret_key(&self.secp_ctx,self.local_keys.funding_key()),self.their_funding_pubkey.as_ref().unwrap());
1507
1474
1508
1475
let remote_keys = self.build_remote_transaction_keys()?;
1509
1476
let remote_initial_commitment_tx = self.build_commitment_transaction(self.cur_remote_commitment_transaction_number,&remote_keys,false,false,self.feerate_per_kw).0;
1510
1477
let remote_signature = self.local_keys.sign_remote_commitment(self.channel_value_satoshis,&self.get_funding_redeemscript(),self.feerate_per_kw,&remote_initial_commitment_tx,&remote_keys,&Vec::new(),self.our_to_self_delay,&self.secp_ctx)
1511
1478
.map_err(|_| ChannelError::Close("Failed to get signatures for new commitment_signed"))?.0;
1512
1479
1513
1480
// We sign the "remote" commitment transaction, allowing them to broadcast the tx if they wish.
let local_initial_commitment_tx = self.build_commitment_transaction(self.cur_local_commitment_transaction_number,&local_keys,true,false,self.feerate_per_kw).0;
1579
1546
let local_sighash = hash_to_message!(&bip143::SighashComponents::new(&local_initial_commitment_tx).sighash_all(&local_initial_commitment_tx.input[0],&funding_script,self.channel_value_satoshis)[..]);
1580
1547
1581
1548
// They sign the "local" commitment transaction, allowing us to broadcast the tx if we wish.
1582
1549
secp_check!(self.secp_ctx.verify(&local_sighash,&msg.signature,&self.their_funding_pubkey.unwrap()),"Invalid funding_signed signature from peer");
panic!("Can't get a channel monitor until funding has been created");
2865
2834
}
2866
-
&self.channel_monitor
2835
+
&mutself.channel_monitor
2867
2836
}
2868
2837
2869
2838
/// Guaranteed to be Some after both FundingLocked messages have been exchanged (and, thus,
@@ -4141,6 +4110,7 @@ mod tests {
4141
4110
use ln::channel::{Channel,ChannelKeys,InboundHTLCOutput,OutboundHTLCOutput,InboundHTLCState,OutboundHTLCState,HTLCOutputInCommitment,TxCreationKeys};
4142
4111
use ln::channel::MAX_FUNDING_SATOSHIS;
4143
4112
use ln::chan_utils;
4113
+
use ln::chan_utils::LocalCommitmentTransaction;
4144
4114
use chain::chaininterface::{FeeEstimator,ConfirmationTarget};
4145
4115
use chain::keysinterface::{InMemoryChannelKeys,KeysInterface};
4146
4116
use chain::transaction::OutPoint;
@@ -4260,13 +4230,15 @@ mod tests {
4260
4230
.collect();
4261
4231
(res.0, htlcs)
4262
4232
};
4233
+
let redeemscript = chan.get_funding_redeemscript();
4263
4234
let their_signature = Signature::from_der(&hex::decode($their_sig_hex).unwrap()[..]).unwrap();
4264
-
let sighash = Message::from_slice(&bip143::SighashComponents::new(&unsigned_tx.0).sighash_all(&unsigned_tx.0.input[0],&chan.get_funding_redeemscript(), chan.channel_value_satoshis)[..]).unwrap();
4235
+
let sighash = Message::from_slice(&bip143::SighashComponents::new(&unsigned_tx.0).sighash_all(&unsigned_tx.0.input[0],&redeemscript, chan.channel_value_satoshis)[..]).unwrap();
0 commit comments