How to use the @keepkey/device-protocol/lib/types_pb.OutputAddressType.SPEND function in @keepkey/device-protocol

To help you get started, we’ve selected a few @keepkey/device-protocol 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
      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)
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / bitcoin.ts View on Github external
outExchangeType.setReturnAddressNList(output.exchangeType.returnAddressNList)
      outExchangeType.setReturnScriptType(translateInputScriptType(
        output.exchangeType.returnScriptType || BTCInputScriptType.SpendAddress))
      newOutput.setAmount(val)
      newOutput.setAddress(signedExchange.toObject().responsev2.depositAddress.address)
      newOutput.setScriptType(OutputScriptType.PAYTOADDRESS)
      newOutput.setAddressType(OutputAddressType.EXCHANGE)
      newOutput.setExchangeType(outExchangeType)
    } else if (output.isChange) {
      newOutput.setScriptType(translateOutputScriptType(output.scriptType))
      newOutput.setAddressNList(output.addressNList)
      newOutput.setAddressType(OutputAddressType.CHANGE)
    } else {
      newOutput.setScriptType(OutputScriptType.PAYTOADDRESS)
      newOutput.setAddress(output.address)
      newOutput.setAddressType(OutputAddressType.SPEND)
    }
    unsignedTx.addOutputs(newOutput, k)
  })

@keepkey/device-protocol

The proto buffer files from the KeepKey device, packed for consumption by the client.

ISC
Latest version published 3 months ago

Package Health Score

60 / 100
Full package analysis

Similar packages