How to use the @shapeshiftoss/hdwallet-core.arrayify function in @shapeshiftoss/hdwallet-core

To help you get started, we’ve selected a few @shapeshiftoss/hdwallet-core 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 shapeshift / hdwallet / packages / hdwallet-keepkey / src / ethereum.ts View on Github external
return transport.lockDuring(async () => {
    const est: EthereumSignTx = new EthereumSignTx()
    est.setAddressNList(msg.addressNList)
    est.setNonce(arrayify(msg.nonce))
    est.setGasPrice(arrayify(msg.gasPrice))
    est.setGasLimit(arrayify(msg.gasLimit))
    if (msg.value.match('^0x0*$') === null) {
      est.setValue(arrayify(msg.value))
    }

    if (msg.toAddressNList) {
      est.setAddressType(OutputAddressType.SPEND)
      est.setToAddressNList(msg.toAddressNList)
    } else if (msg.exchangeType) {
      est.setAddressType(OutputAddressType.EXCHANGE)

      const signedHex = base64toHEX(msg.exchangeType.signedExchangeResponse)
      const signedExchangeOut = SignedExchangeResponse.deserializeBinary(arrayify(signedHex))
      const exchangeType = new ExchangeType()
      exchangeType.setSignedExchangeResponse(signedExchangeOut)
      exchangeType.setWithdrawalCoinName(msg.exchangeType.withdrawalCoinName) // KeepKey firmware will complain if this doesn't match signed exchange response
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / ethereum.ts View on Github external
est.setAddressNList(msg.addressNList)
    est.setNonce(arrayify(msg.nonce))
    est.setGasPrice(arrayify(msg.gasPrice))
    est.setGasLimit(arrayify(msg.gasLimit))
    if (msg.value.match('^0x0*$') === null) {
      est.setValue(arrayify(msg.value))
    }

    if (msg.toAddressNList) {
      est.setAddressType(OutputAddressType.SPEND)
      est.setToAddressNList(msg.toAddressNList)
    } else if (msg.exchangeType) {
      est.setAddressType(OutputAddressType.EXCHANGE)

      const signedHex = base64toHEX(msg.exchangeType.signedExchangeResponse)
      const signedExchangeOut = SignedExchangeResponse.deserializeBinary(arrayify(signedHex))
      const exchangeType = new ExchangeType()
      exchangeType.setSignedExchangeResponse(signedExchangeOut)
      exchangeType.setWithdrawalCoinName(msg.exchangeType.withdrawalCoinName) // KeepKey firmware will complain if this doesn't match signed exchange response
      exchangeType.setWithdrawalAddressNList(msg.exchangeType.withdrawalAddressNList)
      exchangeType.setWithdrawalScriptType(translateInputScriptType(
        msg.exchangeType.withdrawalScriptType || BTCInputScriptType.SpendAddress))
      exchangeType.setReturnAddressNList(msg.exchangeType.returnAddressNList)
      exchangeType.setReturnScriptType(translateInputScriptType(
        msg.exchangeType.returnScriptType || BTCInputScriptType.SpendAddress))
      est.setExchangeType(exchangeType)
    } else {
      est.setAddressType(OutputAddressType.SPEND)
    }

    if (msg.to) {
      est.setTo(arrayify(msg.to))
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / ethereum.ts View on Github external
return transport.lockDuring(async () => {
    const est: EthereumSignTx = new EthereumSignTx()
    est.setAddressNList(msg.addressNList)
    est.setNonce(arrayify(msg.nonce))
    est.setGasPrice(arrayify(msg.gasPrice))
    est.setGasLimit(arrayify(msg.gasLimit))
    if (msg.value.match('^0x0*$') === null) {
      est.setValue(arrayify(msg.value))
    }

    if (msg.toAddressNList) {
      est.setAddressType(OutputAddressType.SPEND)
      est.setToAddressNList(msg.toAddressNList)
    } else if (msg.exchangeType) {
      est.setAddressType(OutputAddressType.EXCHANGE)

      const signedHex = base64toHEX(msg.exchangeType.signedExchangeResponse)
      const signedExchangeOut = SignedExchangeResponse.deserializeBinary(arrayify(signedHex))
      const exchangeType = new ExchangeType()
      exchangeType.setSignedExchangeResponse(signedExchangeOut)
      exchangeType.setWithdrawalCoinName(msg.exchangeType.withdrawalCoinName) // KeepKey firmware will complain if this doesn't match signed exchange response
      exchangeType.setWithdrawalAddressNList(msg.exchangeType.withdrawalAddressNList)
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / ethereum.ts View on Github external
return transport.lockDuring(async () => {
    const est: EthereumSignTx = new EthereumSignTx()
    est.setAddressNList(msg.addressNList)
    est.setNonce(arrayify(msg.nonce))
    est.setGasPrice(arrayify(msg.gasPrice))
    est.setGasLimit(arrayify(msg.gasLimit))
    if (msg.value.match('^0x0*$') === null) {
      est.setValue(arrayify(msg.value))
    }

    if (msg.toAddressNList) {
      est.setAddressType(OutputAddressType.SPEND)
      est.setToAddressNList(msg.toAddressNList)
    } else if (msg.exchangeType) {
      est.setAddressType(OutputAddressType.EXCHANGE)

      const signedHex = base64toHEX(msg.exchangeType.signedExchangeResponse)
      const signedExchangeOut = SignedExchangeResponse.deserializeBinary(arrayify(signedHex))
      const exchangeType = new ExchangeType()
      exchangeType.setSignedExchangeResponse(signedExchangeOut)
      exchangeType.setWithdrawalCoinName(msg.exchangeType.withdrawalCoinName) // KeepKey firmware will complain if this doesn't match signed exchange response
      exchangeType.setWithdrawalAddressNList(msg.exchangeType.withdrawalAddressNList)
      exchangeType.setWithdrawalScriptType(translateInputScriptType(
        msg.exchangeType.withdrawalScriptType || BTCInputScriptType.SpendAddress))
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / ethereum.ts View on Github external
const exchangeType = new ExchangeType()
      exchangeType.setSignedExchangeResponse(signedExchangeOut)
      exchangeType.setWithdrawalCoinName(msg.exchangeType.withdrawalCoinName) // KeepKey firmware will complain if this doesn't match signed exchange response
      exchangeType.setWithdrawalAddressNList(msg.exchangeType.withdrawalAddressNList)
      exchangeType.setWithdrawalScriptType(translateInputScriptType(
        msg.exchangeType.withdrawalScriptType || BTCInputScriptType.SpendAddress))
      exchangeType.setReturnAddressNList(msg.exchangeType.returnAddressNList)
      exchangeType.setReturnScriptType(translateInputScriptType(
        msg.exchangeType.returnScriptType || BTCInputScriptType.SpendAddress))
      est.setExchangeType(exchangeType)
    } else {
      est.setAddressType(OutputAddressType.SPEND)
    }

    if (msg.to) {
      est.setTo(arrayify(msg.to))
    }

    let dataChunk = null
    let dataRemaining = undefined

    if (msg.data) {
      dataRemaining = arrayify(msg.data)
      est.setDataLength(dataRemaining.length)
      dataChunk = dataRemaining.slice(0, 1024)
      dataRemaining = dataRemaining.slice(dataChunk.length)
      est.setDataInitialChunk(dataChunk)
    }

    if (msg.chainId !== undefined) {
      est.setChainId(msg.chainId)
    }
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / ethereum.ts View on Github external
return transport.lockDuring(async () => {
    const est: EthereumSignTx = new EthereumSignTx()
    est.setAddressNList(msg.addressNList)
    est.setNonce(arrayify(msg.nonce))
    est.setGasPrice(arrayify(msg.gasPrice))
    est.setGasLimit(arrayify(msg.gasLimit))
    if (msg.value.match('^0x0*$') === null) {
      est.setValue(arrayify(msg.value))
    }

    if (msg.toAddressNList) {
      est.setAddressType(OutputAddressType.SPEND)
      est.setToAddressNList(msg.toAddressNList)
    } else if (msg.exchangeType) {
      est.setAddressType(OutputAddressType.EXCHANGE)

      const signedHex = base64toHEX(msg.exchangeType.signedExchangeResponse)
      const signedExchangeOut = SignedExchangeResponse.deserializeBinary(arrayify(signedHex))
      const exchangeType = new ExchangeType()
      exchangeType.setSignedExchangeResponse(signedExchangeOut)
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / ethereum.ts View on Github external
exchangeType.setReturnScriptType(translateInputScriptType(
        msg.exchangeType.returnScriptType || BTCInputScriptType.SpendAddress))
      est.setExchangeType(exchangeType)
    } else {
      est.setAddressType(OutputAddressType.SPEND)
    }

    if (msg.to) {
      est.setTo(arrayify(msg.to))
    }

    let dataChunk = null
    let dataRemaining = undefined

    if (msg.data) {
      dataRemaining = arrayify(msg.data)
      est.setDataLength(dataRemaining.length)
      dataChunk = dataRemaining.slice(0, 1024)
      dataRemaining = dataRemaining.slice(dataChunk.length)
      est.setDataInitialChunk(dataChunk)
    }

    if (msg.chainId !== undefined) {
      est.setChainId(msg.chainId)
    }

    let response: EthereumTxRequest
    let nextResponse = await transport.call(MessageType.MESSAGETYPE_ETHEREUMSIGNTX, est, LONG_TIMEOUT, /*omitLock=*/true)
    if (nextResponse.message_enum === MessageType.MESSAGETYPE_FAILURE) {
      throw nextResponse
    }
    response = nextResponse.proto as EthereumTxRequest
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / ethereum.ts View on Github external
export async function ethVerifyMessage (transport: KeepKeyTransport, msg: ETHVerifyMessage): Promise {
  const m = new EthereumVerifyMessage()
  m.setAddress(arrayify(msg.address))
  m.setSignature(arrayify(msg.signature))
  m.setMessage(toUTF8Array(msg.message))
  const event = await transport.call(MessageType.MESSAGETYPE_ETHEREUMVERIFYMESSAGE, m, LONG_TIMEOUT) as Event
  const success = event.proto as Success
  return success.getMessage() === 'Message verified'
}
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / bitcoin.ts View on Github external
export async function btcVerifyMessage (wallet: BTCWallet, transport: KeepKeyTransport, msg: BTCVerifyMessage): Promise {
  await ensureCoinSupport(wallet, msg.coin)
  const verify = new VerifyMessage()
  verify.setAddress(msg.address)
  verify.setSignature(arrayify('0x' + msg.signature))
  verify.setMessage(toUTF8Array(msg.message))
  verify.setCoinName(msg.coin)
  let event = await transport.call(MessageType.MESSAGETYPE_VERIFYMESSAGE, verify)
  if (event.message_enum === MessageType.MESSAGETYPE_FAILURE) {
    return false
  }
  const success = event.proto as Success
  return success.getMessage() === "Message verified"
}
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / ethereum.ts View on Github external
export async function ethVerifyMessage (transport: KeepKeyTransport, msg: ETHVerifyMessage): Promise {
  const m = new EthereumVerifyMessage()
  m.setAddress(arrayify(msg.address))
  m.setSignature(arrayify(msg.signature))
  m.setMessage(toUTF8Array(msg.message))
  const event = await transport.call(MessageType.MESSAGETYPE_ETHEREUMVERIFYMESSAGE, m, LONG_TIMEOUT) as Event
  const success = event.proto as Success
  return success.getMessage() === 'Message verified'
}