Skip to content

Migrate bitcore-node to use chronik #55

@vince8x

Description

@vince8x

Analysis

bws:

  • lib/blochchainexplorers/v8.ts
    • getAddressActivity (/address/:address/txs?limit=1)
    • getTransactionCount (/address/:address/txs/count)
    • estimateGas (/gas)
    • getTokenContractInfo (/token/:tokenAddress)
    • getBlockchainHeight (/block/tip)
    • getTxidsInBlock (/tx/?blockHash=:blockHash)
  • lib/blochchainexplorers/v8/client.ts
    • register (POST /wallet)
    • getBalance (/wallet/:pubKey/balance) or (/address/:contractAddress/balance)
    • getCheckData (/wallet/:pubKey/check)
    • getAddressTxos (/address/:address?unspent=true/false)
    • getTx (/tx/:txid)
    • getCoins (/wallet/:pubKey/utxos?includeSpent=true/false)
    • getCoinsForTx (/tx/:txid/coins)
    • listTransactions (/wallet/:pubKey/transactions?startBlock= & endBlock= & tokenAddress= &multisigContractAddress= &includeMempool=)
    • broadcast (/tx/send)
  • note:
    • find all text "bc.". It's because bc = server._getBlockchainExplorer ()
    • consider add new provider chronik and still keep v8 provider

bitcore-node services

  • Storage
  • Api
  • P2P
  • Worker (is master and not debug)

bitcore-node api routes

  • address.ts
    • /address/:address?unspent=true&limit=10
      • called by getAddressTxos
      • call streamAddressUtxos -> apiStreamingFind(CoinStorage)
    • /address/:address/txs?unpsent=false&limit=10
      • called by getAddressActivity and getTransactionCount
      • call streamCoins -> streamAddressTransactions
    • /address/:address/coins
      • Seems not be called anywhere
      • call streamCoins -> streamAddressTransactions -> apiStreamingFind(CoinStorage)
    • /address/:address/balance
      • Seems not be called anywhere
      • call ChainStateProvider.getBalanceForAddress -> CoinStorage.getBalance (spentHeight, minHeight ?)
  • block.ts
    • /block
      • Need to check if we need all the params query
      • ChainStateProvider.streamBlocks -> getBlocksQuery
    • /block/tip
      • BitcoinBlockStorage.getLocalTip
    • /block/:blockId
      • ChainStateProvider.getBlock -> getBlocksQuery -> BitcoinBlockStorage.collection.find
    • /block/:blockHash/coins/:limit/:pgnum
      • Seems not to be called anywhere, maybe called from insight
    • /block/before-time/:time
      • Seems not to be called anywhere, maybe called from insight
  • fee.ts
    • /fee/:target
      • Called by V8.estimateFee
      • call ChainStateProvider.getFee -> InternalStateProvider.getFee
  • stats.ts (estimate 0)
    • /stats/daily-transactions
      • Not called by bitcore
  • tx.ts
    • /tx
      • query params: { limit, since, direction, paging }
      • called by V8.getTxidsInBlock
      • Need to check if we need since and direction params or not
  • valid.tx
    • /valid/input
      • Can't find it's called from anywhere
  • wallet.ts
    • POST /wallet (create wallet)
      • Called by V8Client.register
      • ChainStateProvider.getWallet (find by pubkey) then ChainStateProvider.createWallet if not exist
    • /address/:pubKey/addresses/missing
      • Not seems to be called
    • /wallet/:pubKey/addresses
      • Called by V8.getAddresses
      • ChainStateProvider.streamWalletAddresses
    • /wallet/:pubKey/check
      • Called by getCheckData
      • Call ChainStateProvider.walletCheck
    • POST /wallet/:pubKey
      • Called by importAddresses
      • ChainStateProvider.updateWallet -> WalletAddressStorage.updateCoins
    • address/:pubKey/transactions
      • Called by listTransactions
        • Check if we need all the params: startBlock= & endBlock= & tokenAddress= &multisigContractAddress= &includeMempool=
        • It seems tokenAddress is used for ethereum, consider ignore includeMempool
      • Call ChainStateProvider.streamWalletTransactions
    • /wallet/:pubKey/balance
      • Called by getBalance
      • ChainStateProvider.getWalletBalance -> CoinStorage.getBalance
      • Note: We don't have map between coins and walletIds anymore if we switch to chronik, so we need to cache or make sure abcpay not all this api too frequently
    • /wallet/:pubKey/balance/:time
      • Seems not to be called - no need to migrate
      • ChainStateProvider.getWalletBalanceAtTime
    • /wallet/:pubKey/utxos
      • Called by getCoins
      • ChainStateProvider.streamWalletUtxos
      • Note: need to find out it's search utxos for specific wallet or all wallets with same id
    • /wallet/:pubKey
      • Call in authenticateMiddleware -> ChainStateProvider.getWallet

bitcore-node

  • providers/chain-state/internal/internal.ts
  • providers/chain-state/internal/transforms.ts

Need to understand how the data is indexed

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions