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
send warning when we receive a old commitment transaction
During a `channel_reestablish` now we send a warning message when we receive a old commitment transaction from the peer.
In addition, this commit include the update of functional test to make sure that the receiver will generate warn messages.
Signed-off-by: Vincenzo Palazzo <[email protected]>
// Before change the state of the channel we check if the peer is sending a very old
3741
+
// commitment transaction number, if yes we send an error (warning message).
3742
+
let our_commitment_transaction = INITIAL_COMMITMENT_NUMBER - self.cur_holder_commitment_transaction_number - 1;
3743
+
if msg.next_remote_commitment_number + 1 < our_commitment_transaction {
3744
+
returnErr(
3745
+
ChannelError::Warn(format!("Peer attempted to reestablish channel with a very old local commitment transaction: {} (received) vs {} (expected)", msg.next_remote_commitment_number, our_commitment_transaction))
3746
+
);
3747
+
}
3748
+
3740
3749
// Go ahead and unmark PeerDisconnected as various calls we may make check for it (and all
3741
3750
// remaining cases either succeed or ErrorMessage-fail).
check_closed_event!(nodes[1], 1, ClosureReason::ProcessingError { err: "Peer attempted to reestablish channel with a very old local commitment transaction".to_string() });
7407
-
assert_eq!(check_closed_broadcast!(nodes[1], true).unwrap().data, "Peer attempted to reestablish channel with a very old local commitment transaction");
7408
-
check_added_monitors!(nodes[1], 1);
7420
+
let warn_msg = "Peer attempted to reestablish channel with a very old local commitment transaction".to_owned();
let node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap().clone();
7412
-
assert_eq!(node_txn.len(), 1);
7413
-
check_spends!(node_txn[0], chan.3);
7414
-
assert_eq!(node_txn[0].output.len(), 2);
7415
-
mine_transaction(&nodes[0], &node_txn[0]);
7416
-
connect_blocks(&nodes[0], ANTI_REORG_DELAY - 1);
7417
-
check_closed_event!(nodes[0], 1, ClosureReason::ProcessingError { err: "We have fallen behind - we have received proof that if we broadcast remote is going to claim our funds - we can\'t do any automated broadcasting".to_string() });
7418
-
let spend_txn = check_spendable_outputs!(nodes[0], node_cfgs[0].keys_manager);
7419
-
assert_eq!(spend_txn.len(), 1);
7420
-
check_spends!(spend_txn[0], node_txn[0]);
7424
+
let mut node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap().clone();
7425
+
// The node B should not broadcast the transaction to force close the channel!
7426
+
assert!(node_txn.is_empty());
7427
+
// B should now detect that there is something wrong and should force close the channel.
7428
+
let exp_err = "We have fallen behind - we have received proof that if we broadcast remote is going to claim our funds - we can\'t do any automated broadcasting";
0 commit comments