@ledgerhq/hw-app-btc
Advanced tools
Comparing version 4.3.0-beta.d226ed3b to 4.3.0-beta.f8165b69
@@ -1,3 +0,3 @@ | ||
// flow-typed signature: 696def0242d98e513b6490ab5780c479 | ||
// flow-typed version: <<STUB>>/@ledgerhq/hw-transport_v^4.0.0/flow_v0.66.0 | ||
// flow-typed signature: 94dbfcaf31e259540307d74106505796 | ||
// flow-typed version: <<STUB>>/@ledgerhq/hw-transport_v^4.2.0/flow_v0.66.0 | ||
@@ -4,0 +4,0 @@ /** |
@@ -7,2 +7,10 @@ "use strict"; | ||
var _extends2 = require("babel-runtime/helpers/extends"); | ||
var _extends3 = _interopRequireDefault(_extends2); | ||
var _assign = require("babel-runtime/core-js/object/assign"); | ||
var _assign2 = _interopRequireDefault(_assign); | ||
var _regenerator = require("babel-runtime/regenerator"); | ||
@@ -58,10 +66,3 @@ | ||
this.transport = transport; | ||
transport.setScrambleKey("BTC"); | ||
var self = this; | ||
var _arr = ["getWalletPublicKey", "signP2SHTransaction", "signMessageNew", "createPaymentTransactionNew"]; | ||
for (var _i = 0; _i < _arr.length; _i++) { | ||
var methodName = _arr[_i]; | ||
self[methodName] = transport.globalLock(methodName, self[methodName], self); | ||
} | ||
transport.decorateAppAPIMethods(this, ["getWalletPublicKey", "signP2SHTransaction", "signMessageNew", "createPaymentTransactionNew"], "BTC"); | ||
} | ||
@@ -457,3 +458,3 @@ | ||
* @param changePath is an optional BIP 32 path pointing to the path to the public key used to compute the change address | ||
* @param outputScript is the hexadecimal serialized outputs of the transaction to sign | ||
* @param outputScriptHex is the hexadecimal serialized outputs of the transaction to sign | ||
* @param lockTime is the optional lockTime of the transaction to sign, or default (0) | ||
@@ -509,5 +510,8 @@ * @param sigHashType is the hash type of the transaction to sign, or default (all) | ||
return getTrustedInputCall(input[1], input[0]).then(function (trustedInput) { | ||
var sequence = Buffer.alloc(4); | ||
sequence.writeUInt32LE(input.length >= 4 && typeof input[3] === "number" ? input[3] : DEFAULT_SEQUENCE, 0); | ||
trustedInputs.push({ | ||
trustedInput: true, | ||
value: Buffer.from(trustedInput, "hex") | ||
value: Buffer.from(trustedInput, "hex"), | ||
sequence: sequence | ||
}); | ||
@@ -568,4 +572,11 @@ }); | ||
(0, _utils.foreach)(inputs, function (input, i) { | ||
targetTransaction.inputs[i].script = inputs[i].length >= 3 && typeof inputs[i][2] === "string" ? Buffer.from(inputs[i][2], "hex") : !segwit ? regularOutputs[i].script : Buffer.concat([Buffer.from([OP_PUSHDATA1, OP_HASH160, HASH_SIZE]), _this5.hashPublicKey(publicKeys[i]), Buffer.from([OP_EQUALVERIFY, OP_CHECKSIG])]); | ||
return _this5.startUntrustedHashTransactionInput(!segwit && firstRun, targetTransaction, trustedInputs, segwit).then(function () { | ||
var script = inputs[i].length >= 3 && typeof inputs[i][2] === "string" ? Buffer.from(inputs[i][2], "hex") : !segwit ? regularOutputs[i].script : Buffer.concat([Buffer.from([OP_PUSHDATA1, OP_HASH160, HASH_SIZE]), _this5.hashPublicKey(publicKeys[i]), Buffer.from([OP_EQUALVERIFY, OP_CHECKSIG])]); | ||
var pseudoTX = (0, _assign2.default)({}, targetTransaction); | ||
var pseudoTrustedInputs = segwit ? [trustedInputs[i]] : trustedInputs; | ||
if (segwit) { | ||
pseudoTX.inputs = [(0, _extends3.default)({}, pseudoTX.inputs[i], { script: script })]; | ||
} else { | ||
pseudoTX.inputs[i].script = script; | ||
} | ||
return _this5.startUntrustedHashTransactionInput(!segwit && firstRun, pseudoTX, pseudoTrustedInputs, segwit).then(function () { | ||
return (0, _utils.doIf)(!segwit, function () { | ||
@@ -591,15 +602,15 @@ return (0, _utils.doIf)(!resuming && typeof changePath != "undefined", function () { | ||
// Populate the final input scripts | ||
for (var _i2 = 0; _i2 < inputs.length; _i2++) { | ||
for (var _i = 0; _i < inputs.length; _i++) { | ||
if (segwit) { | ||
targetTransaction.witness = Buffer.alloc(0); | ||
targetTransaction.inputs[_i2].script = Buffer.concat([Buffer.from("160014", "hex"), _this5.hashPublicKey(publicKeys[_i2])]); | ||
targetTransaction.inputs[_i].script = Buffer.concat([Buffer.from("160014", "hex"), _this5.hashPublicKey(publicKeys[_i])]); | ||
} else { | ||
var signatureSize = Buffer.alloc(1); | ||
var keySize = Buffer.alloc(1); | ||
signatureSize[0] = signatures[_i2].length; | ||
keySize[0] = publicKeys[_i2].length; | ||
targetTransaction.inputs[_i2].script = Buffer.concat([signatureSize, signatures[_i2], keySize, publicKeys[_i2]]); | ||
signatureSize[0] = signatures[_i].length; | ||
keySize[0] = publicKeys[_i].length; | ||
targetTransaction.inputs[_i].script = Buffer.concat([signatureSize, signatures[_i], keySize, publicKeys[_i]]); | ||
} | ||
var offset = segwit ? 0 : 4; | ||
targetTransaction.inputs[_i2].prevout = trustedInputs[_i2].value.slice(offset, offset + 0x24); | ||
targetTransaction.inputs[_i].prevout = trustedInputs[_i].value.slice(offset, offset + 0x24); | ||
} | ||
@@ -635,3 +646,3 @@ | ||
* @param associatedKeysets is an array of BIP 32 paths pointing to the path to the private key used for each UTXO | ||
* @param outputScript is the hexadecimal serialized outputs of the transaction to sign | ||
* @param outputScriptHex is the hexadecimal serialized outputs of the transaction to sign | ||
* @param lockTime is the optional lockTime of the transaction to sign, or default (0) | ||
@@ -803,3 +814,3 @@ * @param sigHashType is the hash type of the transaction to sign, or default (all) | ||
offset += varint[1]; | ||
for (var _i3 = 0; _i3 < numberOutputs; _i3++) { | ||
for (var _i2 = 0; _i2 < numberOutputs; _i2++) { | ||
var _amount = transaction.slice(offset, offset + 8); | ||
@@ -806,0 +817,0 @@ offset += 8; |
{ | ||
"name": "@ledgerhq/hw-app-btc", | ||
"version": "4.3.0-beta.d226ed3b", | ||
"version": "4.3.0-beta.f8165b69", | ||
"description": "Ledger Hardware Wallet Bitcoin Application API", | ||
@@ -28,3 +28,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@ledgerhq/hw-transport": "^4.3.0-beta.d226ed3b", | ||
"@ledgerhq/hw-transport": "^4.3.0-beta.f8165b69", | ||
"create-hash": "^1.1.3" | ||
@@ -31,0 +31,0 @@ }, |
@@ -32,17 +32,12 @@ //@flow | ||
this.transport = transport; | ||
transport.setScrambleKey("BTC"); | ||
const self: Object = this; | ||
for (let methodName of [ | ||
"getWalletPublicKey", | ||
"signP2SHTransaction", | ||
"signMessageNew", | ||
"createPaymentTransactionNew" | ||
]) { | ||
self[methodName] = transport.globalLock( | ||
methodName, | ||
self[methodName], | ||
self | ||
); | ||
} | ||
transport.decorateAppAPIMethods( | ||
this, | ||
[ | ||
"getWalletPublicKey", | ||
"signP2SHTransaction", | ||
"signMessageNew", | ||
"createPaymentTransactionNew" | ||
], | ||
"BTC" | ||
); | ||
} | ||
@@ -485,3 +480,3 @@ | ||
* @param changePath is an optional BIP 32 path pointing to the path to the public key used to compute the change address | ||
* @param outputScript is the hexadecimal serialized outputs of the transaction to sign | ||
* @param outputScriptHex is the hexadecimal serialized outputs of the transaction to sign | ||
* @param lockTime is the optional lockTime of the transaction to sign, or default (0) | ||
@@ -537,5 +532,13 @@ * @param sigHashType is the hash type of the transaction to sign, or default (all) | ||
getTrustedInputCall(input[1], input[0]).then(trustedInput => { | ||
let sequence = Buffer.alloc(4); | ||
sequence.writeUInt32LE( | ||
input.length >= 4 && typeof input[3] === "number" | ||
? input[3] | ||
: DEFAULT_SEQUENCE, | ||
0 | ||
); | ||
trustedInputs.push({ | ||
trustedInput: true, | ||
value: Buffer.from(trustedInput, "hex") | ||
value: Buffer.from(trustedInput, "hex"), | ||
sequence | ||
}); | ||
@@ -610,3 +613,3 @@ }) | ||
foreach(inputs, (input, i) => { | ||
targetTransaction.inputs[i].script = | ||
let script = | ||
inputs[i].length >= 3 && typeof inputs[i][2] === "string" | ||
@@ -621,6 +624,13 @@ ? Buffer.from(inputs[i][2], "hex") | ||
]); | ||
let pseudoTX = Object.assign({}, targetTransaction); | ||
let pseudoTrustedInputs = segwit ? [trustedInputs[i]] : trustedInputs; | ||
if (segwit) { | ||
pseudoTX.inputs = [{ ...pseudoTX.inputs[i], script }]; | ||
} else { | ||
pseudoTX.inputs[i].script = script; | ||
} | ||
return this.startUntrustedHashTransactionInput( | ||
!segwit && firstRun, | ||
targetTransaction, | ||
trustedInputs, | ||
pseudoTX, | ||
pseudoTrustedInputs, | ||
segwit | ||
@@ -716,3 +726,3 @@ ) | ||
* @param associatedKeysets is an array of BIP 32 paths pointing to the path to the private key used for each UTXO | ||
* @param outputScript is the hexadecimal serialized outputs of the transaction to sign | ||
* @param outputScriptHex is the hexadecimal serialized outputs of the transaction to sign | ||
* @param lockTime is the optional lockTime of the transaction to sign, or default (0) | ||
@@ -719,0 +729,0 @@ * @param sigHashType is the hash type of the transaction to sign, or default (all) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
197216
2291