mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
Add support for creating instant altcoin payment accounts in api
- Added bool tradeInstant field to proto message def. - Adjusted core createcryptopaymentacct impl to new tradeInstant request param. - Adjusted cli side createcryptopaymentacct impl to new tradeInstant request param. - Fixed CliMain's takeoffer help text (was missing the --payment-account opt).
This commit is contained in:
parent
2d66a5996d
commit
58c885efc1
@ -527,9 +527,11 @@ public class CliMain {
|
||||
var accountName = opts.getAccountName();
|
||||
var currencyCode = opts.getCurrencyCode();
|
||||
var address = opts.getAddress();
|
||||
var isTradeInstant = opts.getIsTradeInstant();
|
||||
var paymentAccount = client.createCryptoCurrencyPaymentAccount(accountName,
|
||||
currencyCode,
|
||||
address);
|
||||
address,
|
||||
isTradeInstant);
|
||||
out.println("payment account saved");
|
||||
out.println(formatPaymentAcctTbl(singletonList(paymentAccount)));
|
||||
return;
|
||||
@ -744,7 +746,9 @@ public class CliMain {
|
||||
stream.format(rowFormat, getmyoffers.name(), "--direction=<buy|sell> \\", "Get my current offers");
|
||||
stream.format(rowFormat, "", "--currency-code=<currency-code>", "");
|
||||
stream.println();
|
||||
stream.format(rowFormat, takeoffer.name(), "--offer-id=<offer-id> [--fee-currency=<btc|bsq>]", "Take offer with id");
|
||||
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.println();
|
||||
stream.format(rowFormat, gettrade.name(), "--trade-id=<trade-id> \\", "Get trade summary or full contract");
|
||||
stream.format(rowFormat, "", "[--show-contract=<true|false>]", "");
|
||||
@ -768,6 +772,7 @@ public class CliMain {
|
||||
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, "", "--trade-instant=<true|false>", "");
|
||||
stream.println();
|
||||
stream.format(rowFormat, getpaymentaccts.name(), "", "Get user payment accounts");
|
||||
stream.println();
|
||||
|
@ -433,11 +433,13 @@ public final class GrpcClient {
|
||||
|
||||
public PaymentAccount createCryptoCurrencyPaymentAccount(String accountName,
|
||||
String currencyCode,
|
||||
String address) {
|
||||
String address,
|
||||
boolean tradeInstant) {
|
||||
var request = CreateCryptoCurrencyPaymentAccountRequest.newBuilder()
|
||||
.setAccountName(accountName)
|
||||
.setCurrencyCode(currencyCode)
|
||||
.setAddress(address)
|
||||
.setTradeInstant(tradeInstant)
|
||||
.build();
|
||||
return grpcStubs.paymentAccountsService.createCryptoCurrencyPaymentAccount(request).getPaymentAccount();
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import joptsimple.OptionSpec;
|
||||
import static bisq.cli.opts.OptLabel.OPT_ACCOUNT_NAME;
|
||||
import static bisq.cli.opts.OptLabel.OPT_ADDRESS;
|
||||
import static bisq.cli.opts.OptLabel.OPT_CURRENCY_CODE;
|
||||
import static bisq.cli.opts.OptLabel.OPT_TRADE_INSTANT;
|
||||
|
||||
public class CreateCryptoCurrencyPaymentAcctOptionParser extends AbstractMethodOptionParser implements MethodOpts {
|
||||
|
||||
@ -35,6 +36,11 @@ public class CreateCryptoCurrencyPaymentAcctOptionParser extends AbstractMethodO
|
||||
final OptionSpec<String> addressOpt = parser.accepts(OPT_ADDRESS, "bsq address")
|
||||
.withRequiredArg();
|
||||
|
||||
final OptionSpec<Boolean> tradeInstantOpt = parser.accepts(OPT_TRADE_INSTANT, "create trade instant account")
|
||||
.withOptionalArg()
|
||||
.ofType(boolean.class)
|
||||
.defaultsTo(Boolean.FALSE);
|
||||
|
||||
public CreateCryptoCurrencyPaymentAcctOptionParser(String[] args) {
|
||||
super(args);
|
||||
}
|
||||
@ -72,4 +78,8 @@ public class CreateCryptoCurrencyPaymentAcctOptionParser extends AbstractMethodO
|
||||
public String getAddress() {
|
||||
return options.valueOf(addressOpt);
|
||||
}
|
||||
|
||||
public boolean getIsTradeInstant() {
|
||||
return options.valueOf(tradeInstantOpt);
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ public class OptLabel {
|
||||
public final static String OPT_SECURITY_DEPOSIT = "security-deposit";
|
||||
public final static String OPT_SHOW_CONTRACT = "show-contract";
|
||||
public final static String OPT_TRADE_ID = "trade-id";
|
||||
public final static String OPT_TRADE_INSTANT = "trade-instant";
|
||||
public final static String OPT_TIMEOUT = "timeout";
|
||||
public final static String OPT_TRANSACTION_ID = "transaction-id";
|
||||
public final static String OPT_TX_FEE_RATE = "tx-fee-rate";
|
||||
|
@ -210,8 +210,14 @@ public class CoreApi {
|
||||
return paymentAccountsService.getPaymentAccountFormAsString(paymentMethodId);
|
||||
}
|
||||
|
||||
public PaymentAccount createCryptoCurrencyPaymentAccount(String accountName, String currencyCode, String address) {
|
||||
return paymentAccountsService.createCryptoCurrencyPaymentAccount(accountName, currencyCode, address);
|
||||
public PaymentAccount createCryptoCurrencyPaymentAccount(String accountName,
|
||||
String currencyCode,
|
||||
String address,
|
||||
boolean tradeInstant) {
|
||||
return paymentAccountsService.createCryptoCurrencyPaymentAccount(accountName,
|
||||
currencyCode,
|
||||
address,
|
||||
tradeInstant);
|
||||
}
|
||||
|
||||
public List<PaymentMethod> getCryptoCurrencyPaymentMethods() {
|
||||
|
@ -21,6 +21,7 @@ import bisq.core.account.witness.AccountAgeWitnessService;
|
||||
import bisq.core.api.model.PaymentAccountForm;
|
||||
import bisq.core.locale.CryptoCurrency;
|
||||
import bisq.core.payment.CryptoCurrencyAccount;
|
||||
import bisq.core.payment.InstantCryptoCurrencyAccount;
|
||||
import bisq.core.payment.PaymentAccount;
|
||||
import bisq.core.payment.PaymentAccountFactory;
|
||||
import bisq.core.payment.payload.PaymentMethod;
|
||||
@ -100,7 +101,8 @@ class CorePaymentAccountsService {
|
||||
|
||||
PaymentAccount createCryptoCurrencyPaymentAccount(String accountName,
|
||||
String currencyCode,
|
||||
String address) {
|
||||
String address,
|
||||
boolean tradeInstant) {
|
||||
String bsqCode = currencyCode.toUpperCase();
|
||||
if (!bsqCode.equals("BSQ"))
|
||||
throw new IllegalArgumentException("api does not currently support " + currencyCode + " accounts");
|
||||
@ -108,8 +110,9 @@ class CorePaymentAccountsService {
|
||||
// Validate the BSQ address string but ignore the return value.
|
||||
coreWalletsService.getValidBsqLegacyAddress(address);
|
||||
|
||||
CryptoCurrencyAccount cryptoCurrencyAccount =
|
||||
(CryptoCurrencyAccount) PaymentAccountFactory.getPaymentAccount(PaymentMethod.BLOCK_CHAINS);
|
||||
var cryptoCurrencyAccount = tradeInstant
|
||||
? (InstantCryptoCurrencyAccount) PaymentAccountFactory.getPaymentAccount(PaymentMethod.BLOCK_CHAINS_INSTANT)
|
||||
: (CryptoCurrencyAccount) PaymentAccountFactory.getPaymentAccount(PaymentMethod.BLOCK_CHAINS);
|
||||
cryptoCurrencyAccount.init();
|
||||
cryptoCurrencyAccount.setAccountName(accountName);
|
||||
cryptoCurrencyAccount.setAddress(address);
|
||||
|
@ -7,33 +7,41 @@ createcryptopaymentacct - create a cryptocurrency payment account
|
||||
SYNOPSIS
|
||||
--------
|
||||
createcryptopaymentacct
|
||||
--account-name=<name>
|
||||
--account-name=<account-name>
|
||||
--currency-code=<bsq>
|
||||
--address=<bsq-address>
|
||||
--address=<unused-bsq-address>
|
||||
[--trade-instant=<true|false default=false>]
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
Creates a cryptocurrency (altcoin) trading account for buying and selling BTC.
|
||||
Create an cryptocurrency (altcoin) payment account. Only BSQ payment accounts are currently supported.
|
||||
|
||||
OPTIONS
|
||||
-------
|
||||
--account-name
|
||||
The name of the cryptocurrency payment account.
|
||||
The name of the cryptocurrency payment account used to create and take altcoin offers.
|
||||
|
||||
--currency-code
|
||||
The three letter code for the cryptocurrency used to buy or sell BTC, e.g., BSQ.
|
||||
The three letter code for the altcoin, e.g., BSQ.
|
||||
|
||||
--address
|
||||
A valid BSQ wallet address.
|
||||
The altcoin address to be used receive cryptocurrency payment when selling BTC.
|
||||
|
||||
--trade-instant
|
||||
True for creating an instant cryptocurrency payment account, false otherwise.
|
||||
Default is false.
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
To create a new BSQ payment account, find an unused BSQ wallet address:
|
||||
$ ./bisq-cli --password=xyz --port=9998 getunusedbsqaddress
|
||||
|
||||
With the returned BSQ address, e.g., Bn3PCQgRwhkrGnaMp1RYwt9tFwL51YELqne create the cryptocurrency payment account:
|
||||
$ ./bisq-cli --password=xyz --port=9998 createcryptopaymentacct \
|
||||
--account-name="My BSQ Account" \
|
||||
--currency-code=BSQ \
|
||||
--address=Bn3PCQgRwhkrGnaMp1RYwt9tFwL51YELqne
|
||||
To create a BSQ Altcoin payment account:
|
||||
$ ./bisq-cli --password=xyz --port=9998 createcryptopaymentacct --account-name="My BSQ Account" \
|
||||
--currency-code=bsq \
|
||||
--address=Bn3PCQgRwhkrGnaMp1RYwt9tFwL51YELqne \
|
||||
--trade-instant=false
|
||||
|
||||
To create a BSQ Instant Altcoin payment account:
|
||||
$ ./bisq-cli --password=xyz --port=9998 createcryptopaymentacct --account-name="My Instant BSQ Account" \
|
||||
--currency-code=bsq \
|
||||
--address=Bn3PCQgRwhkrGnaMp1RYwt9tFwL51YELqne \
|
||||
--trade-instant=true
|
||||
|
@ -135,7 +135,8 @@ class GrpcPaymentAccountsService extends PaymentAccountsImplBase {
|
||||
try {
|
||||
PaymentAccount paymentAccount = coreApi.createCryptoCurrencyPaymentAccount(req.getAccountName(),
|
||||
req.getCurrencyCode(),
|
||||
req.getAddress());
|
||||
req.getAddress(),
|
||||
req.getTradeInstant());
|
||||
var reply = CreateCryptoCurrencyPaymentAccountReply.newBuilder()
|
||||
.setPaymentAccount(paymentAccount.toProtoMessage())
|
||||
.build();
|
||||
|
@ -210,6 +210,7 @@ message CreateCryptoCurrencyPaymentAccountRequest {
|
||||
string accountName = 1;
|
||||
string currencyCode = 2;
|
||||
string address = 3;
|
||||
bool tradeInstant = 4;
|
||||
}
|
||||
|
||||
message CreateCryptoCurrencyPaymentAccountReply {
|
||||
|
Loading…
Reference in New Issue
Block a user