@@ -860,7 +860,7 @@ impl OutputCache {
860
860
}
861
861
862
862
for tx in tx_to_rollback_data {
863
- self . rollback_tx_data ( & tx) ;
863
+ self . rollback_tx_data ( & tx) ? ;
864
864
}
865
865
866
866
conflicting_txs_with_descendants. extend ( txs_to_rollback. into_iter ( ) ) ;
@@ -1242,7 +1242,7 @@ impl OutputCache {
1242
1242
pub fn remove_confirmed_tx ( & mut self , tx_id : & OutPointSourceId ) -> WalletResult < ( ) > {
1243
1243
if let Some ( tx) = self . txs . remove ( tx_id) {
1244
1244
matches ! ( tx. state( ) , TxState :: Confirmed ( ..) ) ;
1245
- self . rollback_tx_data ( & tx) ;
1245
+ self . rollback_tx_data ( & tx) ? ;
1246
1246
}
1247
1247
1248
1248
ensure ! (
@@ -1459,7 +1459,7 @@ impl OutputCache {
1459
1459
1460
1460
// After tx is removed as a result of reorg, abandoning or marking as conflicted
1461
1461
// its effect on OutputCache's data fields should be rolled back
1462
- fn rollback_tx_data ( & mut self , tx : & WalletTx ) {
1462
+ fn rollback_tx_data ( & mut self , tx : & WalletTx ) -> WalletResult < ( ) > {
1463
1463
let tx_id = tx. id ( ) ;
1464
1464
1465
1465
// Iterate in reverse to handle situations where an account is modified twice in the same tx
@@ -1514,18 +1514,31 @@ impl OutputCache {
1514
1514
}
1515
1515
}
1516
1516
}
1517
+ TxOutput :: CreateDelegationId ( _, _) => {
1518
+ let input0_outpoint = crate :: utils:: get_first_utxo_outpoint ( tx. inputs ( ) ) ?;
1519
+ let delegation_id = make_delegation_id ( input0_outpoint) ;
1520
+ self . delegations . remove ( & delegation_id) ;
1521
+ }
1522
+ TxOutput :: IssueFungibleToken ( _) => {
1523
+ let token_id = make_token_id ( tx. inputs ( ) ) . ok_or ( WalletError :: NoUtxos ) ?;
1524
+ self . token_issuance . remove ( & token_id) ;
1525
+ }
1526
+ TxOutput :: CreateOrder ( _) => {
1527
+ let input0_outpoint = crate :: utils:: get_first_utxo_outpoint ( tx. inputs ( ) ) ?;
1528
+ let order_id = make_order_id ( input0_outpoint) ;
1529
+ self . orders . remove ( & order_id) ;
1530
+ }
1517
1531
TxOutput :: Burn ( _)
1518
1532
| TxOutput :: Transfer ( _, _)
1519
1533
| TxOutput :: IssueNft ( _, _, _)
1520
1534
| TxOutput :: DataDeposit ( _)
1521
1535
| TxOutput :: DelegateStaking ( _, _)
1522
1536
| TxOutput :: LockThenTransfer ( _, _, _)
1523
- | TxOutput :: CreateDelegationId ( _, _)
1524
- | TxOutput :: IssueFungibleToken ( _)
1525
- | TxOutput :: Htlc ( _, _)
1526
- | TxOutput :: CreateOrder ( _) => { }
1537
+ | TxOutput :: Htlc ( _, _) => { }
1527
1538
}
1528
1539
}
1540
+
1541
+ Ok ( ( ) )
1529
1542
}
1530
1543
1531
1544
/// Mark a transaction and its descendants as abandoned
@@ -1562,7 +1575,7 @@ impl OutputCache {
1562
1575
}
1563
1576
1564
1577
for tx in txs_to_rollback {
1565
- self . rollback_tx_data ( & tx) ;
1578
+ self . rollback_tx_data ( & tx) ? ;
1566
1579
}
1567
1580
1568
1581
Ok ( all_abandoned)
0 commit comments