mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-25 15:29:23 -05:00
create split output tx only once on error
This commit is contained in:
parent
b3c607152d
commit
39b8afa528
@ -828,7 +828,6 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
|||||||
MoneroTxWallet splitOutputTx = findSplitOutputFundingTx(openOffers, openOffer);
|
MoneroTxWallet splitOutputTx = findSplitOutputFundingTx(openOffers, openOffer);
|
||||||
if (splitOutputTx != null && openOffer.getScheduledTxHashes() == null) {
|
if (splitOutputTx != null && openOffer.getScheduledTxHashes() == null) {
|
||||||
openOffer.setScheduledTxHashes(Arrays.asList(splitOutputTx.getHash()));
|
openOffer.setScheduledTxHashes(Arrays.asList(splitOutputTx.getHash()));
|
||||||
openOffer.setSplitOutputTxHash(splitOutputTx.getHash());
|
|
||||||
openOffer.setScheduledAmount(offerReserveAmount.toString());
|
openOffer.setScheduledAmount(offerReserveAmount.toString());
|
||||||
openOffer.setState(OpenOffer.State.SCHEDULED);
|
openOffer.setState(OpenOffer.State.SCHEDULED);
|
||||||
}
|
}
|
||||||
@ -841,10 +840,10 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
|||||||
// otherwise sign and post offer if split output available
|
// otherwise sign and post offer if split output available
|
||||||
signAndPostOffer(openOffer, true, resultHandler, (errMsg) -> {
|
signAndPostOffer(openOffer, true, resultHandler, (errMsg) -> {
|
||||||
|
|
||||||
// on error, create new tx to split output if offer subaddress does not have exact output
|
// on error, create split output tx if not already created
|
||||||
int offerSubaddress = xmrWalletService.getOrCreateAddressEntry(openOffer.getId(), XmrAddressEntry.Context.OFFER_FUNDING).getSubaddressIndex();
|
if (openOffer.getSplitOutputTxHash() == null) {
|
||||||
if (!splitOutputTx.getOutgoingTransfer().getSubaddressIndices().equals(Arrays.asList(offerSubaddress))) {
|
int offerSubaddress = xmrWalletService.getOrCreateAddressEntry(openOffer.getId(), XmrAddressEntry.Context.OFFER_FUNDING).getSubaddressIndex();
|
||||||
log.warn("Splitting new output because spending existing output(s) failed for offer {}. Split output tx subaddresses={}. Offer funding subadress={}", openOffer.getId(), splitOutputTx.getOutgoingTransfer().getSubaddressIndices(), offerSubaddress);
|
log.warn("Splitting new output because spending scheduled output(s) failed for offer {}. Split output tx subaddresses={}. Offer funding subadress={}", openOffer.getId(), splitOutputTx.getOutgoingTransfer().getSubaddressIndices(), offerSubaddress);
|
||||||
splitOrSchedule(openOffers, openOffer, offerReserveAmount);
|
splitOrSchedule(openOffers, openOffer, offerReserveAmount);
|
||||||
resultHandler.handleResult(null);
|
resultHandler.handleResult(null);
|
||||||
} else {
|
} else {
|
||||||
@ -883,7 +882,12 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
|||||||
List<MoneroTxWallet> fundingTxs = new ArrayList<>();
|
List<MoneroTxWallet> fundingTxs = new ArrayList<>();
|
||||||
MoneroTxWallet earliestUnscheduledTx = null;
|
MoneroTxWallet earliestUnscheduledTx = null;
|
||||||
|
|
||||||
// return earliest tx with exact confirmed output to given subaddress if available
|
// return split output tx if already assigned
|
||||||
|
if (openOffer != null && openOffer.getSplitOutputTxHash() != null) {
|
||||||
|
return xmrWalletService.getWallet().getTx(openOffer.getSplitOutputTxHash());
|
||||||
|
}
|
||||||
|
|
||||||
|
// return earliest tx with exact amount to offer's subaddress if available
|
||||||
if (preferredSubaddressIndex != null) {
|
if (preferredSubaddressIndex != null) {
|
||||||
|
|
||||||
// get txs with exact output amount
|
// get txs with exact output amount
|
||||||
@ -901,9 +905,9 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
|||||||
if (earliestUnscheduledTx != null) return earliestUnscheduledTx;
|
if (earliestUnscheduledTx != null) return earliestUnscheduledTx;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return split output tx if already assigned
|
// return scheduled tx if already assigned
|
||||||
if (openOffer != null && openOffer.getSplitOutputTxHash() != null) {
|
if (openOffer.getScheduledTxHashes() != null) {
|
||||||
return xmrWalletService.getWallet().getTx(openOffer.getSplitOutputTxHash());
|
return xmrWalletService.getWallet().getTx(openOffer.getScheduledTxHashes().get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// cache all transactions including from pool
|
// cache all transactions including from pool
|
||||||
|
Loading…
Reference in New Issue
Block a user