@@ -1523,16 +1523,19 @@ trait InitialRemoteCommitmentReceiver<SP: Deref> where SP::Target: SignerProvide
1523
1523
}
1524
1524
1525
1525
fn initial_commitment_signed<L: Deref>(
1526
- &mut self, channel_id: ChannelId, counterparty_signature: Signature, counterparty_txid: Txid,
1526
+ &mut self, channel_id: ChannelId, counterparty_signature: Signature,
1527
1527
counterparty_commitment_number: u64, best_block: BestBlock, signer_provider: &SP, logger: &L,
1528
- ) -> Result<ChannelMonitor<<SP::Target as SignerProvider>::EcdsaSigner>, ChannelError>
1528
+ ) -> Result<( ChannelMonitor<<SP::Target as SignerProvider>::EcdsaSigner>, CommitmentTransaction) , ChannelError>
1529
1529
where
1530
1530
L::Target: Logger
1531
1531
{
1532
1532
let initial_commitment_tx = match self.check_counterparty_commitment_signature(&counterparty_signature, logger) {
1533
1533
Ok(res) => res,
1534
1534
Err(ChannelError::Close(e)) => {
1535
- self.context_mut().channel_transaction_parameters.funding_outpoint = None;
1535
+ // TODO(dual_funding): Update for V2 established channels.
1536
+ if !self.context().is_outbound() {
1537
+ self.context_mut().channel_transaction_parameters.funding_outpoint = None;
1538
+ }
1536
1539
return Err(ChannelError::Close(e));
1537
1540
},
1538
1541
Err(e) => {
@@ -1596,15 +1599,15 @@ trait InitialRemoteCommitmentReceiver<SP: Deref> where SP::Target: SignerProvide
1596
1599
obscure_factor,
1597
1600
holder_commitment_tx, best_block, context.counterparty_node_id, context.channel_id());
1598
1601
channel_monitor.provide_initial_counterparty_commitment_tx(
1599
- counterparty_txid , Vec::new(),
1602
+ counterparty_initial_bitcoin_tx.txid , Vec::new(),
1600
1603
counterparty_commitment_number,
1601
1604
context.counterparty_cur_commitment_point.unwrap(),
1602
1605
counterparty_initial_commitment_tx.feerate_per_kw(),
1603
1606
counterparty_initial_commitment_tx.to_broadcaster_value_sat(),
1604
1607
counterparty_initial_commitment_tx.to_countersignatory_value_sat(),
1605
1608
logger);
1606
1609
1607
- Ok(channel_monitor)
1610
+ Ok(( channel_monitor, counterparty_initial_commitment_tx) )
1608
1611
}
1609
1612
}
1610
1613
@@ -7998,24 +8001,20 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
7998
8001
panic!("Should not have advanced channel commitment tx numbers prior to funding_created");
7999
8002
}
8000
8003
8001
- let counterparty_keys = self.context.build_remote_transaction_keys();
8002
- let counterparty_initial_commitment_tx = self.context.build_commitment_transaction(self.context.cur_counterparty_commitment_transaction_number, &counterparty_keys, false, false, logger).tx;
8003
- let counterparty_trusted_tx = counterparty_initial_commitment_tx.trust();
8004
- let counterparty_initial_bitcoin_tx = counterparty_trusted_tx.built_transaction();
8005
-
8006
- log_trace!(logger, "Initial counterparty tx for channel {} is: txid {} tx {}",
8007
- &self.context.channel_id(), counterparty_initial_bitcoin_tx.txid, encode::serialize_hex(&counterparty_initial_bitcoin_tx.transaction));
8008
-
8009
- let channel_monitor = match self.initial_commitment_signed(
8004
+ let (channel_monitor, counterparty_initial_commitment_tx) = match self.initial_commitment_signed(
8010
8005
self.context.channel_id(),
8011
- msg.signature, counterparty_initial_bitcoin_tx.txid,
8012
- self.context.cur_counterparty_commitment_transaction_number,
8006
+ msg.signature, self.context.cur_counterparty_commitment_transaction_number,
8013
8007
best_block, signer_provider, logger
8014
8008
) {
8015
8009
Ok(channel_monitor) => channel_monitor,
8016
8010
Err(err) => return Err((self, err)),
8017
8011
};
8018
8012
8013
+ let counterparty_trusted_tx = counterparty_initial_commitment_tx.trust();
8014
+ let counterparty_initial_bitcoin_tx = counterparty_trusted_tx.built_transaction();
8015
+ log_trace!(logger, "Initial counterparty tx for channel {} is: txid {} tx {}",
8016
+ &self.context.channel_id(), counterparty_initial_bitcoin_tx.txid, encode::serialize_hex(&counterparty_initial_bitcoin_tx.transaction));
8017
+
8019
8018
self.context.cur_counterparty_commitment_transaction_number -= 1;
8020
8019
log_info!(logger, "Received funding_signed from peer for channel {}", &self.context.channel_id());
8021
8020
@@ -8233,20 +8232,16 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
8233
8232
// check_funding_created_signature may fail.
8234
8233
self.context.holder_signer.as_mut().provide_channel_parameters(&self.context.channel_transaction_parameters);
8235
8234
8236
- self.context.cur_counterparty_commitment_transaction_number -= 1;
8237
- let counterparty_keys = self.context.build_remote_transaction_keys();
8238
- let counterparty_initial_commitment_tx = self.context.build_commitment_transaction(self.context.cur_counterparty_commitment_transaction_number + 1, &counterparty_keys, false, false, logger).tx;
8239
-
8240
- let channel_monitor = match self.initial_commitment_signed(
8235
+ let (channel_monitor, counterparty_initial_commitment_tx) = match self.initial_commitment_signed(
8241
8236
ChannelId::v1_from_funding_outpoint(funding_txo),
8242
- msg.signature, counterparty_initial_commitment_tx.trust().txid(),
8243
- self.context.cur_counterparty_commitment_transaction_number + 1,
8237
+ msg.signature, self.context.cur_counterparty_commitment_transaction_number,
8244
8238
best_block, signer_provider, logger
8245
8239
) {
8246
8240
Ok(channel_monitor) => channel_monitor,
8247
8241
Err(err) => return Err((self, err)),
8248
8242
};
8249
8243
8244
+ self.context.cur_counterparty_commitment_transaction_number -= 1;
8250
8245
let funding_signed = self.context.get_funding_signed_msg(logger, counterparty_initial_commitment_tx);
8251
8246
8252
8247
log_info!(logger, "{} funding_signed for peer for channel {}",
0 commit comments