How to use the @liquality/utils.Address function in @liquality/utils

To help you get started, we’ve selected a few @liquality/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github liquality / chainabstractionlayer / packages / litecoin-js-wallet-provider / lib / LitecoinJsWalletProvider.js View on Github external
async getAddresses (startingIndex = 0, numAddresses = 1, change = false) {
    if (numAddresses < 1) { throw new Error('You must return at least one address') }

    const node = await this.node()

    const addresses = []
    const lastIndex = startingIndex + numAddresses
    const changeVal = change ? '1' : '0'

    for (let currentIndex = startingIndex; currentIndex < lastIndex; currentIndex++) {
      const subPath = changeVal + '/' + currentIndex
      const path = this._derivationPath + subPath
      const publicKey = node.derivePath(path).publicKey
      const address = this.getAddressFromPublicKey(publicKey)

      addresses.push(new Address({
        address,
        publicKey,
        derivationPath: path,
        index: currentIndex
      }))
    }

    return addresses
  }
github liquality / chainabstractionlayer / packages / ethereum-js-wallet-provider / lib / EthereumJsWalletProvider.js View on Github external
async getAddresses () {
    const derivationPath = this._derivationPath + '0/0'
    const hdKey = await this.hdKey(derivationPath)
    const address = ethUtil.privateToAddress(hdKey._privateKey).toString('hex')
    const publicKey = ethUtil.privateToPublic(hdKey._privateKey).toString('hex')
    return [
      new Address({
        address,
        derivationPath,
        publicKey,
        index: 0
      })
    ]
  }
github liquality / chainabstractionlayer / packages / bitcoin-node-wallet-provider / lib / BitcoinNodeWalletProvider.js View on Github external
async getNewAddress (addressType, label = '') {
    const params = addressType ? [label, addressType] : [label]
    const newAddress = await this._rpc.jsonrpc('getnewaddress', ...params)

    if (!newAddress) return null

    return new Address(newAddress)
  }
github liquality / chainabstractionlayer / packages / bitcoin-ledger-provider / lib / BitcoinLedgerProvider.js View on Github external
Buffer.from(compressedPubKey, 'hex'),
      Buffer.from(walletPubKey.chainCode, 'hex'),
      this._network
    )

    const addresses = []
    const lastIndex = startingIndex + numAddresses
    const changeVal = change ? '1' : '0'

    for (let currentIndex = startingIndex; currentIndex < lastIndex; currentIndex++) {
      const subPath = changeVal + '/' + currentIndex
      const publicKey = node.derivePath(subPath).publicKey
      const address = pubKeyToAddress(publicKey, this._network.name, 'pubKeyHash')
      const path = this._baseDerivationPath + subPath

      addresses.push(new Address({
        address,
        publicKey: publicKey.toString('hex'),
        derivationPath: path,
        index: currentIndex
      }))
    }

    return addresses
  }
github liquality / chainabstractionlayer / packages / bitcoin-js-wallet-provider / lib / BitcoinJsWalletProvider.js View on Github external
async getAddresses (startingIndex = 0, numAddresses = 1, change = false) {
    if (numAddresses < 1) { throw new Error('You must return at least one address') }

    const node = await this.node()

    const addresses = []
    const lastIndex = startingIndex + numAddresses
    const changeVal = change ? '1' : '0'

    for (let currentIndex = startingIndex; currentIndex < lastIndex; currentIndex++) {
      const subPath = changeVal + '/' + currentIndex
      const path = this._derivationPath + subPath
      const publicKey = node.derivePath(path).publicKey
      const address = this.getAddressFromPublicKey(publicKey)

      addresses.push(new Address({
        address,
        publicKey,
        derivationPath: path,
        index: currentIndex
      }))
    }

    return addresses
  }

@liquality/utils

[![Build Status](https://travis-ci.com/liquality/chainabstractionlayer.svg?branch=master)](https://travis-ci.com/liquality/chainabstractionlayer) [![Coverage Status](https://coveralls.io/repos/github/liquality/chainabstractionlayer/badge.svg?branch=master

MIT
Latest version published 2 years ago

Package Health Score

52 / 100
Full package analysis

Similar packages