fix(wallet) don't delete pending transactions for multi-transaction

This is done in Nim after the watched pending transaction changes state.

Note: tried to delete all transactions, not only multi-transaction,
as soon as the state is downloaded but it didn't work: noticed crashes
with minted transactions after restart.

Updates status-desktop #10474
This commit is contained in:
Stefan 2023-04-28 12:02:04 +03:00 committed by Stefan Dunca
parent 8a95dab5eb
commit c5a8b40d9c
1 changed files with 7 additions and 18 deletions

View File

@ -362,26 +362,15 @@ func (c *transfersCommand) Run(ctx context.Context) (err error) {
// Update MultiTransactionID from pending entry // Update MultiTransactionID from pending entry
for index := range allTransfers { for index := range allTransfers {
transfer := &allTransfers[index] transfer := &allTransfers[index]
if transfer.MultiTransactionID == NoMultiTransactionID {
entry, err := c.transactionManager.GetPendingEntry(c.chainClient.ChainID, transfer.ID) entry, err := c.transactionManager.GetPendingEntry(c.chainClient.ChainID, transfer.ID)
if err != nil { if err == nil {
if err == sql.ErrNoRows { // Propagate the MultiTransactionID, in case the pending entry was a multi-transaction
log.Info("Pending transaction not found for", "chainID", c.chainClient.ChainID, "transferID", transfer.ID)
} else {
return err
}
} else {
transfer.MultiTransactionID = entry.MultiTransactionID transfer.MultiTransactionID = entry.MultiTransactionID
if transfer.Receipt != nil && transfer.Receipt.Status == types.ReceiptStatusSuccessful { } else if err != sql.ErrNoRows {
// TODO: Nim logic was deleting pending previously, should we notify UI about it? log.Error("GetPendingEntry error", "error", err)
err := c.transactionManager.DeletePending(c.chainClient.ChainID, transfer.ID)
if err != nil {
return err return err
} }
} }
}
}
}
if len(allTransfers) > 0 { if len(allTransfers) > 0 {
err = c.db.SaveTransfersMarkBlocksLoaded(c.chainClient.ChainID, c.address, allTransfers, []*big.Int{c.block}) err = c.db.SaveTransfersMarkBlocksLoaded(c.chainClient.ChainID, c.address, allTransfers, []*big.Int{c.block})