Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define proto for api method 'sendbsq' #4796

Merged
merged 4 commits into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions core/src/main/java/bisq/core/api/model/BalancesInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package bisq.core.api.model;

import bisq.common.Payload;

import lombok.Getter;

@Getter
public class BalancesInfo implements Payload {

private final BsqBalanceInfo bsqBalanceInfo;
private final BtcBalanceInfo btcBalanceInfo;

public BalancesInfo(BsqBalanceInfo bsqBalanceInfo, BtcBalanceInfo btcBalanceInfo) {
this.bsqBalanceInfo = bsqBalanceInfo;
this.btcBalanceInfo = btcBalanceInfo;
}

///////////////////////////////////////////////////////////////////////////////////////////
// PROTO BUFFER
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public bisq.proto.grpc.BalancesInfo toProtoMessage() {
return bisq.proto.grpc.BalancesInfo.newBuilder()
.setBsqBalanceInfo(bsqBalanceInfo.toProtoMessage())
.setBtcBalanceInfo(btcBalanceInfo.toProtoMessage())
.build();
}

public static BalancesInfo fromProto(bisq.proto.grpc.BalancesInfo proto) {
return new BalancesInfo(BsqBalanceInfo.fromProto(proto.getBsqBalanceInfo()),
BtcBalanceInfo.fromProto(proto.getBtcBalanceInfo()));
}

@Override
public String toString() {
return "BalancesInfo{" + "\n" +
" " + bsqBalanceInfo.toString() + "\n" +
", " + btcBalanceInfo.toString() + "\n" +
'}';
}
}
87 changes: 87 additions & 0 deletions core/src/main/java/bisq/core/api/model/BsqBalanceInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package bisq.core.api.model;

import bisq.common.Payload;

import com.google.common.annotations.VisibleForTesting;

import lombok.Getter;

@Getter
public class BsqBalanceInfo implements Payload {

// All balances are in BSQ satoshis.
private final long availableConfirmedBalance;
private final long unverifiedBalance;
private final long unconfirmedChangeBalance;
private final long lockedForVotingBalance;
private final long lockupBondsBalance;
private final long unlockingBondsBalance;

public BsqBalanceInfo(long availableConfirmedBalance,
long unverifiedBalance,
long unconfirmedChangeBalance,
long lockedForVotingBalance,
long lockupBondsBalance,
long unlockingBondsBalance) {
this.availableConfirmedBalance = availableConfirmedBalance;
this.unverifiedBalance = unverifiedBalance;
this.unconfirmedChangeBalance = unconfirmedChangeBalance;
this.lockedForVotingBalance = lockedForVotingBalance;
this.lockupBondsBalance = lockupBondsBalance;
this.unlockingBondsBalance = unlockingBondsBalance;
}

@VisibleForTesting
public static BsqBalanceInfo valueOf(long availableConfirmedBalance,
long unverifiedBalance,
long unconfirmedChangeBalance,
long lockedForVotingBalance,
long lockupBondsBalance,
long unlockingBondsBalance) {
// Convenience for creating a model instance instead of a proto.
return new BsqBalanceInfo(availableConfirmedBalance,
unverifiedBalance,
unconfirmedChangeBalance,
lockedForVotingBalance,
lockupBondsBalance,
unlockingBondsBalance);
}

///////////////////////////////////////////////////////////////////////////////////////////
// PROTO BUFFER
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public bisq.proto.grpc.BsqBalanceInfo toProtoMessage() {
return bisq.proto.grpc.BsqBalanceInfo.newBuilder()
.setAvailableConfirmedBalance(availableConfirmedBalance)
.setUnverifiedBalance(unverifiedBalance)
.setUnconfirmedChangeBalance(unconfirmedChangeBalance)
.setLockedForVotingBalance(lockedForVotingBalance)
.setLockupBondsBalance(lockupBondsBalance)
.setUnlockingBondsBalance(unlockingBondsBalance)
.build();

}

public static BsqBalanceInfo fromProto(bisq.proto.grpc.BsqBalanceInfo proto) {
return new BsqBalanceInfo(proto.getAvailableConfirmedBalance(),
proto.getUnverifiedBalance(),
proto.getUnconfirmedChangeBalance(),
proto.getLockedForVotingBalance(),
proto.getLockupBondsBalance(),
proto.getUnlockingBondsBalance());
}

@Override
public String toString() {
return "BsqBalanceInfo{" +
"availableConfirmedBalance=" + availableConfirmedBalance +
", unverifiedBalance=" + unverifiedBalance +
", unconfirmedChangeBalance=" + unconfirmedChangeBalance +
", lockedForVotingBalance=" + lockedForVotingBalance +
", lockupBondsBalance=" + lockupBondsBalance +
", unlockingBondsBalance=" + unlockingBondsBalance +
'}';
}
}
70 changes: 70 additions & 0 deletions core/src/main/java/bisq/core/api/model/BtcBalanceInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package bisq.core.api.model;

import bisq.common.Payload;

