woodser / monero-ts

TypeScript library for using Monero
http://woodser.github.io/monero-ts/typedocs
MIT License
210 stars 71 forks source link

surprise @ getIncomingTransfers #218

Closed james-mou closed 1 month ago

james-mou commented 3 months ago

Hi,

I got hold of a wallet instance like this:

  this.readonlyWallet = await MoneroTs.createWalletKeys({
    networkType: MoneroTs.MoneroNetworkType.MAINNET,
    primaryAddress: connectionInfo.mainAddress,
    privateViewKey: connectionInfo.privateViewKey,
    restoreHeight: requiredRestoreHeight as number,

    server: {
      uri: `http://127.0.0.1:${RPC_PORT}`,
      username: RPC_USERNAME,
      password: RPC_PASSWORD,
    },
  });

then on a timer, I called getIncomingTransfers on this wallet instance like this and got a "not supported" error, I triple-checked all my input parameters, the values seem to be within reason, so I dug into your source code, MoneroWalletKeys never overrode "getTransfers", which unconditionally throws "not supported" error in its base class MoneroWallet

  const transfers = await this.readonlyWallet.getIncomingTransfers({
    txQuery: {
      isIncoming: true,
      isConfirmed: true,
      height: requiredRestoreHeight as number,
    },
  });

my plan was to loop through all the transfers within that window and compare their subaddressIndex with values I stored in the database (at subaddress generation time), to figure out which ones of these subaddresses have received payments and how much, please advise how I can do that.

I really love the fact that MoneroWalletKeys can work with everything in memory

woodser commented 3 months ago

MoneroWalletKeys is for basic key management only.

Use MoneroWalletFull to scan the blockchain and get transactions and other wallet state.

woodser commented 1 month ago

The new release will correctly throw an error when attempting to create a keys-only wallet with a server.