@ledgerhq/hw-app-btc
Advanced tools
Comparing version 4.12.0-beta.a9ddcef0 to 4.12.0-beta.e285238a
@@ -281,5 +281,5 @@ "use strict"; | ||
value: function startUntrustedHashTransactionInputRaw(newTransaction, firstRound, transactionData) { | ||
var segwit = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; | ||
var bip143 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; | ||
return this.transport.send(0xe0, 0x44, firstRound ? 0x00 : 0x80, newTransaction ? segwit ? 0x02 : 0x00 : 0x80, transactionData); | ||
return this.transport.send(0xe0, 0x44, firstRound ? 0x00 : 0x80, newTransaction ? bip143 ? 0x02 : 0x00 : 0x80, transactionData); | ||
} | ||
@@ -291,6 +291,6 @@ }, { | ||
var segwit = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; | ||
var bip143 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; | ||
var data = Buffer.concat([transaction.version, transaction.timestamp || Buffer.alloc(0), this.createVarint(transaction.inputs.length)]); | ||
return this.startUntrustedHashTransactionInputRaw(newTransaction, true, data, segwit).then(function () { | ||
return this.startUntrustedHashTransactionInputRaw(newTransaction, true, data, bip143).then(function () { | ||
var i = 0; | ||
@@ -300,3 +300,3 @@ return (0, _utils.eachSeries)(transaction.inputs, function (input) { | ||
if (inputs[i].trustedInput) { | ||
if (segwit) { | ||
if (bip143) { | ||
prefix = Buffer.from([0x02]); | ||
@@ -310,3 +310,3 @@ } else { | ||
data = Buffer.concat([prefix, inputs[i].value, _this2.createVarint(input.script.length)]); | ||
return _this2.startUntrustedHashTransactionInputRaw(newTransaction, false, data, segwit).then(function () { | ||
return _this2.startUntrustedHashTransactionInputRaw(newTransaction, false, data, bip143).then(function () { | ||
var scriptBlocks = []; | ||
@@ -328,3 +328,3 @@ var offset = 0; | ||
return (0, _utils.eachSeries)(scriptBlocks, function (scriptBlock) { | ||
return _this2.startUntrustedHashTransactionInputRaw(newTransaction, false, scriptBlock, segwit); | ||
return _this2.startUntrustedHashTransactionInputRaw(newTransaction, false, scriptBlock, bip143); | ||
}).then(function () { | ||
@@ -491,2 +491,3 @@ i++; | ||
var startTime = Date.now(); | ||
var useBip143 = segwit || !!additionals && (additionals.includes("abc") || additionals.includes("gold")); | ||
// Inputs are provided as arrays of [transaction, output_index, optional redeem script, optional sequence] | ||
@@ -560,6 +561,6 @@ // associatedKeysets are provided as arrays of [path] | ||
}).then(function () { | ||
return (0, _utils.doIf)(segwit || !!additionals && (additionals.includes("abc") || additionals.includes("gold")), function () { | ||
return (0, _utils.doIf)(useBip143, function () { | ||
return ( | ||
// Do the first run with all inputs | ||
_this5.startUntrustedHashTransactionInput(true, targetTransaction, trustedInputs, segwit).then(function () { | ||
_this5.startUntrustedHashTransactionInput(true, targetTransaction, trustedInputs, useBip143).then(function () { | ||
return (0, _utils.doIf)(!resuming && typeof changePath != "undefined", function () { | ||
@@ -586,3 +587,3 @@ // $FlowFixMe | ||
} | ||
return _this5.startUntrustedHashTransactionInput(!segwit && !!additionals && (additionals.includes("abc") || additionals.includes("gold")) && firstRun, pseudoTX, pseudoTrustedInputs, segwit).then(function () { | ||
return _this5.startUntrustedHashTransactionInput(!useBip143 && firstRun, pseudoTX, pseudoTrustedInputs, useBip143).then(function () { | ||
return (0, _utils.doIf)(!segwit && !!additionals && (additionals.includes("abc") || additionals.includes("gold")), function () { | ||
@@ -589,0 +590,0 @@ return (0, _utils.doIf)(!resuming && typeof changePath != "undefined", function () { |
{ | ||
"name": "@ledgerhq/hw-app-btc", | ||
"version": "4.12.0-beta.a9ddcef0", | ||
"version": "4.12.0-beta.e285238a", | ||
"description": "Ledger Hardware Wallet Bitcoin Application API", | ||
@@ -28,3 +28,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@ledgerhq/hw-transport": "^4.12.0-beta.a9ddcef0", | ||
"@ledgerhq/hw-transport": "^4.12.0-beta.e285238a", | ||
"create-hash": "^1.1.3" | ||
@@ -31,0 +31,0 @@ }, |
@@ -257,3 +257,3 @@ //@flow | ||
transactionData: Buffer, | ||
segwit?: boolean = false | ||
bip143?: boolean = false | ||
) { | ||
@@ -264,3 +264,3 @@ return this.transport.send( | ||
firstRound ? 0x00 : 0x80, | ||
newTransaction ? (segwit ? 0x02 : 0x00) : 0x80, | ||
newTransaction ? (bip143 ? 0x02 : 0x00) : 0x80, | ||
transactionData | ||
@@ -274,3 +274,3 @@ ); | ||
inputs: Array<{ trustedInput: boolean, value: Buffer }>, | ||
segwit?: boolean = false | ||
bip143?: boolean = false | ||
) { | ||
@@ -286,3 +286,3 @@ let data = Buffer.concat([ | ||
data, | ||
segwit | ||
bip143 | ||
).then(() => { | ||
@@ -293,3 +293,3 @@ let i = 0; | ||
if (inputs[i].trustedInput) { | ||
if (segwit) { | ||
if (bip143) { | ||
prefix = Buffer.from([0x02]); | ||
@@ -311,3 +311,3 @@ } else { | ||
data, | ||
segwit | ||
bip143 | ||
).then(() => { | ||
@@ -344,3 +344,3 @@ let scriptBlocks = []; | ||
scriptBlock, | ||
segwit | ||
bip143 | ||
); | ||
@@ -514,2 +514,3 @@ }).then(() => { | ||
let startTime = Date.now(); | ||
let useBip143 = segwit || (!!additionals && (additionals.includes("abc") || additionals.includes("gold"))) | ||
// Inputs are provided as arrays of [transaction, output_index, optional redeem script, optional sequence] | ||
@@ -603,3 +604,3 @@ // associatedKeysets are provided as arrays of [path] | ||
.then(() => | ||
doIf(segwit || (!!additionals && (additionals.includes("abc") || additionals.includes("gold"))), () => | ||
doIf(useBip143, () => | ||
// Do the first run with all inputs | ||
@@ -610,3 +611,3 @@ this.startUntrustedHashTransactionInput( | ||
trustedInputs, | ||
segwit | ||
useBip143 | ||
).then(() => | ||
@@ -641,6 +642,6 @@ doIf(!resuming && typeof changePath != "undefined", () => { | ||
return this.startUntrustedHashTransactionInput( | ||
(!segwit && (!!additionals && (additionals.includes("abc") || additionals.includes("gold")))) && firstRun, | ||
!useBip143 && firstRun, | ||
pseudoTX, | ||
pseudoTrustedInputs, | ||
segwit | ||
useBip143 | ||
) | ||
@@ -647,0 +648,0 @@ .then(() => |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2277
198157