diff --git a/client/asset/btc/btc.go b/client/asset/btc/btc.go index 478ac79fa6..a2ce396eec 100644 --- a/client/asset/btc/btc.go +++ b/client/asset/btc/btc.go @@ -2168,9 +2168,14 @@ func (btc *baseWallet) ReturnCoins(unspents asset.Coins) error { return fmt.Errorf("error converting coin: %w", err) } ops = append(ops, op) + } + if err := btc.node.lockUnspent(true, ops); err != nil { + return err // could it have unlocked some of them? we may want to loop instead if that's the case + } + for _, op := range ops { delete(btc.fundingCoins, op.pt) } - return btc.node.lockUnspent(true, ops) + return nil } // rawWalletTx gets the raw bytes of a transaction and the number of diff --git a/client/asset/dcr/dcr.go b/client/asset/dcr/dcr.go index 32577033ef..aa6c0807e9 100644 --- a/client/asset/dcr/dcr.go +++ b/client/asset/dcr/dcr.go @@ -1921,14 +1921,21 @@ func (dcr *ExchangeWallet) returnCoins(unspents asset.Coins) ([]*fundingCoin, er ops = append(ops, op.wireOutPoint()) // op.tree may be wire.TxTreeUnknown, but that's fine since wallet.LockUnspent doesn't rely on it if fCoin, ok := dcr.fundingCoins[op.pt]; ok { fundingCoins = append(fundingCoins, fCoin) - delete(dcr.fundingCoins, op.pt) } else { dcr.log.Warnf("returning coin %s that is not cached as a funding coin", op) fundingCoins = append(fundingCoins, &fundingCoin{op: op}) } } - return fundingCoins, dcr.wallet.LockUnspent(dcr.ctx, true, ops) + if err := dcr.wallet.LockUnspent(dcr.ctx, true, ops); err != nil { + return nil, err + } + + for _, fCoin := range fundingCoins { + delete(dcr.fundingCoins, fCoin.op.pt) + } + + return fundingCoins, nil } // FundingCoins gets funding coins for the coin IDs. The coins are locked. This