reset address entries for open offer on error taking offer

This commit is contained in:
woodser 2023-12-17 07:38:48 -05:00
parent 30e199c56e
commit dffb676f4e
4 changed files with 3 additions and 13 deletions

View File

@ -1007,13 +1007,14 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
xmrWalletService.swapAddressEntryToAvailable(openOffer.getId(), XmrAddressEntry.Context.OFFER_FUNDING); // change funding subaddress in case funded with unsuitable output(s)
XmrAddressEntry entry = xmrWalletService.getOrCreateAddressEntry(openOffer.getId(), XmrAddressEntry.Context.OFFER_FUNDING);
log.info("Creating split output tx to fund offer {} at subaddress {}", openOffer.getId(), entry.getSubaddressIndex());
long startTime = System.currentTimeMillis();
MoneroTxWallet splitOutputTx = xmrWalletService.getWallet().createTx(new MoneroTxConfig()
.setAccountIndex(0)
.setAddress(entry.getAddressString())
.setAmount(reserveAmount)
.setRelay(true)
.setPriority(XmrWalletService.PROTOCOL_FEE_PRIORITY));
log.info("Done creating split output tx to fund offer {}", openOffer.getId());
log.info("Done creating split output tx to fund offer {} in {} ms", openOffer.getId(), System.currentTimeMillis() - startTime);
// schedule txs
openOffer.setSplitOutputTxHash(splitOutputTx.getHash());

View File

@ -878,6 +878,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
requestPersistence();
}, errorMessage -> {
log.warn("Taker error during trade initialization: " + errorMessage);
xmrWalletService.resetAddressEntriesForOpenOffer(trade.getId());
maybeRemoveTradeOnError(trade);
errorMessageHandler.handleErrorMessage(errorMessage);
if (takeOfferRequestErrorMessageHandler != null) takeOfferRequestErrorMessageHandler.handleErrorMessage(errorMessage);

View File

@ -73,10 +73,4 @@ public class BuyerAsTakerProtocol extends BuyerProtocol implements TakerProtocol
}
}).start();
}
@Override
protected void handleError(String errorMessage) {
trade.getXmrWalletService().resetAddressEntriesForOpenOffer(trade.getId());
super.handleError(errorMessage);
}
}

View File

@ -74,10 +74,4 @@ public class SellerAsTakerProtocol extends SellerProtocol implements TakerProtoc
}
}).start();
}
@Override
protected void handleError(String errorMessage) {
trade.getXmrWalletService().resetAddressEntriesForOpenOffer(trade.getId());
super.handleError(errorMessage);
}
}