[bisq-network/bisq] API POC: Use json form to create fiat payment accts (#4813)

Stan notifications at github.com
Mon Nov 16 17:21:24 CET 2020


These changes show how the API could create any exiting fiat `PaymentAccount` with a single CLI parameter, using reflection and json.

The idea is to use the CLI to create fiat accounts in four simple steps, as opposed to figuring out how to correctly pass a complicated set of parameters to a CLI `createpaymentacct` command.  The steps are:

1.  Get a list of payment account method IDs, e.g., 

    `$ getpaymentmethods`    -- returns list of payment method IDs and descriptions

2.  Ask for a payment account (json) form, e.g.,

    `$ getpaymentacctform  japan_bank`  (a paymentMethodId)    -- returns a json file with fields specific to the payment method

3.  Edit the returned json file, i.e., `japan_bank_form.json` with the user's file editor.

4.  Submit the payment account json form via the CLI.

    `$ createpaymentacct  japan_bank_form.json`
  

The PR adds the new classes needed to generate a payment account json form for a given `paymentMethodId` (serialize only the necessary fields in a `PaymentAccount` subclass to json file), and de-serialize an edited json form into a `PaymentAccount` instance.  

Changes include

- A new `isCountryBasedPaymentAccount` method in the abstract  `PaymentAccount`, to help in serialization / de-serialization.

- A new `ReflectionUtils` class in the `common.util.pkg`.

- A new gson `PaymentAccountTypeAdapter` in `core.api.model`, for doing the `PaymentAccount` serialization and de-serialization
  work.
  
- A new `PaymentAccountForm` class in `core.api.model`, to be used  by the server, for creating new fiat accounts from json   forms.
  
- A new `PaymentAccountFormTest` to prove this scheme works.  

This new `PaymentAccount` serialization / de-serialization scheme is  not exposed in the API yet, nor are de-serialized `PaymentAccount` instances persisted.  The only change to existing code is the new `boolean isCountryBasedPaymentAccount()` method added to abstract `PaymentAccount`.

This is the 13th in a chain of PRs beginning with https://github.com/bisq-network/bisq/pull/4793.  

PR https://github.com/bisq-network/bisq/pull/4808 should be reviewed before this one.

_Note:  Several log statements exist to aid travis ci debugging of the test case, if it fails.  They will be removed._
You can view, comment on, or merge this pull request online at:

  https://github.com/bisq-network/bisq/pull/4813

-- Commit Summary --

  * Define new grpc bsq/btc balances protos
  * Add proto wrappers for serving bsq, btc or all balances
  * Define proto for api method 'getunusedbsqaddress'
  * Define proto fapi method 'sendbsq'
  * Add proto fields to support trade fee currency choice
  * Implement and test api method 'getunusedbsqaddress'
  * Add teardown to test case
  * Remove trailing spaces in blank line
  * Implement and test new getbalance(s) api methods
  * Resolve unnecessary use of fully qualified name for codacy
  * Stub out api method 'sendbsq' in core
  * Re comment sendbsq tests so travis ci does not fail
  * Refactor desktop's BsqSendView, share with api
  * Resolve 'Avoid creating BigDecimal with a decimal' issue for codacy
  * Support paying trade fees in bsq or btc (api)
  * Delete deprecated api test, adjust api build/run doc
  * Refactor api getbalance methods.
  * Fix typo
  * Remove unnecessary fully qualified name
  * Remove unused imports
  * Add new ReflectionUtils to support Json <-> PaymentAccount transform
  * Add new gson TypeAdapter<PaymentAccount>
  * Add new PaymentAccountForm singleton to read & write json forms
  * Add new isCountryBasedPaymentAccount method
  * Test PaymentAccountForm

-- File Changes --

    M apitest/docs/build-run.md (2)
    D apitest/src/test/java/bisq/apitest/method/GetBalanceTest.java (73)
    M apitest/src/test/java/bisq/apitest/method/MethodTest.java (59)
    M apitest/src/test/java/bisq/apitest/method/offer/AbstractOfferTest.java (24)
    M apitest/src/test/java/bisq/apitest/method/offer/CancelOfferTest.java (1)
    M apitest/src/test/java/bisq/apitest/method/offer/CreateOfferUsingFixedPriceTest.java (11)
    M apitest/src/test/java/bisq/apitest/method/offer/CreateOfferUsingMarketPriceMarginTest.java (14)
    M apitest/src/test/java/bisq/apitest/method/offer/ValidateCreateOfferTest.java (1)
    M apitest/src/test/java/bisq/apitest/method/trade/AbstractTradeTest.java (20)
    M apitest/src/test/java/bisq/apitest/method/trade/TakeBuyBTCOfferTest.java (18)
    M apitest/src/test/java/bisq/apitest/method/trade/TakeSellBTCOfferTest.java (18)
    A apitest/src/test/java/bisq/apitest/method/wallet/BsqWalletTest.java (244)
    A apitest/src/test/java/bisq/apitest/method/wallet/BtcWalletTest.java (107)
    R apitest/src/test/java/bisq/apitest/method/wallet/WalletProtectionTest.java (22)
    D apitest/src/test/java/bisq/apitest/scenario/FundWalletScenarioTest.java (76)
    M apitest/src/test/java/bisq/apitest/scenario/WalletTest.java (50)
    M cli/src/main/java/bisq/cli/CliMain.java (82)
    M cli/src/main/java/bisq/cli/ColumnHeaderConstants.java (13)
    M cli/src/main/java/bisq/cli/CurrencyFormat.java (9)
    M cli/src/main/java/bisq/cli/TableFormat.java (76)
    A common/src/main/java/bisq/common/util/ReflectionUtils.java (108)
    M core/src/main/java/bisq/core/api/CoreApi.java (18)
    M core/src/main/java/bisq/core/api/CoreOffersService.java (8)
    M core/src/main/java/bisq/core/api/CoreTradesService.java (8)
    M core/src/main/java/bisq/core/api/CoreWalletsService.java (133)
    A core/src/main/java/bisq/core/api/model/BalancesInfo.java (45)
    A core/src/main/java/bisq/core/api/model/BsqBalanceInfo.java (94)
    A core/src/main/java/bisq/core/api/model/BtcBalanceInfo.java (75)
    M core/src/main/java/bisq/core/api/model/OfferInfo.java (10)
    A core/src/main/java/bisq/core/api/model/PaymentAccountForm.java (211)
    A core/src/main/java/bisq/core/api/model/PaymentAccountTypeAdapter.java (324)
    A core/src/main/java/bisq/core/btc/model/BsqTransferModel.java (77)
    A core/src/main/java/bisq/core/btc/wallet/BsqTransferService.java (59)
    M core/src/main/java/bisq/core/offer/OfferUtil.java (18)
    M core/src/main/java/bisq/core/payment/PaymentAccount.java (4)
    A core/src/test/java/bisq/core/api/model/PaymentAccountFormTest.java (477)
    M daemon/src/main/java/bisq/daemon/grpc/GrpcOffersService.java (1)
    M daemon/src/main/java/bisq/daemon/grpc/GrpcTradesService.java (1)
    M daemon/src/main/java/bisq/daemon/grpc/GrpcWalletsService.java (75)
    M desktop/src/main/java/bisq/desktop/main/dao/wallet/send/BsqSendView.java (41)
    M proto/src/main/proto/grpc.proto (69)

-- Patch Links --

https://github.com/bisq-network/bisq/pull/4813.patch
https://github.com/bisq-network/bisq/pull/4813.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/4813
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20201116/120482a3/attachment-0001.html>


More information about the bisq-github mailing list