mimblewimble / grin-wallet

Grin Wallet
Apache License 2.0
182 stars 133 forks source link

Getting the transaction list by the block height (Owner API) #595

Open davidtavarez opened 3 years ago

davidtavarez commented 3 years ago

I would like to filter the transaction list by block height. Right now, for retrieve_txs we have this:

{
  "jsonrpc": "2.0",
  "method": "retrieve_txs",
  "params": {
   "token": "token",
   "refresh_from_node": true,
   "tx_id": null,
   "tx_slate_id": null,
  },
  "id": 1
 }

I would like to also send confirm_height as a parameter, like this for example:

{
  "jsonrpc": "2.0",
  "method": "retrieve_txs",
  "params": {
   "token": "token",
   "refresh_from_node": true,
   "tx_id": null,
   "tx_slate_id": null,
   "confirm_height":  1127853,
  },
  "id": 1
 }
davidtavarez commented 3 years ago

I can't see if the confirmed block height is stored: https://github.com/mimblewimble/grin-wallet/blob/master/libwallet/src/types.rs#L792 or returned https://github.com/mimblewimble/grin-wallet/blob/master/libwallet/src/internal/updater.rs#L93

Is there any workaround for this?

pkariz commented 3 years ago

I think i know why exchanges might need this for the deposit flow (if they use SRS flow - afaik they all do that currently). The problem is that after the exchange does R part of SRS, there exists the final kernel excess (X), but from the slates (which you get from wallet-api calls) you can only get Xs and Xr (in hex compressed). Now you have 2 options: 1) you get Xs and Xr, calculate X = Xs + Xr and hex compress it (that seems painful to me and prone to errors in implementations) 2) you call retrieve_txs(tx_slate_id=<...>)[0]['kernel_excess'] to get the excess (easy way) The problem is that exchanges have many transactions and it would be good to limit the returned transactions by block height (it's easy to know for exchanges by which height to filter) - ignore if it's already done in O(1) when tx_slate_id is passed

The current TxLogEntry doesn't seem to have the "confirmed" block stored

trevyn commented 3 years ago

@davidtavarez If you're interested in digging a bit deeper on this one, I can personally offer a bounty of US$1,000 paid in BTC if you can figure out a PR for this.