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

Add rpc method 'getaddressbalance' #4304

Merged
merged 5 commits into from
Jun 25, 2020

Conversation

ghubstan
Copy link
Member

This PR addresses task 2 in issue 4257

This new gRPC Wallet service method displays the balance and number of confirmations for the most recent transaction for the given BTC wallet address.

The new method required the usual boilerplate changes to grpc.proto, CliMain, and GrpcWalletService.

Two unit tests to check error msgs was added to cli/test.sh.

This PR should be reviewed/merged after PR 4299.

This change fixes the ambiguity in the original class name, which
implied it was a btc wallet service, not a bsq and btc wallets service.
This commit includes the following changes:

 * New tests for methods `lockwallet`, `unlockwallet`,
   `removewalletpassword`, and `setwalletpassword`.

 * New `getbalance` method error handing tests to verify
   error message correctness when wallet is locked.

 * Update to `getversion` method test -- now expects `1.3.4`.

 * Check for new `[params]` column header in help text.
This addresses task #1 in issue bisq-network#4257.

This new gRPC WalletService method displays the BTC wallet's list of
receiving addresses.  The balance and number of confirmations
for the most recent transaction is displayed to the right of each
address.  Instead of returning a gRPC data structure to the client,
the service method returns a formatted String.

If the BTC wallet has no unused addresses, one will be created and
included in the returned list, and it can be used to fund the wallet.

The new method required injection of the BtcWalletService into CoreWalletsService,
and the usual boilerplate changes to grpc.proto, CliMain, and GrpcWalletService.

Some of the next PRs (for bisq-network#4257) will require some common functionality within
CoreWalletsService, so these additional changes were included:

  * a private, class level formatSatoshis function
  * a public getNumConfirmationsForMostRecentTransaction method
  * a public getAddressBalance method
  * a private getAddressEntry method

A unit test that verifies a successful return status was added to cli/test.sh.
Cleaned up the method body and improved the returned string's
formatting.  Also added a line for this method in the CLI help text.
This addresses task 2 in issue 4257
	bisq-network#4257

This new gRPC Wallet service method displays the balance and number
of confimirmations of the most recent transaction for the given BTC
wallet address.

The new method required the usual boilerplate changes to grpc.proto,
CliMain, and GrpcWalletService.

Two unit tests to check error msgs was added to cli/test.sh.
ghubstan added a commit to ghubstan/bisq that referenced this pull request Jun 15, 2020
This addresses task 4 in issue 4257.
    bisq-network#4257

This PR should be reviewed/merged after PR 4304.
    bisq-network#4304

This new gRPC Wallet service method creates a dummy PerfectMoney
payment account for the given name, number and fiat currency code,
as part of the required "simplest possible trading API" (for demo).
An implementation supporting all payment methods is not in the
scope.

Changes specific to the new rpc method implementation follow:

* New createpaymentacct method + help text was added to CliMain.
  Help text formatting was also changed to make room for larger
  method names and argument lists.

* The PaymentAccount proto service def was renamed PaymentAccounts
  to avoid a name collision, and the new rpc CreatePaymentAccount
  was made part of the newly named PaymentAccounts service def.

* New GrpcPaymentAccountsService (gRPC boilerplate) and
  CorePaymentAccountsService (method implementations) classes were
  added.

* The gRPC GetPaymentAccountsService stub was moved from GrpcServer
  to the new GrpcPaymentAccountsService class, and
  GrpcPaymentAccountsService is injected into GrpcServer.

* A new createpaymentacct unit test was added to the bats test
  suite (checks for successful return status code).

Maybe bit out of scope, some small changes were made towards making
sure the entire API is defined in CoreApi, which is used as a
pass-through object to the new CorePaymentAccountsService.  In the
next PR, similar refactoring will be done to make CoreApi the
pass-through object for all of the existing CoreWalletsService
methods.  (CoreWalletsService will be injected into CoreApi.)
In the future, all Grpc*Service implementations will call core
services through CoreApi, for the sake of consistency.
ghubstan added a commit to ghubstan/bisq that referenced this pull request Jun 15, 2020
This addresses task 4 in issue 4257.
    bisq-network#4257

This PR should be reviewed/merged after PR 4304.
    bisq-network#4304

This new gRPC PaymentAccounts service method creates a dummy
PerfectMoney payment account for the given name, number and fiat
currency code, as part of the required "simplest possible trading
API" (for demo).   An implementation supporting all payment
methods is not in the scope.

Changes specific to the new rpc method implementation follow:

* New createpaymentacct method + help text was added to CliMain.
  Help text formatting was also changed to make room for larger
  method names and argument lists.

* The PaymentAccount proto service def was renamed PaymentAccounts
  to avoid a name collision, and the new rpc CreatePaymentAccount
  was made part of the newly named PaymentAccounts service def.

* New GrpcPaymentAccountsService (gRPC boilerplate) and
  CorePaymentAccountsService (method implementations) classes were
  added.

* The gRPC GetPaymentAccountsService stub was moved from GrpcServer
  to the new GrpcPaymentAccountsService class, and
  GrpcPaymentAccountsService is injected into GrpcServer.

* A new createpaymentacct unit test was added to the bats test
  suite (checks for successful return status code).

Maybe bit out of scope, some small changes were made towards making
sure the entire API is defined in CoreApi, which is used as a
pass-through object to the new CorePaymentAccountsService.  In the
next PR, similar refactoring will be done to make CoreApi the
pass-through object for all of the existing CoreWalletsService
methods.  (CoreWalletsService will be injected into CoreApi.)
In the future, all Grpc*Service implementations will call core
services through CoreApi, for the sake of consistency.
ghubstan added a commit to ghubstan/bisq that referenced this pull request Jun 15, 2020
This addresses task 4 in issue 4257.
    bisq-network#4257

This PR should be reviewed/merged after PR 4304.
    bisq-network#4304

This new gRPC PaymentAccounts service method creates a dummy
PerfectMoney payment account for the given name, number and fiat
currency code, as part of the required "simplest possible trading
API" (for demo).   An implementation supporting all payment
methods is not in the scope.

Changes specific to the new rpc method implementation follow:

* New createpaymentacct method + help text was added to CliMain.
  Help text formatting was also changed to make room for larger
  method names and argument lists.

* The PaymentAccount proto service def was renamed PaymentAccounts
  to avoid a name collision, and the new rpc CreatePaymentAccount
  was made part of the newly named PaymentAccounts service def.

* New GrpcPaymentAccountsService (gRPC boilerplate) and
  CorePaymentAccountsService (method implementations) classes were
  added.

* The gRPC GetPaymentAccountsService stub was moved from GrpcServer
  to the new GrpcPaymentAccountsService class, and
  GrpcPaymentAccountsService is injected into GrpcServer.

* A new createpaymentacct unit test was added to the bats test
  suite (checks for successful return status code).

Maybe bit out of scope, some small changes were made towards making
sure the entire API is defined in CoreApi, which is used as a
pass-through object to the new CorePaymentAccountsService.  In the
next PR, similar refactoring will be done to make CoreApi the
pass-through object for all of the existing CoreWalletsService
methods.  (CoreWalletsService will be injected into CoreApi.)
In the future, all Grpc*Service implementations will call core
services through CoreApi, for the sake of consistency.
@cbeams cbeams added this to In progress in Ship Bisq Daemon and API Jun 17, 2020
var numConfirmations = getNumConfirmationsForMostRecentTransaction(addressString);
return addressString
+ " balance: " + format("%13s", btcBalance)
+ ((numConfirmations > 0) ? (" confirmations: " + format("%6d", numConfirmations)) : "");
Copy link
Contributor

@dmos62 dmos62 Jun 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A note: formatting logic in getAddressInfo and getFundingAddresses has a fair amount of duplication. Not making suggestions yet, will see what's in the next PRs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to take a look at this next, and any changes I make will be in a new PR associated with a 5-getpaymentaccts sub branch.

Copy link
Contributor

@dmos62 dmos62 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK.

Copy link
Member

@sqrrm sqrrm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@sqrrm sqrrm merged commit ca98654 into bisq-network:master Jun 25, 2020
Ship Bisq Daemon and API automation moved this from In progress to Done Jun 25, 2020
eigentsmis pushed a commit to eigentsmis/bisq that referenced this pull request Jun 26, 2020
This addresses task 4 in issue 4257.
    bisq-network#4257

This PR should be reviewed/merged after PR 4304.
    bisq-network#4304

This new gRPC PaymentAccounts service method creates a dummy
PerfectMoney payment account for the given name, number and fiat
currency code, as part of the required "simplest possible trading
API" (for demo).   An implementation supporting all payment
methods is not in the scope.

Changes specific to the new rpc method implementation follow:

* New createpaymentacct method + help text was added to CliMain.
  Help text formatting was also changed to make room for larger
  method names and argument lists.

* The PaymentAccount proto service def was renamed PaymentAccounts
  to avoid a name collision, and the new rpc CreatePaymentAccount
  was made part of the newly named PaymentAccounts service def.

* New GrpcPaymentAccountsService (gRPC boilerplate) and
  CorePaymentAccountsService (method implementations) classes were
  added.

* The gRPC GetPaymentAccountsService stub was moved from GrpcServer
  to the new GrpcPaymentAccountsService class, and
  GrpcPaymentAccountsService is injected into GrpcServer.

* A new createpaymentacct unit test was added to the bats test
  suite (checks for successful return status code).

Maybe bit out of scope, some small changes were made towards making
sure the entire API is defined in CoreApi, which is used as a
pass-through object to the new CorePaymentAccountsService.  In the
next PR, similar refactoring will be done to make CoreApi the
pass-through object for all of the existing CoreWalletsService
methods.  (CoreWalletsService will be injected into CoreApi.)
In the future, all Grpc*Service implementations will call core
services through CoreApi, for the sake of consistency.
@ghubstan ghubstan deleted the 2-getaddressbalance branch June 26, 2020 20:42
@ripcurlx ripcurlx added this to the v1.3.6 milestone Jul 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants