mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-31 02:39:08 -04:00
remove DAO
Co-authored-by: premek <1145361+premek@users.noreply.github.com>
This commit is contained in:
parent
f9f2cd07c3
commit
cefba8e4b5
621 changed files with 583 additions and 68805 deletions
|
@ -69,14 +69,12 @@ import bisq.cli.opts.GetTradeOptionParser;
|
|||
import bisq.cli.opts.GetTransactionOptionParser;
|
||||
import bisq.cli.opts.RegisterDisputeAgentOptionParser;
|
||||
import bisq.cli.opts.RemoveWalletPasswordOptionParser;
|
||||
import bisq.cli.opts.SendBsqOptionParser;
|
||||
import bisq.cli.opts.SendBtcOptionParser;
|
||||
import bisq.cli.opts.SetTxFeeRateOptionParser;
|
||||
import bisq.cli.opts.SetWalletPasswordOptionParser;
|
||||
import bisq.cli.opts.SimpleMethodOptionParser;
|
||||
import bisq.cli.opts.TakeOfferOptionParser;
|
||||
import bisq.cli.opts.UnlockWalletOptionParser;
|
||||
import bisq.cli.opts.VerifyBsqSentToAddressOptionParser;
|
||||
import bisq.cli.opts.WithdrawFundsOptionParser;
|
||||
|
||||
/**
|
||||
|
@ -168,9 +166,6 @@ public class CliMain {
|
|||
var currencyCode = opts.getCurrencyCode();
|
||||
var balances = client.getBalances(currencyCode);
|
||||
switch (currencyCode.toUpperCase()) {
|
||||
case "BSQ":
|
||||
out.println(formatBsqBalanceInfoTbl(balances.getBsq()));
|
||||
break;
|
||||
case "BTC":
|
||||
out.println(formatBtcBalanceInfoTbl(balances.getBtc()));
|
||||
break;
|
||||
|
@ -215,36 +210,6 @@ public class CliMain {
|
|||
out.println(formatAddressBalanceTbl(fundingAddresses));
|
||||
return;
|
||||
}
|
||||
case getunusedbsqaddress: {
|
||||
if (new SimpleMethodOptionParser(args).parse().isForHelp()) {
|
||||
out.println(client.getMethodHelp(method));
|
||||
return;
|
||||
}
|
||||
var address = client.getUnusedBsqAddress();
|
||||
out.println(address);
|
||||
return;
|
||||
}
|
||||
case sendbsq: {
|
||||
var opts = new SendBsqOptionParser(args).parse();
|
||||
if (opts.isForHelp()) {
|
||||
out.println(client.getMethodHelp(method));
|
||||
return;
|
||||
}
|
||||
var address = opts.getAddress();
|
||||
var amount = opts.getAmount();
|
||||
verifyStringIsValidDecimal(OPT_AMOUNT, amount);
|
||||
|
||||
var txFeeRate = opts.getFeeRate();
|
||||
if (!txFeeRate.isEmpty())
|
||||
verifyStringIsValidLong(OPT_TX_FEE_RATE, txFeeRate);
|
||||
|
||||
var txInfo = client.sendBsq(address, amount, txFeeRate);
|
||||
out.printf("%s bsq sent to %s in tx %s%n",
|
||||
amount,
|
||||
address,
|
||||
txInfo.getTxId());
|
||||
return;
|
||||
}
|
||||
case sendbtc: {
|
||||
var opts = new SendBtcOptionParser(args).parse();
|
||||
if (opts.isForHelp()) {
|
||||
|
@ -268,23 +233,6 @@ public class CliMain {
|
|||
txInfo.getTxId());
|
||||
return;
|
||||
}
|
||||
case verifybsqsenttoaddress: {
|
||||
var opts = new VerifyBsqSentToAddressOptionParser(args).parse();
|
||||
if (opts.isForHelp()) {
|
||||
out.println(client.getMethodHelp(method));
|
||||
return;
|
||||
}
|
||||
var address = opts.getAddress();
|
||||
var amount = opts.getAmount();
|
||||
verifyStringIsValidDecimal(OPT_AMOUNT, amount);
|
||||
|
||||
var bsqWasSent = client.verifyBsqSentToAddress(address, amount);
|
||||
out.printf("%s bsq %s sent to address %s%n",
|
||||
amount,
|
||||
bsqWasSent ? "has been" : "has not been",
|
||||
address);
|
||||
return;
|
||||
}
|
||||
case gettxfeerate: {
|
||||
if (new SimpleMethodOptionParser(args).parse().isForHelp()) {
|
||||
out.println(client.getMethodHelp(method));
|
||||
|
@ -339,7 +287,6 @@ public class CliMain {
|
|||
var fixedPrice = opts.getFixedPrice();
|
||||
var marketPriceMargin = opts.getMktPriceMarginAsBigDecimal();
|
||||
var securityDeposit = toSecurityDepositAsPct(opts.getSecurityDeposit());
|
||||
var makerFeeCurrencyCode = opts.getMakerFeeCurrencyCode();
|
||||
var offer = client.createOffer(direction,
|
||||
currencyCode,
|
||||
amount,
|
||||
|
@ -348,8 +295,7 @@ public class CliMain {
|
|||
fixedPrice,
|
||||
marketPriceMargin.doubleValue(),
|
||||
securityDeposit,
|
||||
paymentAcctId,
|
||||
makerFeeCurrencyCode);
|
||||
paymentAcctId);
|
||||
out.println(formatOfferTable(singletonList(offer), currencyCode));
|
||||
return;
|
||||
}
|
||||
|
@ -426,8 +372,7 @@ public class CliMain {
|
|||
}
|
||||
var offerId = opts.getOfferId();
|
||||
var paymentAccountId = opts.getPaymentAccountId();
|
||||
var takerFeeCurrencyCode = opts.getTakerFeeCurrencyCode();
|
||||
var trade = client.takeOffer(offerId, paymentAccountId, takerFeeCurrencyCode);
|
||||
var trade = client.takeOffer(offerId, paymentAccountId);
|
||||
out.printf("trade %s successfully taken%n", trade.getTradeId());
|
||||
return;
|
||||
}
|
||||
|
@ -721,7 +666,7 @@ public class CliMain {
|
|||
stream.format(rowFormat, "------", "------", "------------");
|
||||
stream.format(rowFormat, getversion.name(), "", "Get server version");
|
||||
stream.println();
|
||||
stream.format(rowFormat, getbalance.name(), "[--currency-code=<bsq|btc>]", "Get server wallet balances");
|
||||
stream.format(rowFormat, getbalance.name(), "[--currency-code=<btc>]", "Get server wallet balances");
|
||||
stream.println();
|
||||
stream.format(rowFormat, getaddressbalance.name(), "--address=<btc-address>", "Get server wallet address balance");
|
||||
stream.println();
|
||||
|
@ -729,17 +674,10 @@ public class CliMain {
|
|||
stream.println();
|
||||
stream.format(rowFormat, getfundingaddresses.name(), "", "Get BTC funding addresses");
|
||||
stream.println();
|
||||
stream.format(rowFormat, getunusedbsqaddress.name(), "", "Get unused BSQ address");
|
||||
stream.println();
|
||||
stream.format(rowFormat, sendbsq.name(), "--address=<bsq-address> --amount=<bsq-amount> \\", "Send BSQ");
|
||||
stream.format(rowFormat, "", "[--tx-fee-rate=<sats/byte>]", "");
|
||||
stream.println();
|
||||
stream.format(rowFormat, sendbtc.name(), "--address=<btc-address> --amount=<btc-amount> \\", "Send BTC");
|
||||
stream.format(rowFormat, "", "[--tx-fee-rate=<sats/byte>]", "");
|
||||
stream.format(rowFormat, "", "[--memo=<\"memo\">]", "");
|
||||
stream.println();
|
||||
stream.format(rowFormat, verifybsqsenttoaddress.name(), "--address=<bsq-address> --amount=<bsq-amount>",
|
||||
"Verify amount was sent to BSQ wallet address");
|
||||
stream.println();
|
||||
stream.format(rowFormat, gettxfeerate.name(), "", "Get current tx fee rate in sats/byte");
|
||||
stream.println();
|
||||
|
@ -756,7 +694,7 @@ public class CliMain {
|
|||
stream.format(rowFormat, "", "[--min-amount=<min-btc-amount>] \\", "");
|
||||
stream.format(rowFormat, "", "--fixed-price=<price> | --market-price=margin=<percent> \\", "");
|
||||
stream.format(rowFormat, "", "--security-deposit=<percent> \\", "");
|
||||
stream.format(rowFormat, "", "[--fee-currency=<bsq|btc>]", "");
|
||||
stream.format(rowFormat, "", "[--fee-currency=<btc>]", "");
|
||||
stream.println();
|
||||
stream.format(rowFormat, canceloffer.name(), "--offer-id=<offer-id>", "Cancel offer with id");
|
||||
stream.println();
|
||||
|
@ -772,7 +710,7 @@ public class CliMain {
|
|||
stream.println();
|
||||
stream.format(rowFormat, takeoffer.name(), "--offer-id=<offer-id> \\", "Take offer with id");
|
||||
stream.format(rowFormat, "", "--payment-account=<payment-account-id>", "");
|
||||
stream.format(rowFormat, "", "[--fee-currency=<btc|bsq>]", "");
|
||||
stream.format(rowFormat, "", "[--fee-currency=<btc>]", "");
|
||||
stream.println();
|
||||
stream.format(rowFormat, gettrade.name(), "--trade-id=<trade-id> \\", "Get trade summary or full contract");
|
||||
stream.format(rowFormat, "", "[--show-contract=<true|false>]", "");
|
||||
|
@ -794,8 +732,8 @@ public class CliMain {
|
|||
stream.format(rowFormat, createpaymentacct.name(), "--payment-account-form=<path>", "Create a new payment account");
|
||||
stream.println();
|
||||
stream.format(rowFormat, createcryptopaymentacct.name(), "--account-name=<name> \\", "Create a new cryptocurrency payment account");
|
||||
stream.format(rowFormat, "", "--currency-code=<bsq> \\", "");
|
||||
stream.format(rowFormat, "", "--address=<bsq-address>", "");
|
||||
stream.format(rowFormat, "", "--currency-code=<btc> \\", "");
|
||||
stream.format(rowFormat, "", "--address=<address>", "");
|
||||
stream.format(rowFormat, "", "--trade-instant=<true|false>", "");
|
||||
stream.println();
|
||||
stream.format(rowFormat, getpaymentaccts.name(), "", "Get user payment accounts");
|
||||
|
|
|
@ -54,7 +54,6 @@ class ColumnHeaderConstants {
|
|||
static final String COL_HEADER_PRICE = "Price in %-3s for 1 BTC";
|
||||
static final String COL_HEADER_PRICE_OF_ALTCOIN = "Price in BTC for 1 %-3s";
|
||||
static final String COL_HEADER_TRADE_AMOUNT = padStart("Amount(%-3s)", 12, ' ');
|
||||
static final String COL_HEADER_TRADE_BSQ_BUYER_ADDRESS = "BSQ Buyer Address";
|
||||
static final String COL_HEADER_TRADE_BUYER_COST = padEnd("Buyer Cost(%-3s)", 15, ' ');
|
||||
static final String COL_HEADER_TRADE_DEPOSIT_CONFIRMED = "Deposit Confirmed";
|
||||
static final String COL_HEADER_TRADE_DEPOSIT_PUBLISHED = "Deposit Published";
|
||||
|
|
|
@ -28,7 +28,6 @@ class CryptoCurrencyUtil {
|
|||
|
||||
public static List<String> getSupportedCryptoCurrencies() {
|
||||
final List<String> result = new ArrayList<>();
|
||||
result.add("BSQ");
|
||||
result.sort(String::compareTo);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -46,12 +46,8 @@ public class CurrencyFormat {
|
|||
static final DecimalFormat BTC_FORMAT = new DecimalFormat("###,##0.00000000");
|
||||
static final DecimalFormat BTC_TX_FEE_FORMAT = new DecimalFormat("###,###,##0");
|
||||
|
||||
static final BigDecimal BSQ_SATOSHI_DIVISOR = new BigDecimal(100);
|
||||
static final DecimalFormat BSQ_FORMAT = new DecimalFormat("###,###,###,##0.00");
|
||||
static final DecimalFormat SEND_BSQ_FORMAT = new DecimalFormat("###########0.00");
|
||||
|
||||
static final BigDecimal SECURITY_DEPOSIT_MULTIPLICAND = new BigDecimal("0.01");
|
||||
|
||||
|
||||
// TODO: (woodser): replace formatSatoshis(), formatBsq() with formatXmr()
|
||||
|
||||
@SuppressWarnings("BigDecimalMethodWithoutRoundingCalled")
|
||||
|
@ -59,22 +55,10 @@ public class CurrencyFormat {
|
|||
return BTC_FORMAT.format(BigDecimal.valueOf(sats).divide(SATOSHI_DIVISOR));
|
||||
}
|
||||
|
||||
@SuppressWarnings("BigDecimalMethodWithoutRoundingCalled")
|
||||
public static String formatBsq(long sats) {
|
||||
return BSQ_FORMAT.format(BigDecimal.valueOf(sats).divide(BSQ_SATOSHI_DIVISOR));
|
||||
}
|
||||
|
||||
public static String formatXmr(BigInteger amount) {
|
||||
return "" + MoneroUtils.atomicUnitsToXmr(amount);
|
||||
}
|
||||
|
||||
public static String formatBsqAmount(long bsqSats) {
|
||||
// BSQ sats = trade.getOffer().getVolume()
|
||||
NUMBER_FORMAT.setMinimumFractionDigits(2);
|
||||
NUMBER_FORMAT.setMaximumFractionDigits(2);
|
||||
NUMBER_FORMAT.setRoundingMode(HALF_UP);
|
||||
return SEND_BSQ_FORMAT.format((double) bsqSats / SATOSHI_DIVISOR.doubleValue());
|
||||
}
|
||||
|
||||
public static String formatTxFeeRateInfo(TxFeeRateInfo txFeeRateInfo) {
|
||||
if (txFeeRateInfo.getUseCustomTxFeeRate())
|
||||
|
|
|
@ -19,7 +19,6 @@ package bisq.cli;
|
|||
|
||||
import bisq.proto.grpc.AddressBalanceInfo;
|
||||
import bisq.proto.grpc.BalancesInfo;
|
||||
import bisq.proto.grpc.BsqBalanceInfo;
|
||||
import bisq.proto.grpc.BtcBalanceInfo;
|
||||
import bisq.proto.grpc.CancelOfferRequest;
|
||||
import bisq.proto.grpc.ConfirmPaymentReceivedRequest;
|
||||
|
@ -42,7 +41,6 @@ import bisq.proto.grpc.GetPaymentMethodsRequest;
|
|||
import bisq.proto.grpc.GetTradeRequest;
|
||||
import bisq.proto.grpc.GetTransactionRequest;
|
||||
import bisq.proto.grpc.GetTxFeeRateRequest;
|
||||
import bisq.proto.grpc.GetUnusedBsqAddressRequest;
|
||||
import bisq.proto.grpc.GetVersionRequest;
|
||||
import bisq.proto.grpc.KeepFundsRequest;
|
||||
import bisq.proto.grpc.LockWalletRequest;
|
||||
|
@ -50,7 +48,6 @@ import bisq.proto.grpc.MarketPriceRequest;
|
|||
import bisq.proto.grpc.OfferInfo;
|
||||
import bisq.proto.grpc.RegisterDisputeAgentRequest;
|
||||
import bisq.proto.grpc.RemoveWalletPasswordRequest;
|
||||
import bisq.proto.grpc.SendBsqRequest;
|
||||
import bisq.proto.grpc.SendBtcRequest;
|
||||
import bisq.proto.grpc.SetTxFeeRatePreferenceRequest;
|
||||
import bisq.proto.grpc.SetWalletPasswordRequest;
|
||||
|
@ -62,7 +59,6 @@ import bisq.proto.grpc.TxFeeRateInfo;
|
|||
import bisq.proto.grpc.TxInfo;
|
||||
import bisq.proto.grpc.UnlockWalletRequest;
|
||||
import bisq.proto.grpc.UnsetTxFeeRatePreferenceRequest;
|
||||
import bisq.proto.grpc.VerifyBsqSentToAddressRequest;
|
||||
import bisq.proto.grpc.WithdrawFundsRequest;
|
||||
import bisq.proto.grpc.XmrBalanceInfo;
|
||||
|
||||
|
@ -100,10 +96,6 @@ public final class GrpcClient {
|
|||
return getBalances("");
|
||||
}
|
||||
|
||||
public BsqBalanceInfo getBsqBalances() {
|
||||
return getBalances("BSQ").getBsq();
|
||||
}
|
||||
|
||||
public BtcBalanceInfo getBtcBalances() {
|
||||
return getBalances("BTC").getBtc();
|
||||
}
|
||||
|
@ -137,11 +129,6 @@ public final class GrpcClient {
|
|||
return grpcStubs.walletsService.getFundingAddresses(request).getAddressBalanceInfoList();
|
||||
}
|
||||
|
||||
public String getUnusedBsqAddress() {
|
||||
var request = GetUnusedBsqAddressRequest.newBuilder().build();
|
||||
return grpcStubs.walletsService.getUnusedBsqAddress(request).getAddress();
|
||||
}
|
||||
|
||||
public String getUnusedBtcAddress() {
|
||||
var request = GetFundingAddressesRequest.newBuilder().build();
|
||||
var addressBalances = grpcStubs.walletsService.getFundingAddresses(request)
|
||||
|
@ -154,15 +141,6 @@ public final class GrpcClient {
|
|||
.getAddress();
|
||||
}
|
||||
|
||||
public TxInfo sendBsq(String address, String amount, String txFeeRate) {
|
||||
var request = SendBsqRequest.newBuilder()
|
||||
.setAddress(address)
|
||||
.setAmount(amount)
|
||||
.setTxFeeRate(txFeeRate)
|
||||
.build();
|
||||
return grpcStubs.walletsService.sendBsq(request).getTxInfo();
|
||||
}
|
||||
|
||||
public TxInfo sendBtc(String address, String amount, String txFeeRate, String memo) {
|
||||
var request = SendBtcRequest.newBuilder()
|
||||
.setAddress(address)
|
||||
|
@ -173,14 +151,6 @@ public final class GrpcClient {
|
|||
return grpcStubs.walletsService.sendBtc(request).getTxInfo();
|
||||
}
|
||||
|
||||
public boolean verifyBsqSentToAddress(String address, String amount) {
|
||||
var request = VerifyBsqSentToAddressRequest.newBuilder()
|
||||
.setAddress(address)
|
||||
.setAmount(amount)
|
||||
.build();
|
||||
return grpcStubs.walletsService.verifyBsqSentToAddress(request).getIsAmountReceived();
|
||||
}
|
||||
|
||||
public TxFeeRateInfo getTxFeeRate() {
|
||||
var request = GetTxFeeRateRequest.newBuilder().build();
|
||||
return grpcStubs.walletsService.getTxFeeRate(request).getTxFeeRateInfo();
|
||||
|
@ -211,8 +181,7 @@ public final class GrpcClient {
|
|||
long minAmount,
|
||||
String fixedPrice,
|
||||
double securityDeposit,
|
||||
String paymentAcctId,
|
||||
String makerFeeCurrencyCode) {
|
||||
String paymentAcctId) {
|
||||
return createOffer(direction,
|
||||
currencyCode,
|
||||
amount,
|
||||
|
@ -221,8 +190,7 @@ public final class GrpcClient {
|
|||
fixedPrice,
|
||||
0.00,
|
||||
securityDeposit,
|
||||
paymentAcctId,
|
||||
makerFeeCurrencyCode);
|
||||
paymentAcctId);
|
||||
}
|
||||
|
||||
public OfferInfo createMarketBasedPricedOffer(String direction,
|
||||
|
@ -231,8 +199,7 @@ public final class GrpcClient {
|
|||
long minAmount,
|
||||
double marketPriceMargin,
|
||||
double securityDeposit,
|
||||
String paymentAcctId,
|
||||
String makerFeeCurrencyCode) {
|
||||
String paymentAcctId) {
|
||||
return createOffer(direction,
|
||||
currencyCode,
|
||||
amount,
|
||||
|
@ -241,8 +208,7 @@ public final class GrpcClient {
|
|||
"0",
|
||||
marketPriceMargin,
|
||||
securityDeposit,
|
||||
paymentAcctId,
|
||||
makerFeeCurrencyCode);
|
||||
paymentAcctId);
|
||||
}
|
||||
|
||||
public OfferInfo createOffer(String direction,
|
||||
|
@ -253,8 +219,7 @@ public final class GrpcClient {
|
|||
String fixedPrice,
|
||||
double marketPriceMargin,
|
||||
double securityDeposit,
|
||||
String paymentAcctId,
|
||||
String makerFeeCurrencyCode) {
|
||||
String paymentAcctId) {
|
||||
var request = CreateOfferRequest.newBuilder()
|
||||
.setDirection(direction)
|
||||
.setCurrencyCode(currencyCode)
|
||||
|
@ -265,7 +230,6 @@ public final class GrpcClient {
|
|||
.setMarketPriceMargin(marketPriceMargin)
|
||||
.setBuyerSecurityDeposit(securityDeposit)
|
||||
.setPaymentAccountId(paymentAcctId)
|
||||
.setMakerFeeCurrencyCode(makerFeeCurrencyCode)
|
||||
.build();
|
||||
return grpcStubs.offersService.createOffer(request).getOffer();
|
||||
}
|
||||
|
@ -321,13 +285,6 @@ public final class GrpcClient {
|
|||
return offers.isEmpty() ? offers : sortOffersByDate(offers);
|
||||
}
|
||||
|
||||
public List<OfferInfo> getBsqOffersSortedByDate() {
|
||||
ArrayList<OfferInfo> offers = new ArrayList<>();
|
||||
offers.addAll(getCryptoCurrencyOffers(BUY.name(), "BSQ"));
|
||||
offers.addAll(getCryptoCurrencyOffers(SELL.name(), "BSQ"));
|
||||
return sortOffersByDate(offers);
|
||||
}
|
||||
|
||||
public List<OfferInfo> getMyOffers(String direction, String currencyCode) {
|
||||
if (isSupportedCryptoCurrency(currencyCode)) {
|
||||
return getMyCryptoCurrencyOffers(direction, currencyCode);
|
||||
|
@ -358,13 +315,6 @@ public final class GrpcClient {
|
|||
return sortOffersByDate(offers);
|
||||
}
|
||||
|
||||
public List<OfferInfo> getMyBsqOffersSortedByDate() {
|
||||
ArrayList<OfferInfo> offers = new ArrayList<>();
|
||||
offers.addAll(getMyCryptoCurrencyOffers(BUY.name(), "BSQ"));
|
||||
offers.addAll(getMyCryptoCurrencyOffers(SELL.name(), "BSQ"));
|
||||
return sortOffersByDate(offers);
|
||||
}
|
||||
|
||||
public OfferInfo getMostRecentOffer(String direction, String currencyCode) {
|
||||
List<OfferInfo> offers = getOffersSortedByDate(direction, currencyCode);
|
||||
return offers.isEmpty() ? null : offers.get(offers.size() - 1);
|
||||
|
@ -376,17 +326,16 @@ public final class GrpcClient {
|
|||
.collect(toList());
|
||||
}
|
||||
|
||||
public TakeOfferReply getTakeOfferReply(String offerId, String paymentAccountId, String takerFeeCurrencyCode) {
|
||||
public TakeOfferReply getTakeOfferReply(String offerId, String paymentAccountId) {
|
||||
var request = TakeOfferRequest.newBuilder()
|
||||
.setOfferId(offerId)
|
||||
.setPaymentAccountId(paymentAccountId)
|
||||
.setTakerFeeCurrencyCode(takerFeeCurrencyCode)
|
||||
.build();
|
||||
return grpcStubs.tradesService.takeOffer(request);
|
||||
}
|
||||
|
||||
public TradeInfo takeOffer(String offerId, String paymentAccountId, String takerFeeCurrencyCode) {
|
||||
var reply = getTakeOfferReply(offerId, paymentAccountId, takerFeeCurrencyCode);
|
||||
public TradeInfo takeOffer(String offerId, String paymentAccountId) {
|
||||
var reply = getTakeOfferReply(offerId, paymentAccountId);
|
||||
if (reply.hasTrade())
|
||||
return reply.getTrade();
|
||||
else
|
||||
|
|
|
@ -41,15 +41,12 @@ public enum Method {
|
|||
gettrade,
|
||||
gettransaction,
|
||||
gettxfeerate,
|
||||
getunusedbsqaddress,
|
||||
getversion,
|
||||
keepfunds,
|
||||
lockwallet,
|
||||
registerdisputeagent,
|
||||
removewalletpassword,
|
||||
sendbsq,
|
||||
sendbtc,
|
||||
verifybsqsenttoaddress,
|
||||
settxfeerate,
|
||||
setwalletpassword,
|
||||
takeoffer,
|
||||
|
|
|
@ -19,7 +19,6 @@ package bisq.cli;
|
|||
|
||||
import bisq.proto.grpc.AddressBalanceInfo;
|
||||
import bisq.proto.grpc.BalancesInfo;
|
||||
import bisq.proto.grpc.BsqBalanceInfo;
|
||||
import bisq.proto.grpc.BtcBalanceInfo;
|
||||
import bisq.proto.grpc.OfferInfo;
|
||||
import bisq.proto.grpc.XmrBalanceInfo;
|
||||
|
@ -75,31 +74,7 @@ public class TableFormat {
|
|||
|
||||
public static String formatBalancesTbls(BalancesInfo balancesInfo) {
|
||||
return "XMR" + "\n"
|
||||
+ formatBtcBalanceInfoTbl(balancesInfo.getBtc()) + "\n"
|
||||
+ "BSQ" + "\n"
|
||||
+ formatBsqBalanceInfoTbl(balancesInfo.getBsq());
|
||||
}
|
||||
|
||||
public static String formatBsqBalanceInfoTbl(BsqBalanceInfo bsqBalanceInfo) {
|
||||
String headerLine = COL_HEADER_AVAILABLE_CONFIRMED_BALANCE + COL_HEADER_DELIMITER
|
||||
+ COL_HEADER_UNVERIFIED_BALANCE + COL_HEADER_DELIMITER
|
||||
+ COL_HEADER_UNCONFIRMED_CHANGE_BALANCE + COL_HEADER_DELIMITER
|
||||
+ COL_HEADER_LOCKED_FOR_VOTING_BALANCE + COL_HEADER_DELIMITER
|
||||
+ COL_HEADER_LOCKUP_BONDS_BALANCE + COL_HEADER_DELIMITER
|
||||
+ COL_HEADER_UNLOCKING_BONDS_BALANCE + COL_HEADER_DELIMITER + "\n";
|
||||
String colDataFormat = "%" + COL_HEADER_AVAILABLE_CONFIRMED_BALANCE.length() + "s" // rt justify
|
||||
+ " %" + (COL_HEADER_UNVERIFIED_BALANCE.length() + 1) + "s" // rt justify
|
||||
+ " %" + (COL_HEADER_UNCONFIRMED_CHANGE_BALANCE.length() + 1) + "s" // rt justify
|
||||
+ " %" + (COL_HEADER_LOCKED_FOR_VOTING_BALANCE.length() + 1) + "s" // rt justify
|
||||
+ " %" + (COL_HEADER_LOCKUP_BONDS_BALANCE.length() + 1) + "s" // rt justify
|
||||
+ " %" + (COL_HEADER_UNLOCKING_BONDS_BALANCE.length() + 1) + "s"; // rt justify
|
||||
return headerLine + format(colDataFormat,
|
||||
formatBsq(bsqBalanceInfo.getAvailableConfirmedBalance()),
|
||||
formatBsq(bsqBalanceInfo.getUnverifiedBalance()),
|
||||
formatBsq(bsqBalanceInfo.getUnconfirmedChangeBalance()),
|
||||
formatBsq(bsqBalanceInfo.getLockedForVotingBalance()),
|
||||
formatBsq(bsqBalanceInfo.getLockupBondsBalance()),
|
||||
formatBsq(bsqBalanceInfo.getUnlockingBondsBalance()));
|
||||
+ formatBtcBalanceInfoTbl(balancesInfo.getBtc());
|
||||
}
|
||||
|
||||
public static String formatBtcBalanceInfoTbl(BtcBalanceInfo btcBalanceInfo) {
|
||||
|
|
|
@ -61,9 +61,6 @@ public class TradeFormat {
|
|||
"%" + (COL_HEADER_TRADE_TAKER_FEE.length() + 2) + "s"
|
||||
: "";
|
||||
|
||||
boolean showBsqBuyerAddress = shouldShowBsqBuyerAddress(tradeInfo, isTaker);
|
||||
Supplier<String> bsqBuyerAddressHeader = () -> showBsqBuyerAddress ? COL_HEADER_TRADE_BSQ_BUYER_ADDRESS : "";
|
||||
Supplier<String> bsqBuyerAddressHeaderSpec = () -> showBsqBuyerAddress ? "%s" : "";
|
||||
|
||||
String headersFormat = padEnd(COL_HEADER_TRADE_SHORT_ID, shortIdColWidth, ' ') + COL_HEADER_DELIMITER
|
||||
+ padEnd(COL_HEADER_TRADE_ROLE, roleColWidth, ' ') + COL_HEADER_DELIMITER
|
||||
|
@ -80,7 +77,6 @@ public class TradeFormat {
|
|||
+ COL_HEADER_TRADE_PAYMENT_RECEIVED + COL_HEADER_DELIMITER
|
||||
+ COL_HEADER_TRADE_PAYOUT_PUBLISHED + COL_HEADER_DELIMITER
|
||||
+ COL_HEADER_TRADE_WITHDRAWN + COL_HEADER_DELIMITER
|
||||
+ bsqBuyerAddressHeader.get()
|
||||
+ "%n";
|
||||
|
||||
String counterCurrencyCode = tradeInfo.getOffer().getCounterCurrencyCode();
|
||||
|
@ -108,16 +104,14 @@ public class TradeFormat {
|
|||
+ " %-" + (COL_HEADER_TRADE_PAYMENT_SENT.length() - 1) + "s" // left
|
||||
+ " %-" + (COL_HEADER_TRADE_PAYMENT_RECEIVED.length() - 1) + "s" // left
|
||||
+ " %-" + COL_HEADER_TRADE_PAYOUT_PUBLISHED.length() + "s" // lt justify
|
||||
+ " %-" + (COL_HEADER_TRADE_WITHDRAWN.length() + 2) + "s"
|
||||
+ bsqBuyerAddressHeaderSpec.get();
|
||||
+ " %-" + (COL_HEADER_TRADE_WITHDRAWN.length() + 2) + "s";
|
||||
|
||||
return headerLine + formatTradeData(colDataFormat, tradeInfo, isTaker, showBsqBuyerAddress);
|
||||
return headerLine + formatTradeData(colDataFormat, tradeInfo, isTaker);
|
||||
}
|
||||
|
||||
private static String formatTradeData(String format,
|
||||
TradeInfo tradeInfo,
|
||||
boolean isTaker,
|
||||
boolean showBsqBuyerAddress) {
|
||||
boolean isTaker) {
|
||||
return String.format(format,
|
||||
tradeInfo.getShortId(),
|
||||
tradeInfo.getRole(),
|
||||
|
@ -131,8 +125,7 @@ public class TradeFormat {
|
|||
tradeInfo.getIsFiatSent() ? YES : NO,
|
||||
tradeInfo.getIsFiatReceived() ? YES : NO,
|
||||
tradeInfo.getIsPayoutPublished() ? YES : NO,
|
||||
tradeInfo.getIsWithdrawn() ? YES : NO,
|
||||
bsqReceiveAddress.apply(tradeInfo, showBsqBuyerAddress));
|
||||
tradeInfo.getIsWithdrawn() ? YES : NO);
|
||||
}
|
||||
|
||||
private static final Function<TradeInfo, String> priceHeader = (t) ->
|
||||
|
@ -181,31 +174,4 @@ public class TradeFormat {
|
|||
? formatOfferVolume(t.getOffer().getVolume())
|
||||
: formatXmr(ParsingUtils.centinerosToAtomicUnits(t.getTradeAmountAsLong()));
|
||||
|
||||
private static final BiFunction<TradeInfo, Boolean, String> bsqReceiveAddress = (t, showBsqBuyerAddress) -> {
|
||||
if (showBsqBuyerAddress) {
|
||||
ContractInfo contract = t.getContract();
|
||||
boolean isBuyerMakerAndSellerTaker = contract.getIsBuyerMakerAndSellerTaker();
|
||||
return isBuyerMakerAndSellerTaker // (is XMR buyer / maker)
|
||||
? contract.getTakerPaymentAccountPayload().getAddress()
|
||||
: contract.getMakerPaymentAccountPayload().getAddress();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
private static boolean shouldShowBsqBuyerAddress(TradeInfo tradeInfo, boolean isTaker) {
|
||||
if (tradeInfo.getOffer().getBaseCurrencyCode().equals("XMR")) {
|
||||
return false;
|
||||
} else {
|
||||
ContractInfo contract = tradeInfo.getContract();
|
||||
// Do not forget buyer and seller refer to XMR buyer and seller, not BSQ
|
||||
// buyer and seller. If you are buying BSQ, you are the XMR seller.
|
||||
boolean isBuyerMakerAndSellerTaker = contract.getIsBuyerMakerAndSellerTaker();
|
||||
if (isTaker) {
|
||||
return !isBuyerMakerAndSellerTaker;
|
||||
} else {
|
||||
return isBuyerMakerAndSellerTaker;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,10 +30,10 @@ public class CreateCryptoCurrencyPaymentAcctOptionParser extends AbstractMethodO
|
|||
final OptionSpec<String> accountNameOpt = parser.accepts(OPT_ACCOUNT_NAME, "crypto currency account name")
|
||||
.withRequiredArg();
|
||||
|
||||
final OptionSpec<String> currencyCodeOpt = parser.accepts(OPT_CURRENCY_CODE, "crypto currency code (bsq only)")
|
||||
final OptionSpec<String> currencyCodeOpt = parser.accepts(OPT_CURRENCY_CODE, "crypto currency code")
|
||||
.withRequiredArg();
|
||||
|
||||
final OptionSpec<String> addressOpt = parser.accepts(OPT_ADDRESS, "bsq address")
|
||||
final OptionSpec<String> addressOpt = parser.accepts(OPT_ADDRESS, "address")
|
||||
.withRequiredArg();
|
||||
|
||||
final OptionSpec<Boolean> tradeInstantOpt = parser.accepts(OPT_TRADE_INSTANT, "create trade instant account")
|
||||
|
@ -54,16 +54,9 @@ public class CreateCryptoCurrencyPaymentAcctOptionParser extends AbstractMethodO
|
|||
|
||||
if (!options.has(accountNameOpt) || options.valueOf(accountNameOpt).isEmpty())
|
||||
throw new IllegalArgumentException("no payment account name specified");
|
||||
|
||||
|
||||
if (!options.has(currencyCodeOpt) || options.valueOf(currencyCodeOpt).isEmpty())
|
||||
throw new IllegalArgumentException("no currency code specified");
|
||||
|
||||
if (!options.valueOf(currencyCodeOpt).equalsIgnoreCase("bsq"))
|
||||
throw new IllegalArgumentException("api only supports bsq crypto currency payment accounts");
|
||||
|
||||
if (!options.has(addressOpt) || options.valueOf(addressOpt).isEmpty())
|
||||
throw new IllegalArgumentException("no bsq address specified");
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,10 +55,6 @@ public class CreateOfferOptionParser extends AbstractMethodOptionParser implemen
|
|||
final OptionSpec<String> securityDepositOpt = parser.accepts(OPT_SECURITY_DEPOSIT, "maker security deposit (%)")
|
||||
.withRequiredArg();
|
||||
|
||||
final OptionSpec<String> makerFeeCurrencyCodeOpt = parser.accepts(OPT_FEE_CURRENCY, "maker fee currency code (bsq|btc)")
|
||||
.withOptionalArg()
|
||||
.defaultsTo("btc");
|
||||
|
||||
public CreateOfferOptionParser(String[] args) {
|
||||
super(args);
|
||||
}
|
||||
|
@ -137,8 +133,4 @@ public class CreateOfferOptionParser extends AbstractMethodOptionParser implemen
|
|||
public String getSecurityDeposit() {
|
||||
return options.valueOf(securityDepositOpt);
|
||||
}
|
||||
|
||||
public String getMakerFeeCurrencyCode() {
|
||||
return options.has(makerFeeCurrencyCodeOpt) ? options.valueOf(makerFeeCurrencyCodeOpt) : "btc";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import static joptsimple.internal.Strings.EMPTY;
|
|||
|
||||
public class GetBalanceOptionParser extends AbstractMethodOptionParser implements MethodOpts {
|
||||
|
||||
final OptionSpec<String> currencyCodeOpt = parser.accepts(OPT_CURRENCY_CODE, "wallet currency code (bsq|btc)")
|
||||
final OptionSpec<String> currencyCodeOpt = parser.accepts(OPT_CURRENCY_CODE, "wallet currency code (btc)")
|
||||
.withOptionalArg()
|
||||
.defaultsTo(EMPTY);
|
||||
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.cli.opts;
|
||||
|
||||
|
||||
import joptsimple.OptionSpec;
|
||||
|
||||
import static bisq.cli.opts.OptLabel.OPT_ADDRESS;
|
||||
import static bisq.cli.opts.OptLabel.OPT_AMOUNT;
|
||||
import static bisq.cli.opts.OptLabel.OPT_TX_FEE_RATE;
|
||||
import static joptsimple.internal.Strings.EMPTY;
|
||||
|
||||
public class SendBsqOptionParser extends AbstractMethodOptionParser implements MethodOpts {
|
||||
|
||||
final OptionSpec<String> addressOpt = parser.accepts(OPT_ADDRESS, "destination bsq address")
|
||||
.withRequiredArg();
|
||||
|
||||
final OptionSpec<String> amountOpt = parser.accepts(OPT_AMOUNT, "amount of bsq to send")
|
||||
.withRequiredArg();
|
||||
|
||||
final OptionSpec<String> feeRateOpt = parser.accepts(OPT_TX_FEE_RATE, "optional tx fee rate (sats/byte)")
|
||||
.withOptionalArg()
|
||||
.defaultsTo(EMPTY);
|
||||
|
||||
public SendBsqOptionParser(String[] args) {
|
||||
super(args);
|
||||
}
|
||||
|
||||
public SendBsqOptionParser parse() {
|
||||
super.parse();
|
||||
|
||||
// Short circuit opt validation if user just wants help.
|
||||
if (options.has(helpOpt))
|
||||
return this;
|
||||
|
||||
if (!options.has(addressOpt) || options.valueOf(addressOpt).isEmpty())
|
||||
throw new IllegalArgumentException("no bsq address specified");
|
||||
|
||||
if (!options.has(amountOpt) || options.valueOf(amountOpt).isEmpty())
|
||||
throw new IllegalArgumentException("no bsq amount specified");
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return options.valueOf(addressOpt);
|
||||
}
|
||||
|
||||
public String getAmount() {
|
||||
return options.valueOf(amountOpt);
|
||||
}
|
||||
|
||||
public String getFeeRate() {
|
||||
return options.has(feeRateOpt) ? options.valueOf(feeRateOpt) : "";
|
||||
}
|
||||
}
|
|
@ -32,10 +32,6 @@ public class TakeOfferOptionParser extends AbstractMethodOptionParser implements
|
|||
final OptionSpec<String> paymentAccountIdOpt = parser.accepts(OPT_PAYMENT_ACCOUNT, "id of payment account used for trade")
|
||||
.withRequiredArg();
|
||||
|
||||
final OptionSpec<String> takerFeeCurrencyCodeOpt = parser.accepts(OPT_FEE_CURRENCY, "taker fee currency code (bsq|btc)")
|
||||
.withOptionalArg()
|
||||
.defaultsTo("btc");
|
||||
|
||||
public TakeOfferOptionParser(String[] args) {
|
||||
super(args);
|
||||
}
|
||||
|
@ -63,8 +59,4 @@ public class TakeOfferOptionParser extends AbstractMethodOptionParser implements
|
|||
public String getPaymentAccountId() {
|
||||
return options.valueOf(paymentAccountIdOpt);
|
||||
}
|
||||
|
||||
public String getTakerFeeCurrencyCode() {
|
||||
return options.has(takerFeeCurrencyCodeOpt) ? options.valueOf(takerFeeCurrencyCodeOpt) : "btc";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* This file is part of Bisq.
|
||||
*
|
||||
* Bisq is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bisq is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package bisq.cli.opts;
|
||||
|
||||
|
||||
import joptsimple.OptionSpec;
|
||||
|
||||
import static bisq.cli.opts.OptLabel.OPT_ADDRESS;
|
||||
import static bisq.cli.opts.OptLabel.OPT_AMOUNT;
|
||||
|
||||
public class VerifyBsqSentToAddressOptionParser extends AbstractMethodOptionParser implements MethodOpts {
|
||||
|
||||
final OptionSpec<String> addressOpt = parser.accepts(OPT_ADDRESS, "receiving bsq address")
|
||||
.withRequiredArg();
|
||||
|
||||
final OptionSpec<String> amountOpt = parser.accepts(OPT_AMOUNT, "amount of bsq received")
|
||||
.withRequiredArg();
|
||||
|
||||
public VerifyBsqSentToAddressOptionParser(String[] args) {
|
||||
super(args);
|
||||
}
|
||||
|
||||
public VerifyBsqSentToAddressOptionParser parse() {
|
||||
super.parse();
|
||||
|
||||
// Short circuit opt validation if user just wants help.
|
||||
if (options.has(helpOpt))
|
||||
return this;
|
||||
|
||||
if (!options.has(addressOpt) || options.valueOf(addressOpt).isEmpty())
|
||||
throw new IllegalArgumentException("no bsq address specified");
|
||||
|
||||
if (!options.has(amountOpt) || options.valueOf(amountOpt).isEmpty())
|
||||
throw new IllegalArgumentException("no bsq amount specified");
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return options.valueOf(addressOpt);
|
||||
}
|
||||
|
||||
public String getAmount() {
|
||||
return options.valueOf(amountOpt);
|
||||
}
|
||||
}
|
|
@ -184,84 +184,4 @@ public class OptionParsersTest {
|
|||
exception.getMessage());
|
||||
}
|
||||
|
||||
// createcryptopaymentacct parser tests
|
||||
|
||||
@Test
|
||||
public void testCreateCryptoCurrencyPaymentAcctOptionParserWithMissingAcctNameOptShouldThrowException() {
|
||||
String[] args = new String[]{
|
||||
PASSWORD_OPT,
|
||||
createcryptopaymentacct.name()
|
||||
};
|
||||
Throwable exception = assertThrows(RuntimeException.class, () ->
|
||||
new CreateCryptoCurrencyPaymentAcctOptionParser(args).parse());
|
||||
assertEquals("no payment account name specified", exception.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateCryptoCurrencyPaymentAcctOptionParserWithEmptyAcctNameOptShouldThrowException() {
|
||||
String[] args = new String[]{
|
||||
PASSWORD_OPT,
|
||||
createcryptopaymentacct.name(),
|
||||
"--" + OPT_ACCOUNT_NAME
|
||||
};
|
||||
Throwable exception = assertThrows(RuntimeException.class, () ->
|
||||
new CreateCryptoCurrencyPaymentAcctOptionParser(args).parse());
|
||||
assertEquals("account-name requires an argument", exception.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateCryptoCurrencyPaymentAcctOptionParserWithMissingCurrencyCodeOptShouldThrowException() {
|
||||
String[] args = new String[]{
|
||||
PASSWORD_OPT,
|
||||
createcryptopaymentacct.name(),
|
||||
"--" + OPT_ACCOUNT_NAME + "=" + "bsq payment account"
|
||||
};
|
||||
Throwable exception = assertThrows(RuntimeException.class, () ->
|
||||
new CreateCryptoCurrencyPaymentAcctOptionParser(args).parse());
|
||||
assertEquals("no currency code specified", exception.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateCryptoCurrencyPaymentAcctOptionParserWithInvalidCurrencyCodeOptShouldThrowException() {
|
||||
String[] args = new String[]{
|
||||
PASSWORD_OPT,
|
||||
createcryptopaymentacct.name(),
|
||||
"--" + OPT_ACCOUNT_NAME + "=" + "bsq payment account",
|
||||
"--" + OPT_CURRENCY_CODE + "=" + "xmr"
|
||||
};
|
||||
Throwable exception = assertThrows(RuntimeException.class, () ->
|
||||
new CreateCryptoCurrencyPaymentAcctOptionParser(args).parse());
|
||||
assertEquals("api only supports bsq crypto currency payment accounts", exception.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateCryptoCurrencyPaymentAcctOptionParserWithMissingAddressOptShouldThrowException() {
|
||||
String[] args = new String[]{
|
||||
PASSWORD_OPT,
|
||||
createcryptopaymentacct.name(),
|
||||
"--" + OPT_ACCOUNT_NAME + "=" + "bsq payment account",
|
||||
"--" + OPT_CURRENCY_CODE + "=" + "bsq"
|
||||
};
|
||||
Throwable exception = assertThrows(RuntimeException.class, () ->
|
||||
new CreateCryptoCurrencyPaymentAcctOptionParser(args).parse());
|
||||
assertEquals("no bsq address specified", exception.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateCryptoCurrencyPaymentAcctOptionParser() {
|
||||
var acctName = "bsq payment account";
|
||||
var currencyCode = "bsq";
|
||||
var address = "B1nXyZ"; // address is validated on server
|
||||
String[] args = new String[]{
|
||||
PASSWORD_OPT,
|
||||
createcryptopaymentacct.name(),
|
||||
"--" + OPT_ACCOUNT_NAME + "=" + acctName,
|
||||
"--" + OPT_CURRENCY_CODE + "=" + currencyCode,
|
||||
"--" + OPT_ADDRESS + "=" + address
|
||||
};
|
||||
var parser = new CreateCryptoCurrencyPaymentAcctOptionParser(args).parse();
|
||||
assertEquals(acctName, parser.getAccountName());
|
||||
assertEquals(currencyCode, parser.getCurrencyCode());
|
||||
assertEquals(address, parser.getAddress());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue