mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-10-01 01:35:48 -04:00
add balance to xmr balances
reduce trade api rate limiting offer is set to available
This commit is contained in:
parent
f08c2036a7
commit
469c47b0c7
@ -543,7 +543,8 @@ class CoreWalletsService {
|
||||
if (reservedTradeBalance == null)
|
||||
throw new IllegalStateException("reserved trade balance is not yet available");
|
||||
|
||||
return new XmrBalanceInfo(availableBalance.longValue(),
|
||||
return new XmrBalanceInfo(availableBalance.longValue() + lockedBalance.longValue(),
|
||||
availableBalance.longValue(),
|
||||
lockedBalance.longValue(),
|
||||
reservedOfferBalance.longValue(),
|
||||
reservedTradeBalance.longValue());
|
||||
|
@ -10,20 +10,24 @@ import lombok.Getter;
|
||||
public class XmrBalanceInfo implements Payload {
|
||||
|
||||
public static final XmrBalanceInfo EMPTY = new XmrBalanceInfo(-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1);
|
||||
|
||||
// all balances are in atomic units
|
||||
private final long balance;
|
||||
private final long unlockedBalance;
|
||||
private final long lockedBalance;
|
||||
private final long reservedOfferBalance;
|
||||
private final long reservedTradeBalance;
|
||||
|
||||
public XmrBalanceInfo(long unlockedBalance,
|
||||
public XmrBalanceInfo(long balance,
|
||||
long unlockedBalance,
|
||||
long lockedBalance,
|
||||
long reservedOfferBalance,
|
||||
long reservedTradeBalance) {
|
||||
this.balance = balance;
|
||||
this.unlockedBalance = unlockedBalance;
|
||||
this.lockedBalance = lockedBalance;
|
||||
this.reservedOfferBalance = reservedOfferBalance;
|
||||
@ -31,11 +35,13 @@ public class XmrBalanceInfo implements Payload {
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public static XmrBalanceInfo valueOf(long unlockedBalance,
|
||||
public static XmrBalanceInfo valueOf(long balance,
|
||||
long unlockedBalance,
|
||||
long lockedBalance,
|
||||
long reservedOfferBalance,
|
||||
long reservedTradeBalance) {
|
||||
return new XmrBalanceInfo(unlockedBalance,
|
||||
return new XmrBalanceInfo(balance,
|
||||
unlockedBalance,
|
||||
lockedBalance,
|
||||
reservedOfferBalance,
|
||||
reservedTradeBalance);
|
||||
@ -48,6 +54,7 @@ public class XmrBalanceInfo implements Payload {
|
||||
@Override
|
||||
public bisq.proto.grpc.XmrBalanceInfo toProtoMessage() {
|
||||
return bisq.proto.grpc.XmrBalanceInfo.newBuilder()
|
||||
.setBalance(balance)
|
||||
.setUnlockedBalance(unlockedBalance)
|
||||
.setLockedBalance(lockedBalance)
|
||||
.setReservedOfferBalance(reservedOfferBalance)
|
||||
@ -56,7 +63,8 @@ public class XmrBalanceInfo implements Payload {
|
||||
}
|
||||
|
||||
public static XmrBalanceInfo fromProto(bisq.proto.grpc.XmrBalanceInfo proto) {
|
||||
return new XmrBalanceInfo(proto.getUnlockedBalance(),
|
||||
return new XmrBalanceInfo(proto.getBalance(),
|
||||
proto.getUnlockedBalance(),
|
||||
proto.getLockedBalance(),
|
||||
proto.getReservedOfferBalance(),
|
||||
proto.getReservedTradeBalance());
|
||||
@ -64,7 +72,8 @@ public class XmrBalanceInfo implements Payload {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BtcBalanceInfo{" +
|
||||
return "XmrBalanceInfo{" +
|
||||
"balance=" + balance +
|
||||
"unlockedBalance=" + unlockedBalance +
|
||||
", lockedBalance=" + lockedBalance +
|
||||
", reservedOfferBalance=" + reservedOfferBalance +
|
||||
|
@ -46,7 +46,7 @@ public class MakerProcessesSignOfferResponse extends Task<PlaceOfferModel> {
|
||||
|
||||
// set arbitrator signature for maker's offer
|
||||
model.getOffer().getOfferPayload().setArbitratorSignature(model.getSignOfferResponse().getSignedOfferPayload().getArbitratorSignature());
|
||||
|
||||
offer.setState(Offer.State.AVAILABLE);
|
||||
complete();
|
||||
} catch (Exception e) {
|
||||
offer.setErrorMessage("An error occurred.\n" +
|
||||
|
@ -65,7 +65,6 @@ public class MakerReservesTradeFunds extends Task<PlaceOfferModel> {
|
||||
model.setReserveTx(reserveTx);
|
||||
offer.getOfferPayload().setReserveTxKeyImages(reservedKeyImages);
|
||||
offer.setOfferFeePaymentTxId(reserveTx.getHash()); // TODO (woodser): don't use this field
|
||||
offer.setState(Offer.State.OFFER_FEE_RESERVED);
|
||||
complete();
|
||||
} catch (Throwable t) {
|
||||
offer.setErrorMessage("An error occurred.\n" +
|
||||
|
@ -74,6 +74,7 @@ public class MakerSendsSignOfferRequest extends Task<PlaceOfferModel> {
|
||||
model.getP2PService().sendEncryptedDirectMessage(arbitrator.getNodeAddress(), arbitrator.getPubKeyRing(), request, new SendDirectMessageListener() {
|
||||
@Override
|
||||
public void onArrived() {
|
||||
offer.setState(Offer.State.OFFER_FEE_RESERVED);
|
||||
log.info("{} arrived: arbitrator={}; offerId={}; uid={}", request.getClass().getSimpleName(), arbitrator.getNodeAddress(), offer.getId());
|
||||
complete();
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ class GrpcTradesService extends TradesImplBase {
|
||||
return getCustomRateMeteringInterceptor(coreApi.getConfig().appDataDir, this.getClass())
|
||||
.or(() -> Optional.of(CallRateMeteringInterceptor.valueOf(
|
||||
new HashMap<>() {{
|
||||
put(getGetTradeMethod().getFullMethodName(), new GrpcCallRateMeter(1, SECONDS));
|
||||
put(getGetTradeMethod().getFullMethodName(), new GrpcCallRateMeter(3, SECONDS));
|
||||
put(getTakeOfferMethod().getFullMethodName(), new GrpcCallRateMeter(1, SECONDS));
|
||||
put(getConfirmPaymentStartedMethod().getFullMethodName(), new GrpcCallRateMeter(1, SECONDS));
|
||||
put(getConfirmPaymentReceivedMethod().getFullMethodName(), new GrpcCallRateMeter(1, SECONDS));
|
||||
|
@ -570,10 +570,11 @@ message BtcBalanceInfo {
|
||||
}
|
||||
|
||||
message XmrBalanceInfo {
|
||||
uint64 unlocked_balance = 1 [jstype = JS_STRING];
|
||||
uint64 locked_balance = 2 [jstype = JS_STRING];
|
||||
uint64 reserved_offer_balance = 3 [jstype = JS_STRING];
|
||||
uint64 reserved_trade_balance = 4 [jstype = JS_STRING];
|
||||
uint64 balance = 1 [jstype = JS_STRING];
|
||||
uint64 unlocked_balance = 2 [jstype = JS_STRING];
|
||||
uint64 locked_balance = 3 [jstype = JS_STRING];
|
||||
uint64 reserved_offer_balance = 4 [jstype = JS_STRING];
|
||||
uint64 reserved_trade_balance = 5 [jstype = JS_STRING];
|
||||
}
|
||||
|
||||
message AddressBalanceInfo {
|
||||
|
Loading…
Reference in New Issue
Block a user