Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
})
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"
}
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)
})
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)
})
export function btcVerifyMessage (msg: BTCVerifyMessage): Promise {
const signature = Base64.fromByteArray(fromHexString(msg.signature))
return verify(msg.message, msg.address, signature)
}
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)
})
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)
})
export async function btcVerifyMessage (msg: BTCVerifyMessage): Promise {
const signature = Base64.fromByteArray(fromHexString(msg.signature))
return verify(msg.message, msg.address, signature)
}
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)
})