@ledgerhq/hw-app-btc
Advanced tools
Comparing version 4.2.1 to 4.3.0-beta.d226ed3b
@@ -1,3 +0,3 @@ | ||
// flow-typed signature: 75d330203ebfe98a2c99295790ffe07c | ||
// flow-typed version: <<STUB>>/@ledgerhq/hw-transport_v^2.1.0/flow_v0.63.1 | ||
// flow-typed signature: 696def0242d98e513b6490ab5780c479 | ||
// flow-typed version: <<STUB>>/@ledgerhq/hw-transport_v^4.0.0/flow_v0.66.0 | ||
@@ -37,6 +37,2 @@ /** | ||
declare module '@ledgerhq/hw-transport/flow-typed/npm/invariant_v2.x.x' { | ||
declare module.exports: any; | ||
} | ||
declare module '@ledgerhq/hw-transport/src/Transport' { | ||
@@ -56,7 +52,4 @@ declare module.exports: any; | ||
} | ||
declare module '@ledgerhq/hw-transport/flow-typed/npm/invariant_v2.x.x.js' { | ||
declare module.exports: $Exports<'@ledgerhq/hw-transport/flow-typed/npm/invariant_v2.x.x'>; | ||
} | ||
declare module '@ledgerhq/hw-transport/src/Transport.js' { | ||
declare module.exports: $Exports<'@ledgerhq/hw-transport/src/Transport'>; | ||
} |
@@ -58,2 +58,9 @@ "use strict"; | ||
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); | ||
} | ||
} | ||
@@ -66,16 +73,5 @@ | ||
} | ||
/** | ||
* @param path a BIP 32 path | ||
* @param segwit use segwit | ||
* @example | ||
* btc.getWalletPublicKey("44'/0'/0'/0").then(o => o.bitcoinAddress) | ||
*/ | ||
}, { | ||
key: "getWalletPublicKey", | ||
value: function getWalletPublicKey(path) { | ||
var verify = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
var segwit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | ||
key: "getWalletPublicKey_private", | ||
value: function getWalletPublicKey_private(path, verify, segwit) { | ||
var paths = (0, _utils.splitPath)(path); | ||
@@ -104,3 +100,19 @@ var p1 = 0x00; | ||
} | ||
/** | ||
* @param path a BIP 32 path | ||
* @param segwit use segwit | ||
* @example | ||
* btc.getWalletPublicKey("44'/0'/0'/0").then(o => o.bitcoinAddress) | ||
*/ | ||
}, { | ||
key: "getWalletPublicKey", | ||
value: function getWalletPublicKey(path) { | ||
var verify = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
var segwit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | ||
return this.getWalletPublicKey_private(path, verify, segwit); | ||
} | ||
}, { | ||
key: "getTrustedInputRaw", | ||
@@ -350,6 +362,2 @@ value: function getTrustedInputRaw(transactionData, indexLookup) { | ||
} | ||
/** | ||
*/ | ||
}, { | ||
@@ -530,3 +538,3 @@ key: "signTransaction", | ||
(0, _utils.foreach)(inputs, function (input, i) { | ||
return _this5.getWalletPublicKey(associatedKeysets[i]); | ||
return _this5.getWalletPublicKey_private(associatedKeysets[i], false, false); | ||
}).then(function (result) { | ||
@@ -583,15 +591,15 @@ for (var index = 0; index < result.length; index++) { | ||
// Populate the final input scripts | ||
for (var _i = 0; _i < inputs.length; _i++) { | ||
for (var _i2 = 0; _i2 < inputs.length; _i2++) { | ||
if (segwit) { | ||
targetTransaction.witness = Buffer.alloc(0); | ||
targetTransaction.inputs[_i].script = Buffer.concat([Buffer.from("160014", "hex"), _this5.hashPublicKey(publicKeys[_i])]); | ||
targetTransaction.inputs[_i2].script = Buffer.concat([Buffer.from("160014", "hex"), _this5.hashPublicKey(publicKeys[_i2])]); | ||
} else { | ||
var signatureSize = Buffer.alloc(1); | ||
var keySize = Buffer.alloc(1); | ||
signatureSize[0] = signatures[_i].length; | ||
keySize[0] = publicKeys[_i].length; | ||
targetTransaction.inputs[_i].script = Buffer.concat([signatureSize, signatures[_i], keySize, publicKeys[_i]]); | ||
signatureSize[0] = signatures[_i2].length; | ||
keySize[0] = publicKeys[_i2].length; | ||
targetTransaction.inputs[_i2].script = Buffer.concat([signatureSize, signatures[_i2], keySize, publicKeys[_i2]]); | ||
} | ||
var offset = segwit ? 0 : 4; | ||
targetTransaction.inputs[_i].prevout = trustedInputs[_i].value.slice(offset, offset + 0x24); | ||
targetTransaction.inputs[_i2].prevout = trustedInputs[_i2].value.slice(offset, offset + 0x24); | ||
} | ||
@@ -794,3 +802,3 @@ | ||
offset += varint[1]; | ||
for (var _i2 = 0; _i2 < numberOutputs; _i2++) { | ||
for (var _i3 = 0; _i3 < numberOutputs; _i3++) { | ||
var _amount = transaction.slice(offset, offset + 8); | ||
@@ -797,0 +805,0 @@ offset += 8; |
{ | ||
"name": "@ledgerhq/hw-app-btc", | ||
"version": "4.2.1", | ||
"version": "4.3.0-beta.d226ed3b", | ||
"description": "Ledger Hardware Wallet Bitcoin Application API", | ||
@@ -28,3 +28,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@ledgerhq/hw-transport": "^4.2.0", | ||
"@ledgerhq/hw-transport": "^4.3.0-beta.d226ed3b", | ||
"create-hash": "^1.1.3" | ||
@@ -31,0 +31,0 @@ }, |
@@ -33,2 +33,16 @@ //@flow | ||
transport.setScrambleKey("BTC"); | ||
const self: Object = this; | ||
for (let methodName of [ | ||
"getWalletPublicKey", | ||
"signP2SHTransaction", | ||
"signMessageNew", | ||
"createPaymentTransactionNew" | ||
]) { | ||
self[methodName] = transport.globalLock( | ||
methodName, | ||
self[methodName], | ||
self | ||
); | ||
} | ||
} | ||
@@ -46,12 +60,6 @@ | ||
/** | ||
* @param path a BIP 32 path | ||
* @param segwit use segwit | ||
* @example | ||
* btc.getWalletPublicKey("44'/0'/0'/0").then(o => o.bitcoinAddress) | ||
*/ | ||
getWalletPublicKey( | ||
getWalletPublicKey_private( | ||
path: string, | ||
verify?: boolean = false, | ||
segwit?: boolean = false | ||
verify: boolean, | ||
segwit: boolean | ||
): Promise<{ | ||
@@ -93,2 +101,20 @@ publicKey: string, | ||
/** | ||
* @param path a BIP 32 path | ||
* @param segwit use segwit | ||
* @example | ||
* btc.getWalletPublicKey("44'/0'/0'/0").then(o => o.bitcoinAddress) | ||
*/ | ||
getWalletPublicKey( | ||
path: string, | ||
verify?: boolean = false, | ||
segwit?: boolean = false | ||
): Promise<{ | ||
publicKey: string, | ||
bitcoinAddress: string, | ||
chainCode: string | ||
}> { | ||
return this.getWalletPublicKey_private(path, verify, segwit); | ||
} | ||
getTrustedInputRaw( | ||
@@ -358,4 +384,2 @@ transactionData: Buffer, | ||
/** | ||
*/ | ||
signTransaction( | ||
@@ -548,3 +572,3 @@ path: string, | ||
foreach(inputs, (input, i) => | ||
this.getWalletPublicKey(associatedKeysets[i]) | ||
this.getWalletPublicKey_private(associatedKeysets[i], false, false) | ||
).then(result => { | ||
@@ -551,0 +575,0 @@ for (let index = 0; index < result.length; index++) { |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
195102
2272
1