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

Refactor BtcWalletService to add tx-fee-rate param to 'sendbsq' #4867

Closed
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
fc8af8c
Define new grpc bsq/btc balances protos
ghubstan Nov 13, 2020
faf45ec
Add proto wrappers for serving bsq, btc or all balances
ghubstan Nov 13, 2020
4c03b46
Define proto for api method 'getunusedbsqaddress'
ghubstan Nov 13, 2020
3e98910
Define proto fapi method 'sendbsq'
ghubstan Nov 13, 2020
9f033ee
Add proto fields to support trade fee currency choice
ghubstan Nov 13, 2020
c1c099c
Implement and test api method 'getunusedbsqaddress'
ghubstan Nov 13, 2020
7c2068e
Add teardown to test case
ghubstan Nov 13, 2020
8dc1a74
Remove trailing spaces in blank line
ghubstan Nov 13, 2020
208a37b
Implement and test new getbalance(s) api methods
ghubstan Nov 13, 2020
7f0f949
Resolve unnecessary use of fully qualified name for codacy
ghubstan Nov 13, 2020
0d3b3a6
Stub out api method 'sendbsq' in core
ghubstan Nov 13, 2020
dc3274f
Re comment sendbsq tests so travis ci does not fail
ghubstan Nov 13, 2020
446bd32
Refactor desktop's BsqSendView, share with api
ghubstan Nov 13, 2020
4a90b40
Resolve 'Avoid creating BigDecimal with a decimal' issue for codacy
ghubstan Nov 13, 2020
722460e
Support paying trade fees in bsq or btc (api)
ghubstan Nov 13, 2020
8157f8f
Delete deprecated api test, adjust api build/run doc
ghubstan Nov 13, 2020
7e9ab22
Refactor api getbalance methods.
ghubstan Nov 14, 2020
187a85f
Fix typo
ghubstan Nov 14, 2020
34efc04
Remove unnecessary fully qualified name
ghubstan Nov 14, 2020
530a9f9
Remove unused imports
ghubstan Nov 14, 2020
ec38152
Add api method 'getpaymentmethods'
ghubstan Nov 18, 2020
a465261
Avoid codacy issue over use of fully qualified name
ghubstan Nov 18, 2020
0046b08
Revert "Avoid codacy issue over use of fully qualified name"
ghubstan Nov 18, 2020
7a7d5ba
Print the payment method id (only)
ghubstan Nov 18, 2020
0e0af20
Avoid codacy issue over use of fully qualified name
ghubstan Nov 18, 2020
7d0648a
Make codacy happy again
ghubstan Nov 18, 2020
32ed7ac
Add ReflectionUtils to common.util pkg
ghubstan Nov 18, 2020
c25deba
Add new (gson) PaymentAccountTypeAdapter to core.api.model
ghubstan Nov 18, 2020
1f84ad0
Add isCountryBasedPaymentAccount to abstract PaymentAccount
ghubstan Nov 18, 2020
32dd727
Add new PaymentAccountForm to core.api.model
ghubstan Nov 18, 2020
8996fa1
Add boilerplate for new 'getpaymentacctform' api method
ghubstan Nov 18, 2020
dc227ec
Add new api method 'getpaymentacctform' to CLI
ghubstan Nov 18, 2020
fdb89a2
Test new api method 'getpaymentacctform'
ghubstan Nov 18, 2020
35c1c4e
Ensure EXPECTED_FORM.clear() is never skipped
ghubstan Nov 18, 2020
08228d0
Replace existing api method 'createpaymentacct' impl
ghubstan Nov 18, 2020
138822e
Avoid 'unnecessary use of fully qualified name' codacy issue
ghubstan Nov 18, 2020
cb9a68b
Tidy up payment accts api related msgs on CLI
ghubstan Nov 19, 2020
ff887eb
Fix createpaymentacct validation problems
ghubstan Nov 19, 2020
58f1af6
Log server stack traces, pass concise err msgs to CLI
ghubstan Nov 20, 2020
459b2a9
Add create payment account (api) tests
ghubstan Nov 20, 2020
bb6762a
Reverse argument order for assert(expected, actual) convention
ghubstan Nov 20, 2020
636fac9
Add isMoneyGramAccount to abstract PaymentAccount
ghubstan Nov 21, 2020
23bfa2e
Refactor didReadCountryField to set country on MoneyGram acct
ghubstan Nov 21, 2020
76097fc
Enable CreateMoneyGramAccount test
ghubstan Nov 21, 2020
424f948
Fix broken tests
ghubstan Nov 22, 2020
daeb34b
Add two new api method tests
ghubstan Nov 22, 2020
08d5673
Fix getbalance out bug in CLI
ghubstan Nov 22, 2020
ab5780e
Print 'no offers found' msg in CLI if list is empty
ghubstan Nov 22, 2020
c885438
Fix minor error & help msg bugs
ghubstan Nov 23, 2020
f50634e
Resolve BsqSendView file conflict
ghubstan Nov 26, 2020
9d863e5
Remove deprecated method long getAvailableBalance
ghubstan Nov 26, 2020
baf300a
Add missing newlines to console output statements
ghubstan Nov 26, 2020
1559288
Implement fromProto
ghubstan Nov 26, 2020
8f13b85
Merge branch 'master' into 20-pr-change-requests-A
ghubstan Nov 26, 2020
5a06e4e
Adjust to changed CoinUtil
ghubstan Nov 26, 2020
8fd5786
Adjust test for a new payment method
ghubstan Nov 26, 2020
4464676
Add protobuf defs for gettxfeerate, settxfeerate, unsettxfeerate
ghubstan Nov 26, 2020
9662f26
Add protbuf TxFeeRateInfo
ghubstan Nov 26, 2020
abe7160
Add TxFeeRateInfo proto wrapper
ghubstan Nov 26, 2020
0b0f9f1
Add gettxfeerate, settxfeerate, unsettxfeerate implementations
ghubstan Nov 26, 2020
06eb378
Test new tx fee rate api methods
ghubstan Nov 26, 2020
965b003
Remove unnecessary use of fully qualified name for codacy
ghubstan Nov 27, 2020
6aa7e53
Refactor BtcWalletService to add tx-fee-rate param to 'sendbsq'
ghubstan Nov 30, 2020
f47e6d8
Remove debugging log statements
ghubstan Nov 30, 2020
0562506
Merge branch 'master' into 22-refactor-btcwalletservice-override-feerate
ghubstan Nov 30, 2020
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
Prev Previous commit
Next Next commit
Replace existing api method 'createpaymentacct' impl
In the CLI, this method now takes a single argument, the path to a json
file (a payment account form).  The json text is read from the file
and sent to the server, where it is serialized to a new PaymentAccount
instance, saved, and sent back to the CLI as a protobuf.PaymentAccount.

