@@ -862,7 +862,7 @@ impl OutputCache {
862
862
}
863
863
864
864
for tx in tx_to_rollback_data {
865
- self . rollback_tx_data ( & tx) ;
865
+ self . rollback_tx_data ( & tx) ? ;
866
866
}
867
867
868
868
conflicting_txs_with_descendants. extend ( txs_to_rollback. into_iter ( ) ) ;
@@ -1276,7 +1276,7 @@ impl OutputCache {
1276
1276
pub fn remove_confirmed_tx ( & mut self , tx_id : & OutPointSourceId ) -> WalletResult < ( ) > {
1277
1277
if let Some ( tx) = self . txs . remove ( tx_id) {
1278
1278
matches ! ( tx. state( ) , TxState :: Confirmed ( ..) ) ;
1279
- self . rollback_tx_data ( & tx) ;
1279
+ self . rollback_tx_data ( & tx) ? ;
1280
1280
}
1281
1281
1282
1282
ensure ! (
@@ -1495,7 +1495,7 @@ impl OutputCache {
1495
1495
1496
1496
// After tx is removed as a result of reorg, abandoning or marking as conflicted
1497
1497
// its effect on OutputCache's data fields should be rolled back
1498
- fn rollback_tx_data ( & mut self , tx : & WalletTx ) {
1498
+ fn rollback_tx_data ( & mut self , tx : & WalletTx ) -> WalletResult < ( ) > {
1499
1499
let tx_id = tx. id ( ) ;
1500
1500
1501
1501
// Iterate in reverse to handle situations where an account is modified twice in the same tx
@@ -1585,18 +1585,31 @@ impl OutputCache {
1585
1585
}
1586
1586
}
1587
1587
}
1588
+ TxOutput :: CreateDelegationId ( _, _) => {
1589
+ let input0_outpoint = crate :: utils:: get_first_utxo_outpoint ( tx. inputs ( ) ) ?;
1590
+ let delegation_id = make_delegation_id ( input0_outpoint) ;
1591
+ self . delegations . remove ( & delegation_id) ;
1592
+ }
1593
+ TxOutput :: IssueFungibleToken ( _) => {
1594
+ let token_id = make_token_id ( tx. inputs ( ) ) . ok_or ( WalletError :: NoUtxos ) ?;
1595
+ self . token_issuance . remove ( & token_id) ;
1596
+ }
1597
+ TxOutput :: CreateOrder ( _) => {
1598
+ let input0_outpoint = crate :: utils:: get_first_utxo_outpoint ( tx. inputs ( ) ) ?;
1599
+ let order_id = make_order_id ( input0_outpoint) ;
1600
+ self . orders . remove ( & order_id) ;
1601
+ }
1588
1602
TxOutput :: Burn ( _)
1589
1603
| TxOutput :: Transfer ( _, _)
1590
1604
| TxOutput :: IssueNft ( _, _, _)
1591
1605
| TxOutput :: DataDeposit ( _)
1592
1606
| TxOutput :: DelegateStaking ( _, _)
1593
1607
| TxOutput :: LockThenTransfer ( _, _, _)
1594
- | TxOutput :: CreateDelegationId ( _, _)
1595
- | TxOutput :: IssueFungibleToken ( _)
1596
- | TxOutput :: Htlc ( _, _)
1597
- | TxOutput :: CreateOrder ( _) => { }
1608
+ | TxOutput :: Htlc ( _, _) => { }
1598
1609
}
1599
1610
}
1611
+
1612
+ Ok ( ( ) )
1600
1613
}
1601
1614
1602
1615
/// Mark a transaction and its descendants as abandoned
@@ -1633,7 +1646,7 @@ impl OutputCache {
1633
1646
}
1634
1647
1635
1648
for tx in txs_to_rollback {
1636
- self . rollback_tx_data ( & tx) ;
1649
+ self . rollback_tx_data ( & tx) ? ;
1637
1650
}
1638
1651
1639
1652
Ok ( all_abandoned)
0 commit comments