mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-14 17:35:27 -04:00
refactor trade protocol error handling and wallet deletion
This commit is contained in:
parent
b034ac8c13
commit
6fb846d783
10 changed files with 233 additions and 205 deletions
|
@ -549,11 +549,20 @@ public class XmrWalletService {
|
|||
/**
|
||||
* Freeze the given outputs with a lock on the wallet.
|
||||
*
|
||||
* @param keyImages the key images to freeze
|
||||
* @param keyImages the key images to freeze (ignored if null or empty)
|
||||
*/
|
||||
public void freezeOutputs(Collection<String> keyImages) {
|
||||
if (keyImages == null || keyImages.isEmpty()) return;
|
||||
synchronized (WALLET_LOCK) {
|
||||
for (String keyImage : keyImages) wallet.freezeOutput(keyImage);
|
||||
|
||||
// collect outputs to freeze
|
||||
List<String> unfrozenKeyImages = getOutputs(new MoneroOutputQuery().setIsFrozen(false).setIsSpent(false)).stream()
|
||||
.map(output -> output.getKeyImage().getHex())
|
||||
.collect(Collectors.toList());
|
||||
unfrozenKeyImages.retainAll(keyImages);
|
||||
|
||||
// freeze outputs
|
||||
for (String keyImage : unfrozenKeyImages) wallet.freezeOutput(keyImage);
|
||||
cacheWalletInfo();
|
||||
requestSaveMainWallet();
|
||||
}
|
||||
|
@ -567,7 +576,15 @@ public class XmrWalletService {
|
|||
public void thawOutputs(Collection<String> keyImages) {
|
||||
if (keyImages == null || keyImages.isEmpty()) return;
|
||||
synchronized (WALLET_LOCK) {
|
||||
for (String keyImage : keyImages) wallet.thawOutput(keyImage);
|
||||
|
||||
// collect outputs to thaw
|
||||
List<String> frozenKeyImages = getOutputs(new MoneroOutputQuery().setIsFrozen(true).setIsSpent(false)).stream()
|
||||
.map(output -> output.getKeyImage().getHex())
|
||||
.collect(Collectors.toList());
|
||||
frozenKeyImages.retainAll(keyImages);
|
||||
|
||||
// thaw outputs
|
||||
for (String keyImage : frozenKeyImages) wallet.thawOutput(keyImage);
|
||||
cacheWalletInfo();
|
||||
requestSaveMainWallet();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue