refactoring based on congestion testing

retry creating and processing trade txs on failure
do not use connection manager polling to reduce requests
use global daemon lock for wallet sync operations
sync wallets on poll if behind
use local util to get payment uri to avoid blocking
all peers share multisig hex on deposits confirmed
import multisig hex when needed
This commit is contained in:
woodser 2024-04-29 07:02:05 -04:00
parent f519ac12a5
commit e63141279c
36 changed files with 799 additions and 568 deletions

View file

@ -91,6 +91,7 @@ import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.util.Callback;
import monero.common.MoneroUtils;
import monero.wallet.model.MoneroTxConfig;
import monero.wallet.model.MoneroWalletListener;
import net.glxn.qrgen.QRCode;
@ -365,7 +366,7 @@ public class DepositView extends ActivatableView<VBox, Void> {
@NotNull
private String getPaymentUri() {
return xmrWalletService.getWallet().getPaymentUri(new MoneroTxConfig()
return MoneroUtils.getPaymentUri(new MoneroTxConfig()
.setAddress(addressTextField.getAddress())
.setAmount(HavenoUtils.coinToAtomicUnits(getAmount()))
.setNote(paymentLabelString));

View file

@ -261,7 +261,7 @@ public class WithdrawalView extends ActivatableView<VBox, Void> {
// create tx
if (amount.compareTo(BigInteger.ZERO) <= 0) throw new RuntimeException(Res.get("portfolio.pending.step5_buyer.amountTooLow"));
MoneroTxWallet tx = xmrWalletService.getWallet().createTx(new MoneroTxConfig()
MoneroTxWallet tx = xmrWalletService.createTx(new MoneroTxConfig()
.setAccountIndex(0)
.setAmount(amount)
.setAddress(withdrawToAddress)

View file

@ -613,10 +613,12 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
if (offer.getState() == Offer.State.OFFER_FEE_RESERVED) errorMessage.set(errMessage + Res.get("createOffer.errorInfo"));
else errorMessage.set(errMessage);
updateButtonDisableState();
updateSpinnerInfo();
UserThread.execute(() -> {
updateButtonDisableState();
updateSpinnerInfo();
resultHandler.run();
resultHandler.run();
});
});
updateButtonDisableState();

View file

@ -21,6 +21,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import haveno.common.ClockWatcher;
import haveno.common.UserThread;
import haveno.common.app.DevEnv;
import haveno.core.account.witness.AccountAgeWitnessService;
import haveno.core.network.MessageState;
@ -101,6 +102,7 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
@Getter
private final ObjectProperty<MessageState> messageStateProperty = new SimpleObjectProperty<>(MessageState.UNDEFINED);
private Subscription tradeStateSubscription;
private Subscription paymentAccountDecryptedSubscription;
private Subscription payoutStateSubscription;
private Subscription messageStateSubscription;
@Getter
@ -146,6 +148,11 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
tradeStateSubscription = null;
}
if (paymentAccountDecryptedSubscription != null) {
paymentAccountDecryptedSubscription.unsubscribe();
paymentAccountDecryptedSubscription = null;
}
if (payoutStateSubscription != null) {
payoutStateSubscription.unsubscribe();
payoutStateSubscription = null;
@ -167,6 +174,10 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
buyerState.set(BuyerState.UNDEFINED);
}
if (paymentAccountDecryptedSubscription != null) {
paymentAccountDecryptedSubscription.unsubscribe();
}
if (payoutStateSubscription != null) {
payoutStateSubscription.unsubscribe();
sellerState.set(SellerState.UNDEFINED);
@ -183,6 +194,9 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
tradeStateSubscription = EasyBind.subscribe(trade.stateProperty(), state -> {
onTradeStateChanged(state);
});
paymentAccountDecryptedSubscription = EasyBind.subscribe(trade.getProcessModel().getPaymentAccountDecryptedProperty(), decrypted -> {
refresh();
});
payoutStateSubscription = EasyBind.subscribe(trade.payoutStateProperty(), state -> {
onPayoutStateChanged(state);
});
@ -191,6 +205,14 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
}
}
private void refresh() {
UserThread.execute(() -> {
sellerState.set(UNDEFINED);
buyerState.set(BuyerState.UNDEFINED);
onTradeStateChanged(trade.getState());
});
}
private void onMessageStateChanged(MessageState messageState) {
messageStateProperty.set(messageState);
}

View file

@ -221,7 +221,7 @@ public class BuyerStep2View extends TradeStepView {
PaymentAccountPayload paymentAccountPayload = model.dataModel.getSellersPaymentAccountPayload();
String paymentMethodId = paymentAccountPayload != null ? paymentAccountPayload.getPaymentMethodId() : "<missing payment account payload>";
String paymentMethodId = paymentAccountPayload != null ? paymentAccountPayload.getPaymentMethodId() : "<pending>";
TitledGroupBg accountTitledGroupBg = addTitledGroupBg(gridPane, ++gridRow, 4,
Res.get("portfolio.pending.step2_buyer.startPaymentUsing", Res.get(paymentMethodId)),
Layout.COMPACT_GROUP_DISTANCE);

View file

@ -93,6 +93,7 @@ import javafx.stage.StageStyle;
import javafx.util.Callback;
import javafx.util.StringConverter;
import lombok.extern.slf4j.Slf4j;
import monero.common.MoneroUtils;
import monero.daemon.model.MoneroTx;
import monero.wallet.MoneroWallet;
import monero.wallet.model.MoneroTxConfig;
@ -686,7 +687,7 @@ public class GUIUtil {
}
public static String getMoneroURI(String address, BigInteger amount, String label, MoneroWallet wallet) {
return wallet.getPaymentUri(new MoneroTxConfig()
return MoneroUtils.getPaymentUri(new MoneroTxConfig()
.setAddress(address)
.setAmount(amount)
.setNote(label));