- Modified existing gRPC boilerplate in grpc.proto and GrpcPaymentAccountsService.

- Modified existing method signatures in CoreApi and CorePaymentAccountsService.

- Replaced existing method impl in CorePaymentAccountsService and
  removed dead code.

- Replaced the CLI's existing 'createpaymentacct' method impl.

- Modified existing tests.
  • Loading branch information
ghubstan committed Nov 18, 2020
commit 08228d07bc92de1feaf722afa0dd4bd068aba671
28 changes: 17 additions & 11 deletions apitest/src/test/java/bisq/apitest/method/MethodTest.java
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@
package bisq.apitest.method;

import bisq.core.api.model.PaymentAccountForm;
import bisq.core.proto.CoreProtoResolver;

import bisq.proto.grpc.AddressBalanceInfo;
import bisq.proto.grpc.BalancesInfo;
@@ -65,7 +66,6 @@
import static bisq.apitest.config.BisqAppConfig.arbdaemon;
import static bisq.apitest.config.BisqAppConfig.bobdaemon;
import static bisq.common.app.DevEnv.DEV_PRIVILEGE_PRIV_KEY;
import static bisq.core.payment.payload.PaymentMethod.PERFECT_MONEY;
import static java.util.Arrays.stream;
import static java.util.Comparator.comparing;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -89,6 +89,8 @@ public class MethodTest extends ApiTestCase {
protected static PaymentAccount alicesDummyAcct;
protected static PaymentAccount bobsDummyAcct;

private static final CoreProtoResolver CORE_PROTO_RESOLVER = new CoreProtoResolver();

public static void startSupportingApps(boolean registerDisputeAgents,
boolean generateBtcBlock,
Enum<?>... supportingApps) {
@@ -280,16 +282,16 @@ protected final File getPaymentAccountForm(BisqAppConfig bisqAppConfig, String p
return jsonFile;
}

protected final CreatePaymentAccountRequest createCreatePerfectMoneyPaymentAccountRequest(
String accountName,
String accountNumber,
String currencyCode) {
return CreatePaymentAccountRequest.newBuilder()
.setPaymentMethodId(PERFECT_MONEY.getId())
.setAccountName(accountName)
.setAccountNumber(accountNumber)
.setCurrencyCode(currencyCode)
protected final bisq.core.payment.PaymentAccount createPaymentAccount(BisqAppConfig bisqAppConfig,
String jsonString) {
var req = CreatePaymentAccountRequest.newBuilder()
.setPaymentAccountForm(jsonString)
.build();
var paymentAccountsService = grpcStubs(bisqAppConfig).paymentAccountsService;
// Normally, we can do asserts on the protos from the gRPC service, but in this
// case we need to return a bisq.core.payment.PaymentAccount so it can be cast
// to its sub type.
return fromProto(paymentAccountsService.createPaymentAccount(req).getPaymentAccount());
}

protected static PaymentAccount getDefaultPerfectDummyPaymentAccount(BisqAppConfig bisqAppConfig) {
@@ -356,10 +358,14 @@ protected static RegisterDisputeAgentRequest createRegisterDisputeAgentRequest(S
.setRegistrationKey(DEV_PRIVILEGE_PRIV_KEY).build();
}

@SuppressWarnings("ResultOfMethodCallIgnored")
@SuppressWarnings({"ResultOfMethodCallIgnored", "SameParameterValue"})
protected static void registerDisputeAgents(BisqAppConfig bisqAppConfig) {
var disputeAgentsService = grpcStubs(bisqAppConfig).disputeAgentsService;
disputeAgentsService.registerDisputeAgent(createRegisterDisputeAgentRequest(MEDIATOR));
disputeAgentsService.registerDisputeAgent(createRegisterDisputeAgentRequest(REFUND_AGENT));
}

private bisq.core.payment.PaymentAccount fromProto(protobuf.PaymentAccount proto) {
return bisq.core.payment.PaymentAccount.fromProto(proto, CORE_PROTO_RESOLVER);
}
}
Original file line number Diff line number Diff line change
@@ -2,6 +2,9 @@

import bisq.core.api.model.PaymentAccountForm;
import bisq.core.locale.Res;
import bisq.core.payment.PaymentAccount;

import bisq.proto.grpc.GetPaymentAccountsRequest;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -16,6 +19,7 @@

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

import lombok.extern.slf4j.Slf4j;

@@ -28,6 +32,7 @@
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;


@@ -95,7 +100,10 @@ protected final File getEmptyForm(TestInfo testInfo, String paymentMethodId) {
// A short cut over the API:
// File emptyForm = PAYMENT_ACCOUNT_FORM.getPaymentAccountForm(paymentMethodId);
emptyForm.deleteOnExit();
log.info("{} Empty form saved to {}", testName(testInfo), PAYMENT_ACCOUNT_FORM.getClickableURI(emptyForm));

if (log.isDebugEnabled())
log.debug("{} Empty form saved to {}", testName(testInfo), PAYMENT_ACCOUNT_FORM.getClickableURI(emptyForm));

return emptyForm;
}

@@ -138,4 +146,27 @@ protected final File fillPaymentAccountForm() {
}
return tmpJsonForm;
}

protected final void verifyCommonFormEntries(PaymentAccount paymentAccount) {
// All PaymentAccount subclasses have paymentMethodId and an accountName fields.
assertNotNull(paymentAccount);
assertEquals(EXPECTED_FORM.get(PROPERTY_NAME_PAYMENT_METHOD_ID), paymentAccount.getPaymentMethod().getId());
assertTrue(paymentAccount.getCreationDate().getTime() > 0);
assertEquals(EXPECTED_FORM.get(PROPERTY_NAME_ACCOUNT_NAME), paymentAccount.getAccountName());
}

protected final void verifyAccountFiatCurrency(PaymentAccount paymentAccount, String expectedCurrencyCode) {
assertNotNull(paymentAccount.getSingleTradeCurrency());
assertEquals(expectedCurrencyCode, paymentAccount.getSingleTradeCurrency().getCode());
}

protected final void verifyUserPayloadHasPaymentAccountWithId(String paymentAccountId) {
var getPaymentAccountsRequest = GetPaymentAccountsRequest.newBuilder().build();
var reply = grpcStubs(alicedaemon)
.paymentAccountsService.getPaymentAccounts(getPaymentAccountsRequest);
Optional<protobuf.PaymentAccount> paymentAccount = reply.getPaymentAccountsList().stream()
.filter(a -> a.getId().equals(paymentAccountId))
.findFirst();
assertTrue(paymentAccount.isPresent());
}
}
Loading