Skip to content

Commit 58a84c6

Browse files
committed
Fix incorrect anchors counterparty_payment_script upon deserialization
1 parent 3ef8990 commit 58a84c6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lightning/src/chain/channelmonitor.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -4130,7 +4130,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
41304130
1 => { None },
41314131
_ => return Err(DecodeError::InvalidValue),
41324132
};
4133-
let counterparty_payment_script = Readable::read(reader)?;
4133+
let mut counterparty_payment_script: Script = Readable::read(reader)?;
41344134
let shutdown_script = {
41354135
let script = <Script as Readable>::read(reader)?;
41364136
if script.is_empty() { None } else { Some(script) }
@@ -4331,6 +4331,17 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
43314331
(17, initial_counterparty_commitment_info, option),
43324332
});
43334333

4334+
// Monitors for anchor outputs channels opened in v0.0.116 suffered from a bug in which the
4335+
// wrong `counterparty_payment_script` was being tracked. Fix it now on deserialization to
4336+
// give them a chance to recognize the spendable output.
4337+
if onchain_tx_handler.channel_type_features().supports_anchors_zero_fee_htlc_tx() &&
4338+
counterparty_payment_script.is_v0_p2wpkh() {
4339+
let payment_point = onchain_tx_handler.channel_transaction_parameters
4340+
.as_holder_broadcastable().broadcaster_pubkeys().payment_point;
4341+
counterparty_payment_script =
4342+
chan_utils::get_to_countersignatory_with_anchors_redeemscript(&payment_point);
4343+
}
4344+
43344345
Ok((best_block.block_hash(), ChannelMonitor::from_impl(ChannelMonitorImpl {
43354346
latest_update_id,
43364347
commitment_transaction_number_obscure_factor,

0 commit comments

Comments
 (0)