import com.google.common.annotations.VisibleForTesting;

import lombok.Getter;

@Getter
public class BtcBalanceInfo implements Payload {

// All balances are in BTC satoshis.
private final long availableBalance;
private final long reservedBalance;
private final long totalAvailableBalance; // available + reserved
private final long lockedBalance;

public BtcBalanceInfo(long availableBalance,
long reservedBalance,
long totalAvailableBalance,
long lockedBalance) {
this.availableBalance = availableBalance;
this.reservedBalance = reservedBalance;
this.totalAvailableBalance = totalAvailableBalance;
this.lockedBalance = lockedBalance;
}

@VisibleForTesting
public static BtcBalanceInfo valueOf(long availableBalance,
long reservedBalance,
long totalAvailableBalance,
long lockedBalance) {
// Convenience for creating a model instance instead of a proto.
return new BtcBalanceInfo(availableBalance,
reservedBalance,
totalAvailableBalance,
lockedBalance);
}

///////////////////////////////////////////////////////////////////////////////////////////
// PROTO BUFFER
///////////////////////////////////////////////////////////////////////////////////////////

@Override
public bisq.proto.grpc.BtcBalanceInfo toProtoMessage() {
return bisq.proto.grpc.BtcBalanceInfo.newBuilder()
.setAvailableBalance(availableBalance)
.setReservedBalance(reservedBalance)
.setTotalAvailableBalance(totalAvailableBalance)
.setLockedBalance(lockedBalance)
.build();
}

public static BtcBalanceInfo fromProto(bisq.proto.grpc.BtcBalanceInfo proto) {
return new BtcBalanceInfo(proto.getAvailableBalance(),
proto.getReservedBalance(),
proto.getTotalAvailableBalance(),
proto.getLockedBalance());
}

@Override
public String toString() {
return "BtcBalanceInfo{" +
"availableBalance=" + availableBalance +
", reservedBalance=" + reservedBalance +
", totalAvailableBalance=" + totalAvailableBalance +
", lockedBalance=" + lockedBalance +
'}';
}
}
67 changes: 67 additions & 0 deletions proto/src/main/proto/grpc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,18 @@ message TradeInfo {
service Wallets {
rpc GetBalance (GetBalanceRequest) returns (GetBalanceReply) {
}
rpc GetBalances (GetBalancesRequest) returns (GetBalancesReply) {
}
rpc GetBsqBalances (GetBsqBalancesRequest) returns (GetBsqBalancesReply) {
}
rpc GetBtcBalances (GetBtcBalancesRequest) returns (GetBtcBalancesReply) {
}
rpc GetAddressBalance (GetAddressBalanceRequest) returns (GetAddressBalanceReply) {
}
rpc GetUnusedBsqAddress (GetUnusedBsqAddressRequest) returns (GetUnusedBsqAddressReply) {
}
rpc SendBsq (SendBsqRequest) returns (SendBsqReply) {
}
rpc GetFundingAddresses (GetFundingAddressesRequest) returns (GetFundingAddressesReply) {
}
rpc SetWalletPassword (SetWalletPasswordRequest) returns (SetWalletPasswordReply) {
Expand All @@ -296,6 +306,27 @@ message GetBalanceReply {
uint64 balance = 1;
}

message GetBalancesRequest {
}

message GetBalancesReply {
BalancesInfo balances = 1;
}

message GetBsqBalancesRequest {
}

message GetBsqBalancesReply {
BsqBalanceInfo bsqBalanceInfo = 1;
}

message GetBtcBalancesRequest {
}

message GetBtcBalancesReply {
BtcBalanceInfo btcBalanceInfo = 1;
}

message GetAddressBalanceRequest {
string address = 1;
}
Expand All @@ -304,6 +335,21 @@ message GetAddressBalanceReply {
AddressBalanceInfo addressBalanceInfo = 1;
}

message GetUnusedBsqAddressRequest {
}

message GetUnusedBsqAddressReply {
string address = 1;
}

message SendBsqRequest {
string address = 1;
double amount = 2;
}

message SendBsqReply {
}

message GetFundingAddressesRequest {
}

Expand Down Expand Up @@ -340,6 +386,27 @@ message UnlockWalletRequest {
message UnlockWalletReply {
}

message BalancesInfo {
BsqBalanceInfo bsqBalanceInfo = 1;
BtcBalanceInfo btcBalanceInfo = 2;
}

message BsqBalanceInfo {
uint64 availableConfirmedBalance = 1;
uint64 unverifiedBalance = 2;
uint64 unconfirmedChangeBalance = 3;
uint64 lockedForVotingBalance = 4;
uint64 lockupBondsBalance = 5;
uint64 unlockingBondsBalance = 6;
}

message BtcBalanceInfo {
uint64 availableBalance = 1;
uint64 reservedBalance = 2;
uint64 totalAvailableBalance = 3;
uint64 lockedBalance = 4;
}

message AddressBalanceInfo {
string address = 1;
int64 balance = 2;
Expand Down