Skip to content

Commit 8daaad9

Browse files
committed
fix(chain): add missing continue in CanonicalIter assumed-tx processing
Without the `continue`, the loop falls through to the subsequent processing blocks when assumed-canonical transactions are the only remaining unprocessed source. If the anchored, seen, and leftover iterators are all exhausted, the loop reaches `return None` and silently drops the assumed transactions that were just marked canonical. Co-Authored-By: HAL 9000
1 parent d9aa92b commit 8daaad9

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

crates/chain/src/canonical_iter.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ impl<A: Anchor, C: ChainOracle> Iterator for CanonicalIter<'_, A, C> {
218218
if !self.is_canonicalized(txid) {
219219
self.mark_canonical(txid, tx, CanonicalReason::assumed());
220220
}
221+
continue;
221222
}
222223

223224
if let Some((txid, tx, anchors)) = self.unprocessed_anchored_txs.next() {

crates/chain/tests/test_tx_graph_conflicts.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,34 @@ fn test_tx_conflict_handling() {
943943
confirmed: Amount::ZERO,
944944
},
945945
},
946+
Scenario {
947+
name: "only assumed-canonical txs are yielded without anchored or seen txs",
948+
tx_templates: &[
949+
TxTemplate {
950+
tx_name: "assumed_a",
951+
inputs: &[TxInTemplate::Bogus],
952+
outputs: &[TxOutTemplate::new(21_000, Some(0))],
953+
assume_canonical: true,
954+
..Default::default()
955+
},
956+
TxTemplate {
957+
tx_name: "assumed_b",
958+
inputs: &[TxInTemplate::Bogus],
959+
outputs: &[TxOutTemplate::new(18_000, Some(1))],
960+
assume_canonical: true,
961+
..Default::default()
962+
},
963+
],
964+
exp_chain_txs: HashSet::from(["assumed_a", "assumed_b"]),
965+
exp_chain_txouts: HashSet::from([("assumed_a", 0), ("assumed_b", 0)]),
966+
exp_unspents: HashSet::from([("assumed_a", 0), ("assumed_b", 0)]),
967+
exp_balance: Balance {
968+
immature: Amount::ZERO,
969+
trusted_pending: Amount::from_sat(21_000 + 18_000),
970+
untrusted_pending: Amount::ZERO,
971+
confirmed: Amount::ZERO,
972+
},
973+
},
946974
Scenario {
947975
name: "coinbase tx must not become unconfirmed",
948976
tx_templates: &[

0 commit comments

Comments
 (0)