@ledgerhq/hw-app-btc
Advanced tools
Comparing version 4.24.0 to 4.26.0-beta.ebeb3540
@@ -7,26 +7,12 @@ "use strict"; | ||
var _extends2 = require("babel-runtime/helpers/extends"); | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var _extends3 = _interopRequireDefault(_extends2); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _assign = require("babel-runtime/core-js/object/assign"); | ||
// TODO future refactoring | ||
// - drop utils.js & refactoring with async/await style | ||
// - try to avoid every place we do hex<>Buffer conversion. also accept Buffer as func parameters (could accept both a string or a Buffer in the API) | ||
// - there are redundant code across apps (see Eth vs Btc). we might want to factorize it somewhere. also each app apdu call should be abstracted it out as an api | ||
var _assign2 = _interopRequireDefault(_assign); | ||
var _regenerator = require("babel-runtime/regenerator"); | ||
var _regenerator2 = _interopRequireDefault(_regenerator); | ||
var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator"); | ||
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2); | ||
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck"); | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
var _createClass2 = require("babel-runtime/helpers/createClass"); | ||
var _createClass3 = _interopRequireDefault(_createClass2); | ||
var _utils = require("./utils"); | ||
@@ -40,6 +26,6 @@ | ||
// TODO future refactoring | ||
// - drop utils.js & refactoring with async/await style | ||
// - try to avoid every place we do hex<>Buffer conversion. also accept Buffer as func parameters (could accept both a string or a Buffer in the API) | ||
// - there are redundant code across apps (see Eth vs Btc). we might want to factorize it somewhere. also each app apdu call should be abstracted it out as an api | ||
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var MAX_SCRIPT_BLOCK = 50; | ||
@@ -66,4 +52,5 @@ var DEFAULT_VERSION = 1; | ||
var scrambleKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "BTC"; | ||
(0, _classCallCheck3.default)(this, Btc); | ||
_classCallCheck(this, Btc); | ||
this.transport = transport; | ||
@@ -73,3 +60,3 @@ transport.decorateAppAPIMethods(this, ["getWalletPublicKey", "signP2SHTransaction", "signMessageNew", "createPaymentTransactionNew"], scrambleKey); | ||
(0, _createClass3.default)(Btc, [{ | ||
_createClass(Btc, [{ | ||
key: "hashPublicKey", | ||
@@ -212,5 +199,5 @@ value: function hashPublicKey(buffer) { | ||
value: function () { | ||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(indexLookup, transaction) { | ||
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(indexLookup, transaction) { | ||
var sha, hash, data, outputs, locktime; | ||
return _regenerator2.default.wrap(function _callee$(_context) { | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
@@ -607,6 +594,6 @@ switch (_context.prev = _context.next) { | ||
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_DUP, OP_HASH160, HASH_SIZE]), _this5.hashPublicKey(publicKeys[i]), Buffer.from([OP_EQUALVERIFY, OP_CHECKSIG])]); | ||
var pseudoTX = (0, _assign2.default)({}, targetTransaction); | ||
var pseudoTX = Object.assign({}, targetTransaction); | ||
var pseudoTrustedInputs = useBip143 ? [trustedInputs[i]] : trustedInputs; | ||
if (useBip143) { | ||
pseudoTX.inputs = [(0, _extends3.default)({}, pseudoTX.inputs[i], { script: script })]; | ||
pseudoTX.inputs = [_extends({}, pseudoTX.inputs[i], { script: script })]; | ||
} else { | ||
@@ -767,6 +754,6 @@ pseudoTX.inputs[i].script = script; | ||
var script = inputs[i].length >= 3 && typeof inputs[i][2] === "string" ? Buffer.from(inputs[i][2], "hex") : regularOutputs[i].script; | ||
var pseudoTX = (0, _assign2.default)({}, targetTransaction); | ||
var pseudoTX = Object.assign({}, targetTransaction); | ||
var pseudoTrustedInputs = segwit ? [trustedInputs[i]] : trustedInputs; | ||
if (segwit) { | ||
pseudoTX.inputs = [(0, _extends3.default)({}, pseudoTX.inputs[i], { script: script })]; | ||
pseudoTX.inputs = [_extends({}, pseudoTX.inputs[i], { script: script })]; | ||
} else { | ||
@@ -984,2 +971,3 @@ pseudoTX.inputs[i].script = script; | ||
}]); | ||
return Btc; | ||
@@ -986,0 +974,0 @@ }(); |
@@ -6,8 +6,2 @@ "use strict"; | ||
}); | ||
exports.isLedgerDevice = undefined; | ||
var _promise = require("babel-runtime/core-js/promise"); | ||
var _promise2 = _interopRequireDefault(_promise); | ||
exports.defer = defer; | ||
@@ -19,9 +13,6 @@ exports.splitPath = splitPath; | ||
exports.asyncWhile = asyncWhile; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function defer() { | ||
var resolve = void 0, | ||
reject = void 0; | ||
var promise = new _promise2.default(function (success, failure) { | ||
var promise = new Promise(function (success, failure) { | ||
resolve = success; | ||
@@ -76,3 +67,3 @@ reject = failure; | ||
}); | ||
}, _promise2.default.resolve()); | ||
}, Promise.resolve()); | ||
} | ||
@@ -89,3 +80,3 @@ | ||
} | ||
return _promise2.default.resolve().then(function () { | ||
return Promise.resolve().then(function () { | ||
return iterate(0, arr, []); | ||
@@ -96,3 +87,3 @@ }); | ||
function doIf(condition, callback) { | ||
return _promise2.default.resolve().then(function () { | ||
return Promise.resolve().then(function () { | ||
if (condition) { | ||
@@ -115,3 +106,3 @@ return callback(); | ||
} | ||
return _promise2.default.resolve([]).then(iterate); | ||
return Promise.resolve([]).then(iterate); | ||
} | ||
@@ -118,0 +109,0 @@ |
{ | ||
"name": "@ledgerhq/hw-app-btc", | ||
"version": "4.24.0", | ||
"version": "4.26.0-beta.ebeb3540", | ||
"description": "Ledger Hardware Wallet Bitcoin Application API", | ||
@@ -28,3 +28,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@ledgerhq/hw-transport": "^4.24.0", | ||
"@ledgerhq/hw-transport": "^4.26.0-beta.ebeb3540", | ||
"create-hash": "^1.1.3" | ||
@@ -31,0 +31,0 @@ }, |
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
208829
2218
1