@ledgerhq/hw-app-btc
Advanced tools
Comparing version 10.0.1-nightly.2 to 10.0.1-recover-beta.0
# @ledgerhq/hw-app-btc | ||
## 10.0.1-nightly.2 | ||
## 10.0.1-recover-beta.0 | ||
@@ -8,18 +8,4 @@ ### Patch Changes | ||
- Updated dependencies []: | ||
- @ledgerhq/hw-transport@6.28.2-nightly.2 | ||
- @ledgerhq/hw-transport@6.28.2-recover-beta.0 | ||
## 10.0.1-nightly.1 | ||
### Patch Changes | ||
- Updated dependencies []: | ||
- @ledgerhq/hw-transport@6.28.2-nightly.1 | ||
## 10.0.1-nightly.0 | ||
### Patch Changes | ||
- Updated dependencies []: | ||
- @ledgerhq/hw-transport@6.28.2-nightly.0 | ||
## 10.0.0 | ||
@@ -26,0 +12,0 @@ |
@@ -37,2 +37,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
import BtcNew from "./BtcNew"; | ||
@@ -235,17 +251,40 @@ import BtcOld from "./BtcOld"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var appAndVersion, isBtcLegacy; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, getAppAndVersion(this._transport)]; | ||
var appAndVersion, isBtcLegacy, _a, major, minor; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
// if BtcOld was instantiated, stick with it | ||
if (this._impl instanceof BtcOld) | ||
return [2 /*return*/, this._impl]; | ||
return [4 /*yield*/, getAppAndVersion(this._transport)]; | ||
case 1: | ||
appAndVersion = _a.sent(); | ||
if (!(appAndVersion.name === "Exchange" && this._impl instanceof BtcNew)) return [3 /*break*/, 3]; | ||
appAndVersion = _b.sent(); | ||
isBtcLegacy = true; | ||
if (!(appAndVersion.name === "Bitcoin" || | ||
appAndVersion.name === "Bitcoin Test")) return [3 /*break*/, 2]; | ||
_a = __read(appAndVersion.version.split("."), 2), major = _a[0], minor = _a[1]; | ||
// we use the legacy protocol for versions below 2.1.0 of the Bitcoin app. | ||
isBtcLegacy = | ||
parseInt(major) <= 1 || (parseInt(major) == 2 && parseInt(minor) == 0); | ||
return [3 /*break*/, 5]; | ||
case 2: | ||
if (!(appAndVersion.name === "Bitcoin Legacy" || | ||
appAndVersion.name === "Bitcoin Test Legacy")) return [3 /*break*/, 3]; | ||
// the "Bitcoin Legacy" and "Bitcoin Testnet Legacy" app use the legacy protocol, regardless of the version | ||
isBtcLegacy = true; | ||
return [3 /*break*/, 5]; | ||
case 3: | ||
if (!(appAndVersion.name === "Exchange")) return [3 /*break*/, 5]; | ||
return [4 /*yield*/, checkIsBtcLegacy(this._transport)]; | ||
case 2: | ||
isBtcLegacy = _a.sent(); | ||
case 4: | ||
// We can't query the version of the Bitcoin app if we're coming from Exchange; | ||
// therefore, we use a workaround to distinguish legacy and new versions. | ||
// This can be removed once Ledger Live enforces minimum bitcoin version >= 2.1.0. | ||
isBtcLegacy = _b.sent(); | ||
_b.label = 5; | ||
case 5: | ||
if (isBtcLegacy) { | ||
this._impl = new BtcOld(this._transport); | ||
} | ||
_a.label = 3; | ||
case 3: return [2 /*return*/, this._impl]; | ||
return [2 /*return*/, this._impl]; | ||
} | ||
@@ -252,0 +291,0 @@ }); |
@@ -38,2 +38,18 @@ "use strict"; | ||
}; | ||
var __read = (this && this.__read) || function (o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -240,17 +256,40 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var appAndVersion, isBtcLegacy; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, (0, getAppAndVersion_1.getAppAndVersion)(this._transport)]; | ||
var appAndVersion, isBtcLegacy, _a, major, minor; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
// if BtcOld was instantiated, stick with it | ||
if (this._impl instanceof BtcOld_1["default"]) | ||
return [2 /*return*/, this._impl]; | ||
return [4 /*yield*/, (0, getAppAndVersion_1.getAppAndVersion)(this._transport)]; | ||
case 1: | ||
appAndVersion = _a.sent(); | ||
if (!(appAndVersion.name === "Exchange" && this._impl instanceof BtcNew_1["default"])) return [3 /*break*/, 3]; | ||
appAndVersion = _b.sent(); | ||
isBtcLegacy = true; | ||
if (!(appAndVersion.name === "Bitcoin" || | ||
appAndVersion.name === "Bitcoin Test")) return [3 /*break*/, 2]; | ||
_a = __read(appAndVersion.version.split("."), 2), major = _a[0], minor = _a[1]; | ||
// we use the legacy protocol for versions below 2.1.0 of the Bitcoin app. | ||
isBtcLegacy = | ||
parseInt(major) <= 1 || (parseInt(major) == 2 && parseInt(minor) == 0); | ||
return [3 /*break*/, 5]; | ||
case 2: | ||
if (!(appAndVersion.name === "Bitcoin Legacy" || | ||
appAndVersion.name === "Bitcoin Test Legacy")) return [3 /*break*/, 3]; | ||
// the "Bitcoin Legacy" and "Bitcoin Testnet Legacy" app use the legacy protocol, regardless of the version | ||
isBtcLegacy = true; | ||
return [3 /*break*/, 5]; | ||
case 3: | ||
if (!(appAndVersion.name === "Exchange")) return [3 /*break*/, 5]; | ||
return [4 /*yield*/, (0, getAppAndVersion_1.checkIsBtcLegacy)(this._transport)]; | ||
case 2: | ||
isBtcLegacy = _a.sent(); | ||
case 4: | ||
// We can't query the version of the Bitcoin app if we're coming from Exchange; | ||
// therefore, we use a workaround to distinguish legacy and new versions. | ||
// This can be removed once Ledger Live enforces minimum bitcoin version >= 2.1.0. | ||
isBtcLegacy = _b.sent(); | ||
_b.label = 5; | ||
case 5: | ||
if (isBtcLegacy) { | ||
this._impl = new BtcOld_1["default"](this._transport); | ||
} | ||
_a.label = 3; | ||
case 3: return [2 /*return*/, this._impl]; | ||
return [2 /*return*/, this._impl]; | ||
} | ||
@@ -257,0 +296,0 @@ }); |
{ | ||
"name": "@ledgerhq/hw-app-btc", | ||
"version": "10.0.1-nightly.2", | ||
"version": "10.0.1-recover-beta.0", | ||
"description": "Ledger Hardware Wallet Bitcoin Application API", | ||
@@ -73,3 +73,3 @@ "keywords": [ | ||
"varuint-bitcoin": "1.1.2", | ||
"@ledgerhq/hw-transport": "^6.28.2-nightly.2", | ||
"@ledgerhq/hw-transport": "^6.28.2-recover-beta.0", | ||
"@ledgerhq/logs": "^6.10.1" | ||
@@ -88,4 +88,4 @@ }, | ||
"typescript": "^4", | ||
"@ledgerhq/hw-transport-mocker": "^6.27.13-nightly.2", | ||
"@ledgerhq/hw-transport-node-speculos": "^6.27.13-nightly.2" | ||
"@ledgerhq/hw-transport-mocker": "^6.27.13-recover-beta.0", | ||
"@ledgerhq/hw-transport-node-speculos": "^6.27.13-recover-beta.0" | ||
}, | ||
@@ -92,0 +92,0 @@ "gitHead": "dd0dea64b58e5a9125c8a422dcffd29e5ef6abec", |
@@ -272,11 +272,34 @@ import type Transport from "@ledgerhq/hw-transport"; | ||
async changeImplIfNecessary(): Promise<BtcOld | BtcNew> { | ||
// if BtcOld was instantiated, stick with it | ||
if (this._impl instanceof BtcOld) return this._impl; | ||
const appAndVersion = await getAppAndVersion(this._transport); | ||
if (appAndVersion.name === "Exchange" && this._impl instanceof BtcNew) { | ||
const isBtcLegacy = await checkIsBtcLegacy(this._transport); | ||
if (isBtcLegacy) { | ||
this._impl = new BtcOld(this._transport); | ||
} | ||
let isBtcLegacy = true; // default for all altcoins | ||
if ( | ||
appAndVersion.name === "Bitcoin" || | ||
appAndVersion.name === "Bitcoin Test" | ||
) { | ||
const [major, minor] = appAndVersion.version.split("."); | ||
// we use the legacy protocol for versions below 2.1.0 of the Bitcoin app. | ||
isBtcLegacy = | ||
parseInt(major) <= 1 || (parseInt(major) == 2 && parseInt(minor) == 0); | ||
} else if ( | ||
appAndVersion.name === "Bitcoin Legacy" || | ||
appAndVersion.name === "Bitcoin Test Legacy" | ||
) { | ||
// the "Bitcoin Legacy" and "Bitcoin Testnet Legacy" app use the legacy protocol, regardless of the version | ||
isBtcLegacy = true; | ||
} else if (appAndVersion.name === "Exchange") { | ||
// We can't query the version of the Bitcoin app if we're coming from Exchange; | ||
// therefore, we use a workaround to distinguish legacy and new versions. | ||
// This can be removed once Ledger Live enforces minimum bitcoin version >= 2.1.0. | ||
isBtcLegacy = await checkIsBtcLegacy(this._transport); | ||
} | ||
if (isBtcLegacy) { | ||
this._impl = new BtcOld(this._transport); | ||
} | ||
return this._impl; | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1192305
17779