[bisq-network/bisq] [WIP] Implement simplest possible trading script (#4257)

Stan notifications at github.com
Thu May 14 20:28:22 UTC 2020


After implementing rpc wallet protection methods ([ISSUE 4214](https://github.com/bisq-network/bisq/issues/4198) + [PR 4214](https://github.com/bisq-network/bisq/pull/4214)), we need a  minimum set of endpoints to enable trading from the gRPC API, and a bats script for test / demo purposes.

The goal of the set of PRs that will accompany this issue is to allow a user to perform all of the following functions with the gRPC API  (the UI should not be needed for any setup):

- [ ] List BTC Receiving/Funding/Deposit Addresses 
  [TODO Pick method name part Receiving || Funding || Deposit] 
  [TODO combine this and two following tasks into a single task (method).]

  Method Signature:	`listfundaddress ["addr"]`	

  Show all receive/deposit/funding addresses, similar to  UI -> FUNDS -> RECEIVE FUNDS list box, or one receive/deposit/funding address.    Outputs array of BTC address, balance, # confirmations, usage ("Unused", "Used in N transaction(s)).

  Analog to [listreceivedbyaddress](https://bitcoincore.org/en/doc/0.19.0/rpc/wallet/listreceivedbyaddress)

- [ ] List Used BTC Receiving Addresses

  Method Signature:	`listfundaddress used`

  Show all used receive/deposit/funding addresses.

- [ ] List Unused BTC Receiving Address
  
  Method Signature:	`listfundaddress unused`

  Show zero or one unused receive/deposit/funding address.

  See `DepositView` -> `walletService.getAvailableAddressEntries()...`                
  See `BtcWalletService` ->  `public List<AddressEntry> getAvailableAddressEntries()`

- [ ] Create New BTC Deposit Address
  
  [TODO Pick method name part Receiving || Funding || Deposit] 

  Method Signature:	`newdepositaddress`

  If an unused receive address exists, show `funds.deposit.selectUnused` error message, plus the existing unused address.

  See `DepositView` -> `newSavingsAddressEntry = walletService.getFreshAddressEntry()`
  See `BtcWalletService` -> `public AddressEntry getFreshAddressEntry()`
  
  Analog to [getnewaddress](https://bitcoincore.org/en/doc/0.19.0/rpc/wallet/getnewaddress) 

- [ ] Fund a BTC wallet

  No new method is needed to fund a wallet.  User sends BTC from an external wallet to a Bisq "Fund your wallet" address, then awaits confirmations.

  Use Case:
      User sends BTC via `bitcoin-cli sendtoaddress "addr" amt`
      User queries the status of the funding tx by calling `listfundaddress "addr"`

- [ ] Create a payment method

  Method Signature:	`createpaymentacct acct-name paymentmethod acct-number currency`

  (The different payment methods will have different attributes, the above signature is specific to PerfectMoney)

  In the interest in keeping it simple at this stage, the 1st impl can only create a "PerfectMoney dummy" account, mimicking the default payment method created by the UI when running Bisq in regtest / dev mode with the DAO setup used to test every new release.
  
- [ ] List Offers

  Method Signature:	`listoffers currency`  	[all offers]
  Method Signature:	`listbuyoffers currency`	
  Method Signature:	`listselloffers currency`

  Output would display same info as UI's Offer Book, plus a unique identifier to be used in
a `takeoffer` method.


- [ ] Create Offer

  Method Signature:	`createoffer buy|sell [TBD]`	

  BUY  Offer Parameters:  `payment-method  amt  currency  pct-from-mkt-price  min-amt [pct-sec-deposit]`

  SELL Offer Parameters:  `payment-method  amt  currency  pct-from-mkt-price  min-amt [pct-sec-deposit]`

  _Note: there may be differences in the non-unique BUY/SELL offer params shown above (todo)._

  Offer details are cached in a CoreTradeService object, and user is shown review details + Toc, and 
the offer's unique identifier (analog to btc tx-id), or, an offer creation failure / rejection error message.

  If the offer is valid, it can be broadcast using the unique id;  see Broadcast Offer.

  Only one offer can be cached at a time.  Every new offer will override a previously cached offer.

  Funding source defaults to Bisq wallet.
  Fee currency defaults to BTC. 
  (Support for displaying Bsq balance and paying trade fee with Bsq not in scope.)

- [ ] Broadcast Offer  (Or Confirm Offer)

  Method Signature:	`broadcastoffer offer-id`  OR  `confirmoffer offer-id`

  Confirm and broadcast a valid offer cached by `createoffer`.

  Validates details of offer before broadcasting it, then displays success (with id) or fail reason message.

- [ ] Take Offer

  Method Signature:	`takeoffer offer-id`	

  After trade is funded, offer details are cached in the `CoreTradeService`, and user is shown review details + Toc, and the offer's unique identifier (analog to btc tx-id), or, an offer creation failure error message.

  If the funded offer is valid, it can be broadcast using the unique id:  `confirmtakeoffer offer-id`

  Only one offer can be cached at a time.  Every new offer will override a previously cached offer.

  Taker must have a matching payment-method associated with selected offer.

  Funding source defaults to Bisq wallet.
  Fee currency defaults to BTC. 
  (Support for displaying Bsq balance and paying trade fee with BSQ not in scope.)

- [ ] Confirm Take Offer

  Method Signature:	`confirmtakeoffer offer-id`

  Confirm and begin the payment protocol started by `takeoffer offer-id`

  Validates details of offer before broadcasting it, then displays success (with id) or fail reason message.

- [ ] Query Offer Status

  Method Signature:	`offerstatus offer-id`	

  Displays status of offer, including trade protocol steps that have and have not been completed.

  Offer creators & takers will see different offer status information, but both will see the same 
initial state:	

    `WAITING_FOR_BLOCKCHAIN_CONFIRMATION` (of deposit fees)

  Offer States seen by Takers:

	`START_PAYMENT`
	`WAITING_FOR_PAYMENT_ARRIVAL`

  Offer States seen by Creators:

	`WAITING_FOR_PAYMENT`
	`PAYMENT_RECEIVED`

  Note: there may be some states unique to SELL offer creators/takers and BUY offer creators/takers.			

  Creators and takers will also see the same final status:

 	`COMPLETED` (can move funds)
 	
- [ ] Start Payment

  Method Signature:	`paymentstarted offer-id`		

  Called by BTC buyers after submitting a payment.
		
- [ ] Payment Received

  Method Signature:	`paymentreceived offer-id`		

  Called by BTC sellers after receiving a payment.

- [ ] Cancel Offer

  Method Signature:	`canceloffer offer-id`

  Allow user to cancel an existing offer that has not passed the `START_PAYMENT` stage of the trade protocol.

- [ ] Move BTC from completed trades to Bisq BTC wallet

  Method Signature:	`movefunds`    

  Move BTC funds and trade fees to Bisq wallet after a successful trade completion.

- [ ] Withdraw BTC to an external wallet

  Method Signature:	`withdrawbtc "addr"`    

  Withdraw BTC from Bisq wallet to external BTC address
	

-- 
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/issues/4257
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20200514/5f031d5b/attachment.html>


More information about the bisq-github mailing list