sync and save wallet when closing ticket, fix NPE

This commit is contained in:
woodser 2022-12-27 07:19:49 +00:00
parent f2892d5157
commit c5f6aeb4cc
4 changed files with 16 additions and 8 deletions

View file

@ -280,9 +280,11 @@ public class XmrWalletService {
public MoneroTxWallet createTx(List<MoneroDestination> destinations) {
try {
MoneroTxWallet tx = wallet.createTx(new MoneroTxConfig().setAccountIndex(0).setDestinations(destinations).setRelay(false).setCanSplit(false));
//printTxs("XmrWalletService.createTx", tx);
return tx;
synchronized (wallet) {
MoneroTxWallet tx = wallet.createTx(new MoneroTxConfig().setAccountIndex(0).setDestinations(destinations).setRelay(false).setCanSplit(false));
//printTxs("XmrWalletService.createTx", tx);
return tx;
}
} catch (Exception e) {
throw e;
}

View file

@ -715,6 +715,10 @@ public abstract class DisputeManager<T extends DisputeList<Dispute>> extends Sup
return;
}
// sync and save wallet
trade.syncWallet();
trade.saveWallet();
// create unsigned dispute payout tx if not already published and arbitrator has trader's updated multisig info
TradingPeer receiver = trade.getTradingPeer(dispute.getTraderPubKeyRing());
if (!trade.isPayoutPublished() && receiver.getUpdatedMultisigHex() != null) {
@ -726,10 +730,12 @@ public abstract class DisputeManager<T extends DisputeList<Dispute>> extends Sup
if (trade.getSeller().getUpdatedMultisigHex() != null) updatedMultisigHexes.add(trade.getSeller().getUpdatedMultisigHex());
if (!updatedMultisigHexes.isEmpty()) {
multisigWallet.importMultisigHex(updatedMultisigHexes.toArray(new String[0])); // TODO (monero-project): fails if multisig hex imported individually
trade.syncWallet();
trade.saveWallet();
}
// sync and save wallet
trade.syncWallet();
trade.saveWallet();
// create unsigned dispute payout tx
if (!trade.isPayoutPublished()) {
log.info("Arbitrator creating unsigned dispute payout tx for trade {}", trade.getId());

View file

@ -135,8 +135,7 @@ public final class TradingPeer implements PersistablePayload {
@Override
public Message toProtoMessage() {
final protobuf.TradingPeer.Builder builder = protobuf.TradingPeer.newBuilder()
.setChangeOutputValue(changeOutputValue)
.addAllReserveTxKeyImages(reserveTxKeyImages);
.setChangeOutputValue(changeOutputValue);
Optional.ofNullable(nodeAddress).ifPresent(e -> builder.setNodeAddress(nodeAddress.toProtoMessage()));
Optional.ofNullable(pubKeyRing).ifPresent(e -> builder.setPubKeyRing(pubKeyRing.toProtoMessage()));
Optional.ofNullable(accountId).ifPresent(builder::setAccountId);
@ -160,6 +159,7 @@ public final class TradingPeer implements PersistablePayload {
Optional.ofNullable(reserveTxHash).ifPresent(e -> builder.setReserveTxHash(reserveTxHash));
Optional.ofNullable(reserveTxHex).ifPresent(e -> builder.setReserveTxHex(reserveTxHex));
Optional.ofNullable(reserveTxKey).ifPresent(e -> builder.setReserveTxKey(reserveTxKey));
Optional.ofNullable(reserveTxKeyImages).ifPresent(e -> builder.addAllReserveTxKeyImages(reserveTxKeyImages));
Optional.ofNullable(preparedMultisigHex).ifPresent(e -> builder.setPreparedMultisigHex(preparedMultisigHex));
Optional.ofNullable(madeMultisigHex).ifPresent(e -> builder.setMadeMultisigHex(madeMultisigHex));
Optional.ofNullable(exchangedMultisigHex).ifPresent(e -> builder.setExchangedMultisigHex(exchangedMultisigHex));

View file

@ -145,7 +145,7 @@ public class GrpcDisputesService extends DisputesImplBase {
return getCustomRateMeteringInterceptor(coreApi.getConfig().appDataDir, this.getClass())
.or(() -> Optional.of(CallRateMeteringInterceptor.valueOf(
new HashMap<>() {{
put(getGetDisputeMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
put(getGetDisputeMethod().getFullMethodName(), new GrpcCallRateMeter(20, SECONDS));
put(getGetDisputesMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
put(getResolveDisputeMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));
put(getOpenDisputeMethod().getFullMethodName(), new GrpcCallRateMeter(10, SECONDS));