How to use the @shapeshiftoss/hdwallet-core.fromHexString 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 / bitcoin.ts View on Github external
txOutput.setAmount(satsFromStr(vout.value))
      txOutput.setScriptPubkey(fromHexString(vout.scriptPubKey.hex))
      tx.addBinOutputs(txOutput, i)
    })

    if (coin === "Dash") {
      let dip2_type: number = inputTx.tx.type
      // DIP2 Special Tx with payload
      if (inputTx.tx.version === 3 && dip2_type !== 0) {
        if (!inputTx.tx.extraPayload || !inputTx.tx.extraPayloadSize)
          throw new Error("Payload missing in DIP2 transaction")

        if (inputTx.tx.extraPayloadSize * 2 !== inputTx.tx.extraPayload.length)
          throw new Error("DIP2 Payload length mismatch")

        tx.setExtraData(fromHexString(packVarint(inputTx.tx.extraPayloadSize) + inputTx.tx.extraPayload))
      }

      // Trezor (and therefore KeepKey) firmware doesn't understand the
      // split of version and type, so let's mimic the old serialization
      // format
      tx.setVersion(tx.getVersion() | dip2_type << 16)
    }

    txmap[inputTx.txid] = tx
  })
github shapeshift / hdwallet / packages / hdwallet-trezor / src / bitcoin.ts View on Github external
export async function btcVerifyMessage (transport: TrezorTransport, msg: BTCVerifyMessage): Promise {
  let res = await transport.call('verifyMessage', {
    address: msg.address,
    message: msg.message,
    signature: Base64.fromByteArray(fromHexString(msg.signature)),
    coin: translateCoin(msg.coin)
  })

  if (!res.success && res.payload.error === 'Invalid signature')
    return false

  handleError(transport, res, "Could not verify message with Trezor")

  return res.payload.message === "Message verified"
}
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / bitcoin.ts View on Github external
inputTx.tx.vin.forEach((vin, i) => {
      const txInput = new TxInputType()
      if (vin.coinbase !== undefined) {
        txInput.setPrevHash(fromHexString("\0".repeat(64)))
        txInput.setPrevIndex(0xffffffff)
        txInput.setScriptSig(fromHexString(vin.coinbase))
        txInput.setSequence(vin.sequence)
      } else {
        txInput.setPrevHash(fromHexString(vin.txid))
        txInput.setPrevIndex(vin.vout)
        txInput.setScriptSig(fromHexString(vin.scriptSig.hex))
        txInput.setSequence(vin.sequence)
      }
      tx.addInputs(txInput, i)
    })
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / bitcoin.ts View on Github external
inputTx.tx.vin.forEach((vin, i) => {
      const txInput = new TxInputType()
      if (vin.coinbase !== undefined) {
        txInput.setPrevHash(fromHexString("\0".repeat(64)))
        txInput.setPrevIndex(0xffffffff)
        txInput.setScriptSig(fromHexString(vin.coinbase))
        txInput.setSequence(vin.sequence)
      } else {
        txInput.setPrevHash(fromHexString(vin.txid))
        txInput.setPrevIndex(vin.vout)
        txInput.setScriptSig(fromHexString(vin.scriptSig.hex))
        txInput.setSequence(vin.sequence)
      }
      tx.addInputs(txInput, i)
    })
github shapeshift / hdwallet / packages / hdwallet-portis / src / bitcoin.ts View on Github external
export function btcVerifyMessage (msg: BTCVerifyMessage): Promise {
  const signature = Base64.fromByteArray(fromHexString(msg.signature))
  return verify(msg.message, msg.address, signature)
}
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / bitcoin.ts View on Github external
inputTx.tx.vout.forEach((vout, i) => {
      const txOutput = new TxOutputBinType()
      txOutput.setAmount(satsFromStr(vout.value))
      txOutput.setScriptPubkey(fromHexString(vout.scriptPubKey.hex))
      tx.addBinOutputs(txOutput, i)
    })
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / bitcoin.ts View on Github external
inputTx.tx.vin.forEach((vin, i) => {
      const txInput = new TxInputType()
      if (vin.coinbase !== undefined) {
        txInput.setPrevHash(fromHexString("\0".repeat(64)))
        txInput.setPrevIndex(0xffffffff)
        txInput.setScriptSig(fromHexString(vin.coinbase))
        txInput.setSequence(vin.sequence)
      } else {
        txInput.setPrevHash(fromHexString(vin.txid))
        txInput.setPrevIndex(vin.vout)
        txInput.setScriptSig(fromHexString(vin.scriptSig.hex))
        txInput.setSequence(vin.sequence)
      }
      tx.addInputs(txInput, i)
    })
github shapeshift / hdwallet / packages / hdwallet-ledger / src / bitcoin.ts View on Github external
export async function btcVerifyMessage (msg: BTCVerifyMessage): Promise {
  const signature = Base64.fromByteArray(fromHexString(msg.signature))
  return verify(msg.message, msg.address, signature)
}
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / bitcoin.ts View on Github external
inputTx.tx.vin.forEach((vin, i) => {
      const txInput = new TxInputType()
      if (vin.coinbase !== undefined) {
        txInput.setPrevHash(fromHexString("\0".repeat(64)))
        txInput.setPrevIndex(0xffffffff)
        txInput.setScriptSig(fromHexString(vin.coinbase))
        txInput.setSequence(vin.sequence)
      } else {
        txInput.setPrevHash(fromHexString(vin.txid))
        txInput.setPrevIndex(vin.vout)
        txInput.setScriptSig(fromHexString(vin.scriptSig.hex))
        txInput.setSequence(vin.sequence)
      }
      tx.addInputs(txInput, i)
    })