Demo double-spend-creation 2020-09-demo-doublespend
authorMatt Corallo <git@bluematt.me>
Thu, 17 Sep 2020 16:14:05 +0000 (12:14 -0400)
committerMatt Corallo <git@bluematt.me>
Thu, 17 Sep 2020 16:14:54 +0000 (12:14 -0400)
lightning/src/chain/chaininterface.rs
lightning/src/ln/functional_tests.rs

index 295c337e29d905ff8e6e5b28ffb4043b76429148..bbef5ec721cdf7d1d5a376091191ec747dc408ba 100644 (file)
@@ -380,9 +380,10 @@ impl ChainWatchInterface for ChainWatchInterfaceUtil {
                {
                        let watched = self.watched.lock().unwrap();
                        for (index, transaction) in block.txdata.iter().enumerate() {
-                               if self.does_match_tx_unguarded(transaction, &watched) {
+                               // Note, while some clients filter, we can't rely on all clients filtering!
+                               //if self.does_match_tx_unguarded(transaction, &watched) {
                                        matched_index.push(index);
-                               }
+                               //}
                        }
                }
                matched_index
index a94003c484aaa1dacab7b80b9232e32d78ab6331..6703b1e2ec73df4be03b69d9e7afcdf9d59396cd 100644 (file)
@@ -5037,9 +5037,16 @@ fn test_static_spendable_outputs_justice_tx_revoked_htlc_timeout_tx() {
        check_added_monitors!(nodes[1], 1);
 
        let node_txn = nodes[1].tx_broadcaster.txn_broadcasted.lock().unwrap();
-       assert_eq!(node_txn.len(), 4); // ChannelMonitor: justice tx on revoked commitment, justice tx on revoked HTLC-timeout, adjusted justice tx, ChannelManager: local commitment tx
-       assert_eq!(node_txn[0].input.len(), 2);
-       check_spends!(node_txn[0], revoked_local_txn[0]);
+       assert_eq!(node_txn.len(), 3); // ChannelMonitor: justice tx on revoked commitment, justice tx on revoked HTLC-timeout, adjusted justice tx, ChannelManager: local commitment tx
+
+       // node_txn[0] fully spends revoked_local_txn[0].
+       assert_eq!(node_txn[0].input.len(), 3);
+       assert_eq!(revoked_local_txn[0].output.len(), 2);
+       // node_txn[0] tries to spend both revoked_local_txn[0] and revoked_htlc_txn[0], but
+       // revoked_htlc_txn[0] spends revoked_local_txn[0] (ie this is a double-spend)!
+       check_spends!(node_txn[0], revoked_local_txn[0], revoked_htlc_txn[0]);
+       check_spends!(revoked_htlc_txn[0], revoked_local_txn[0]);
+
        check_spends!(node_txn[1], chan_1.3);
        assert_eq!(node_txn[2].input.len(), 1);
        check_spends!(node_txn[2], revoked_htlc_txn[0]);