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