@ledgerhq/hw-app-btc 10.0.1-recover-beta.0 → 10.0.2-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +16 -2
- package/lib/Btc.js +72 -136
- package/lib/Btc.js.map +1 -1
- package/lib/BtcNew.js +217 -313
- package/lib/BtcNew.js.map +1 -1
- package/lib/BtcOld.js +46 -106
- package/lib/BtcOld.js.map +1 -1
- package/lib/bip32.js +12 -12
- package/lib/bip32.js.map +1 -1
- package/lib/buffertools.js +66 -69
- package/lib/buffertools.js.map +1 -1
- package/lib/compressPublicKey.js +3 -3
- package/lib/compressPublicKey.js.map +1 -1
- package/lib/constants.js +1 -1
- package/lib/createTransaction.d.ts +1 -1
- package/lib/createTransaction.d.ts.map +1 -1
- package/lib/createTransaction.js +285 -398
- package/lib/createTransaction.js.map +1 -1
- package/lib/debug.js +11 -13
- package/lib/debug.js.map +1 -1
- package/lib/finalizeInput.js +23 -62
- package/lib/finalizeInput.js.map +1 -1
- package/lib/getAppAndVersion.d.ts +1 -1
- package/lib/getAppAndVersion.d.ts.map +1 -1
- package/lib/getAppAndVersion.js +29 -72
- package/lib/getAppAndVersion.js.map +1 -1
- package/lib/getTrustedInput.js +108 -251
- package/lib/getTrustedInput.js.map +1 -1
- package/lib/getTrustedInputBIP143.js +9 -10
- package/lib/getTrustedInputBIP143.js.map +1 -1
- package/lib/getWalletPublicKey.d.ts +1 -1
- package/lib/getWalletPublicKey.d.ts.map +1 -1
- package/lib/getWalletPublicKey.js +27 -73
- package/lib/getWalletPublicKey.js.map +1 -1
- package/lib/hashPublicKey.js +4 -4
- package/lib/hashPublicKey.js.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/newops/accounttype.d.ts +2 -2
- package/lib/newops/accounttype.d.ts.map +1 -1
- package/lib/newops/accounttype.js +85 -125
- package/lib/newops/accounttype.js.map +1 -1
- package/lib/newops/appClient.js +98 -205
- package/lib/newops/appClient.js.map +1 -1
- package/lib/newops/clientCommands.js +122 -213
- package/lib/newops/clientCommands.js.map +1 -1
- package/lib/newops/merkelizedPsbt.js +28 -75
- package/lib/newops/merkelizedPsbt.js.map +1 -1
- package/lib/newops/merkle.js +38 -67
- package/lib/newops/merkle.js.map +1 -1
- package/lib/newops/merkleMap.js +11 -12
- package/lib/newops/merkleMap.js.map +1 -1
- package/lib/newops/policy.d.ts +1 -1
- package/lib/newops/policy.d.ts.map +1 -1
- package/lib/newops/policy.js +17 -18
- package/lib/newops/policy.js.map +1 -1
- package/lib/newops/psbtExtractor.js +9 -9
- package/lib/newops/psbtExtractor.js.map +1 -1
- package/lib/newops/psbtFinalizer.js +22 -22
- package/lib/newops/psbtFinalizer.js.map +1 -1
- package/lib/newops/psbtv2.d.ts +1 -1
- package/lib/newops/psbtv2.d.ts.map +1 -1
- package/lib/newops/psbtv2.js +227 -286
- package/lib/newops/psbtv2.js.map +1 -1
- package/lib/serializeTransaction.js +13 -15
- package/lib/serializeTransaction.js.map +1 -1
- package/lib/shouldUseTrustedInputForSegwit.js +4 -5
- package/lib/shouldUseTrustedInputForSegwit.js.map +1 -1
- package/lib/signMessage.js +47 -99
- package/lib/signMessage.js.map +1 -1
- package/lib/signP2SHTransaction.d.ts +1 -1
- package/lib/signP2SHTransaction.d.ts.map +1 -1
- package/lib/signP2SHTransaction.js +91 -187
- package/lib/signP2SHTransaction.js.map +1 -1
- package/lib/signTransaction.js +8 -9
- package/lib/signTransaction.js.map +1 -1
- package/lib/splitTransaction.js +50 -54
- package/lib/splitTransaction.js.map +1 -1
- package/lib/startUntrustedHashTransactionInput.js +65 -167
- package/lib/startUntrustedHashTransactionInput.js.map +1 -1
- package/lib/types.js +1 -1
- package/lib/varint.js +10 -10
- package/lib/varint.js.map +1 -1
- package/lib-es/Btc.js +58 -123
- package/lib-es/Btc.js.map +1 -1
- package/lib-es/BtcNew.js +205 -302
- package/lib-es/BtcNew.js.map +1 -1
- package/lib-es/BtcOld.js +35 -96
- package/lib-es/BtcOld.js.map +1 -1
- package/lib-es/bip32.js +7 -7
- package/lib-es/bip32.js.map +1 -1
- package/lib-es/buffertools.js +62 -67
- package/lib-es/buffertools.js.map +1 -1
- package/lib-es/compressPublicKey.js +2 -2
- package/lib-es/compressPublicKey.js.map +1 -1
- package/lib-es/constants.js +12 -12
- package/lib-es/constants.js.map +1 -1
- package/lib-es/createTransaction.d.ts +1 -1
- package/lib-es/createTransaction.d.ts.map +1 -1
- package/lib-es/createTransaction.js +271 -384
- package/lib-es/createTransaction.js.map +1 -1
- package/lib-es/debug.js +10 -12
- package/lib-es/debug.js.map +1 -1
- package/lib-es/finalizeInput.js +20 -59
- package/lib-es/finalizeInput.js.map +1 -1
- package/lib-es/getAppAndVersion.d.ts +1 -1
- package/lib-es/getAppAndVersion.d.ts.map +1 -1
- package/lib-es/getAppAndVersion.js +27 -70
- package/lib-es/getAppAndVersion.js.map +1 -1
- package/lib-es/getTrustedInput.js +104 -247
- package/lib-es/getTrustedInput.js.map +1 -1
- package/lib-es/getTrustedInputBIP143.js +5 -6
- package/lib-es/getTrustedInputBIP143.js.map +1 -1
- package/lib-es/getWalletPublicKey.d.ts +1 -1
- package/lib-es/getWalletPublicKey.d.ts.map +1 -1
- package/lib-es/getWalletPublicKey.js +25 -71
- package/lib-es/getWalletPublicKey.js.map +1 -1
- package/lib-es/newops/accounttype.d.ts +2 -2
- package/lib-es/newops/accounttype.d.ts.map +1 -1
- package/lib-es/newops/accounttype.js +79 -123
- package/lib-es/newops/accounttype.js.map +1 -1
- package/lib-es/newops/appClient.js +92 -200
- package/lib-es/newops/appClient.js.map +1 -1
- package/lib-es/newops/clientCommands.js +117 -214
- package/lib-es/newops/clientCommands.js.map +1 -1
- package/lib-es/newops/merkelizedPsbt.js +25 -73
- package/lib-es/newops/merkelizedPsbt.js.map +1 -1
- package/lib-es/newops/merkle.js +36 -66
- package/lib-es/newops/merkle.js.map +1 -1
- package/lib-es/newops/merkleMap.js +8 -10
- package/lib-es/newops/merkleMap.js.map +1 -1
- package/lib-es/newops/policy.d.ts +1 -1
- package/lib-es/newops/policy.d.ts.map +1 -1
- package/lib-es/newops/policy.js +12 -14
- package/lib-es/newops/policy.js.map +1 -1
- package/lib-es/newops/psbtExtractor.js +7 -7
- package/lib-es/newops/psbtExtractor.js.map +1 -1
- package/lib-es/newops/psbtFinalizer.js +19 -19
- package/lib-es/newops/psbtFinalizer.js.map +1 -1
- package/lib-es/newops/psbtv2.d.ts +1 -1
- package/lib-es/newops/psbtv2.d.ts.map +1 -1
- package/lib-es/newops/psbtv2.js +225 -286
- package/lib-es/newops/psbtv2.js.map +1 -1
- package/lib-es/serializeTransaction.js +11 -13
- package/lib-es/serializeTransaction.js.map +1 -1
- package/lib-es/shouldUseTrustedInputForSegwit.js +1 -2
- package/lib-es/shouldUseTrustedInputForSegwit.js.map +1 -1
- package/lib-es/signMessage.js +44 -96
- package/lib-es/signMessage.js.map +1 -1
- package/lib-es/signP2SHTransaction.d.ts +1 -1
- package/lib-es/signP2SHTransaction.d.ts.map +1 -1
- package/lib-es/signP2SHTransaction.js +84 -180
- package/lib-es/signP2SHTransaction.js.map +1 -1
- package/lib-es/signTransaction.js +6 -7
- package/lib-es/signTransaction.js.map +1 -1
- package/lib-es/splitTransaction.js +46 -50
- package/lib-es/splitTransaction.js.map +1 -1
- package/lib-es/startUntrustedHashTransactionInput.js +62 -164
- package/lib-es/startUntrustedHashTransactionInput.js.map +1 -1
- package/lib-es/varint.js +9 -9
- package/lib-es/varint.js.map +1 -1
- package/package.json +5 -6
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @ledgerhq/hw-app-btc@10.0.1
|
|
2
|
+
> @ledgerhq/hw-app-btc@10.0.1 build /home/runner/work/ledger-live/ledger-live/libs/ledgerjs/packages/hw-app-btc
|
|
3
3
|
> tsc && tsc -m ES6 --outDir lib-es
|
|
4
4
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
# @ledgerhq/hw-app-btc
|
|
2
2
|
|
|
3
|
-
## 10.0.
|
|
3
|
+
## 10.0.2-next.0
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
7
|
- Updated dependencies []:
|
|
8
|
-
- @ledgerhq/hw-transport@6.28.
|
|
8
|
+
- @ledgerhq/hw-transport@6.28.3-next.0
|
|
9
|
+
|
|
10
|
+
## 10.0.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies []:
|
|
15
|
+
- @ledgerhq/hw-transport@6.28.2
|
|
16
|
+
|
|
17
|
+
## 10.0.1-next.0
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies []:
|
|
22
|
+
- @ledgerhq/hw-transport@6.28.2-next.0
|
|
9
23
|
|
|
10
24
|
## 10.0.0
|
|
11
25
|
|
package/lib/Btc.js
CHANGED
|
@@ -8,63 +8,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
-
if (!m) return o;
|
|
41
|
-
var i = m.call(o), r, ar = [], e;
|
|
42
|
-
try {
|
|
43
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
-
}
|
|
45
|
-
catch (error) { e = { error: error }; }
|
|
46
|
-
finally {
|
|
47
|
-
try {
|
|
48
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
-
}
|
|
50
|
-
finally { if (e) throw e.error; }
|
|
51
|
-
}
|
|
52
|
-
return ar;
|
|
53
|
-
};
|
|
54
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
55
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
56
13
|
};
|
|
57
|
-
exports
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const BtcNew_1 = __importDefault(require("./BtcNew"));
|
|
16
|
+
const BtcOld_1 = __importDefault(require("./BtcOld"));
|
|
17
|
+
const getTrustedInput_1 = require("./getTrustedInput");
|
|
18
|
+
const getTrustedInputBIP143_1 = require("./getTrustedInputBIP143");
|
|
19
|
+
const appClient_1 = require("./newops/appClient");
|
|
20
|
+
const serializeTransaction_1 = require("./serializeTransaction");
|
|
21
|
+
const splitTransaction_1 = require("./splitTransaction");
|
|
22
|
+
const signP2SHTransaction_1 = require("./signP2SHTransaction");
|
|
23
|
+
const signMessage_1 = require("./signMessage");
|
|
24
|
+
const getAppAndVersion_1 = require("./getAppAndVersion");
|
|
68
25
|
/**
|
|
69
26
|
* Bitcoin API.
|
|
70
27
|
*
|
|
@@ -72,9 +29,8 @@ var getAppAndVersion_1 = require("./getAppAndVersion");
|
|
|
72
29
|
* import Btc from "@ledgerhq/hw-app-btc";
|
|
73
30
|
* const btc = new Btc({ transport, currency: "bitcoin" });
|
|
74
31
|
*/
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
var transport = _a.transport, _b = _a.scrambleKey, scrambleKey = _b === void 0 ? "BTC" : _b, _c = _a.currency, currency = _c === void 0 ? "bitcoin" : _c;
|
|
32
|
+
class Btc {
|
|
33
|
+
constructor({ transport, scrambleKey = "BTC", currency = "bitcoin", }) {
|
|
78
34
|
this._transport = transport;
|
|
79
35
|
this._transport.decorateAppAPIMethods(this, [
|
|
80
36
|
"getWalletXpub",
|
|
@@ -87,10 +43,10 @@ var Btc = /** @class */ (function () {
|
|
|
87
43
|
], scrambleKey);
|
|
88
44
|
// new APDU (nano app API) for bitcoin and old APDU for altcoin
|
|
89
45
|
if (currency === "bitcoin" || currency === "bitcoin_testnet") {
|
|
90
|
-
this._impl = new BtcNew_1
|
|
46
|
+
this._impl = new BtcNew_1.default(new appClient_1.AppClient(this._transport));
|
|
91
47
|
}
|
|
92
48
|
else {
|
|
93
|
-
this._impl = new BtcOld_1
|
|
49
|
+
this._impl = new BtcOld_1.default(this._transport);
|
|
94
50
|
}
|
|
95
51
|
}
|
|
96
52
|
/**
|
|
@@ -100,11 +56,11 @@ var Btc = /** @class */ (function () {
|
|
|
100
56
|
* - xpubVersion: the XPUBVersion of the coin used. (use @ledgerhq/currencies if needed)
|
|
101
57
|
* @returns XPUB of the account
|
|
102
58
|
*/
|
|
103
|
-
|
|
104
|
-
return this.changeImplIfNecessary().then(
|
|
59
|
+
getWalletXpub(arg) {
|
|
60
|
+
return this.changeImplIfNecessary().then((impl) => {
|
|
105
61
|
return impl.getWalletXpub(arg);
|
|
106
62
|
});
|
|
107
|
-
}
|
|
63
|
+
}
|
|
108
64
|
/**
|
|
109
65
|
* @param path a BIP 32 path
|
|
110
66
|
* @param options an object with optional these fields:
|
|
@@ -127,23 +83,23 @@ var Btc = /** @class */ (function () {
|
|
|
127
83
|
* btc.getWalletPublicKey("44'/0'/0'/0/0").then(o => o.bitcoinAddress)
|
|
128
84
|
* btc.getWalletPublicKey("49'/0'/0'/0/0", { format: "p2sh" }).then(o => o.bitcoinAddress)
|
|
129
85
|
*/
|
|
130
|
-
|
|
131
|
-
|
|
86
|
+
getWalletPublicKey(path, opts) {
|
|
87
|
+
let options;
|
|
132
88
|
if (arguments.length > 2 || typeof opts === "boolean") {
|
|
133
89
|
console.warn("btc.getWalletPublicKey deprecated signature used. Please switch to getWalletPublicKey(path, { format, verify })");
|
|
134
90
|
options = {
|
|
135
91
|
verify: !!opts,
|
|
136
92
|
// eslint-disable-next-line prefer-rest-params
|
|
137
|
-
format: arguments[2] ? "p2sh" : "legacy"
|
|
93
|
+
format: arguments[2] ? "p2sh" : "legacy",
|
|
138
94
|
};
|
|
139
95
|
}
|
|
140
96
|
else {
|
|
141
97
|
options = opts || {};
|
|
142
98
|
}
|
|
143
|
-
return this.changeImplIfNecessary().then(
|
|
99
|
+
return this.changeImplIfNecessary().then((impl) => {
|
|
144
100
|
return impl.getWalletPublicKey(path, options);
|
|
145
101
|
});
|
|
146
|
-
}
|
|
102
|
+
}
|
|
147
103
|
/**
|
|
148
104
|
* You can sign a message according to the Bitcoin Signature format and retrieve v, r, s given the message and the BIP 32 path of the account to sign.
|
|
149
105
|
* @example
|
|
@@ -153,12 +109,12 @@ var Btc = /** @class */ (function () {
|
|
|
153
109
|
console.log("Signature : " + signature);
|
|
154
110
|
}).catch(function(ex) {console.log(ex);});
|
|
155
111
|
*/
|
|
156
|
-
|
|
112
|
+
signMessage(path, messageHex) {
|
|
157
113
|
return (0, signMessage_1.signMessage)(this._transport, {
|
|
158
|
-
path
|
|
159
|
-
messageHex
|
|
114
|
+
path,
|
|
115
|
+
messageHex,
|
|
160
116
|
});
|
|
161
|
-
}
|
|
117
|
+
}
|
|
162
118
|
/**
|
|
163
119
|
* To sign a transaction involving standard (P2PKH) inputs, call createTransaction with the following parameters
|
|
164
120
|
* @param inputs is an array of [ transaction, output_index, optional redeem script, optional sequence ] where
|
|
@@ -192,14 +148,14 @@ var Btc = /** @class */ (function () {
|
|
|
192
148
|
outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
|
|
193
149
|
}).then(res => ...);
|
|
194
150
|
*/
|
|
195
|
-
|
|
151
|
+
createPaymentTransaction(arg) {
|
|
196
152
|
if (arguments.length > 1) {
|
|
197
153
|
throw new Error("@ledgerhq/hw-app-btc: createPaymentTransaction multi argument signature is deprecated. please switch to named parameters.");
|
|
198
154
|
}
|
|
199
|
-
return this.changeImplIfNecessary().then(
|
|
155
|
+
return this.changeImplIfNecessary().then((impl) => {
|
|
200
156
|
return impl.createPaymentTransaction(arg);
|
|
201
157
|
});
|
|
202
|
-
}
|
|
158
|
+
}
|
|
203
159
|
/**
|
|
204
160
|
* To obtain the signature of multisignature (P2SH) inputs, call signP2SHTransaction_async with the folowing parameters
|
|
205
161
|
* @param inputs is an array of [ transaction, output_index, redeem script, optional sequence ] where
|
|
@@ -219,82 +175,62 @@ var Btc = /** @class */ (function () {
|
|
|
219
175
|
outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
|
|
220
176
|
}).then(result => ...);
|
|
221
177
|
*/
|
|
222
|
-
|
|
178
|
+
signP2SHTransaction(arg) {
|
|
223
179
|
return (0, signP2SHTransaction_1.signP2SHTransaction)(this._transport, arg);
|
|
224
|
-
}
|
|
180
|
+
}
|
|
225
181
|
/**
|
|
226
182
|
* For each UTXO included in your transaction, create a transaction object from the raw serialized version of the transaction used in this UTXO.
|
|
227
183
|
* @example
|
|
228
184
|
const tx1 = btc.splitTransaction("01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000");
|
|
229
185
|
*/
|
|
230
|
-
|
|
231
|
-
if (isSegwitSupported === void 0) { isSegwitSupported = false; }
|
|
232
|
-
if (hasTimestamp === void 0) { hasTimestamp = false; }
|
|
233
|
-
if (hasExtraData === void 0) { hasExtraData = false; }
|
|
234
|
-
if (additionals === void 0) { additionals = []; }
|
|
186
|
+
splitTransaction(transactionHex, isSegwitSupported = false, hasTimestamp = false, hasExtraData = false, additionals = []) {
|
|
235
187
|
return (0, splitTransaction_1.splitTransaction)(transactionHex, isSegwitSupported, hasTimestamp, hasExtraData, additionals);
|
|
236
|
-
}
|
|
188
|
+
}
|
|
237
189
|
/**
|
|
238
190
|
@example
|
|
239
191
|
const tx1 = btc.splitTransaction("01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000");
|
|
240
192
|
const outputScript = btc.serializeTransactionOutputs(tx1).toString('hex');
|
|
241
193
|
*/
|
|
242
|
-
|
|
194
|
+
serializeTransactionOutputs(t) {
|
|
243
195
|
return (0, serializeTransaction_1.serializeTransactionOutputs)(t);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
if (additionals === void 0) { additionals = []; }
|
|
196
|
+
}
|
|
197
|
+
getTrustedInput(indexLookup, transaction, additionals = []) {
|
|
247
198
|
return (0, getTrustedInput_1.getTrustedInput)(this._transport, indexLookup, transaction, additionals);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
if (additionals === void 0) { additionals = []; }
|
|
199
|
+
}
|
|
200
|
+
getTrustedInputBIP143(indexLookup, transaction, additionals = []) {
|
|
251
201
|
return (0, getTrustedInputBIP143_1.getTrustedInputBIP143)(this._transport, indexLookup, transaction, additionals);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
case 4:
|
|
283
|
-
// We can't query the version of the Bitcoin app if we're coming from Exchange;
|
|
284
|
-
// therefore, we use a workaround to distinguish legacy and new versions.
|
|
285
|
-
// This can be removed once Ledger Live enforces minimum bitcoin version >= 2.1.0.
|
|
286
|
-
isBtcLegacy = _b.sent();
|
|
287
|
-
_b.label = 5;
|
|
288
|
-
case 5:
|
|
289
|
-
if (isBtcLegacy) {
|
|
290
|
-
this._impl = new BtcOld_1["default"](this._transport);
|
|
291
|
-
}
|
|
292
|
-
return [2 /*return*/, this._impl];
|
|
293
|
-
}
|
|
294
|
-
});
|
|
202
|
+
}
|
|
203
|
+
changeImplIfNecessary() {
|
|
204
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
205
|
+
// if BtcOld was instantiated, stick with it
|
|
206
|
+
if (this._impl instanceof BtcOld_1.default)
|
|
207
|
+
return this._impl;
|
|
208
|
+
const appAndVersion = yield (0, getAppAndVersion_1.getAppAndVersion)(this._transport);
|
|
209
|
+
let isBtcLegacy = true; // default for all altcoins
|
|
210
|
+
if (appAndVersion.name === "Bitcoin" ||
|
|
211
|
+
appAndVersion.name === "Bitcoin Test") {
|
|
212
|
+
const [major, minor] = appAndVersion.version.split(".");
|
|
213
|
+
// we use the legacy protocol for versions below 2.1.0 of the Bitcoin app.
|
|
214
|
+
isBtcLegacy =
|
|
215
|
+
parseInt(major) <= 1 || (parseInt(major) == 2 && parseInt(minor) == 0);
|
|
216
|
+
}
|
|
217
|
+
else if (appAndVersion.name === "Bitcoin Legacy" ||
|
|
218
|
+
appAndVersion.name === "Bitcoin Test Legacy") {
|
|
219
|
+
// the "Bitcoin Legacy" and "Bitcoin Testnet Legacy" app use the legacy protocol, regardless of the version
|
|
220
|
+
isBtcLegacy = true;
|
|
221
|
+
}
|
|
222
|
+
else if (appAndVersion.name === "Exchange") {
|
|
223
|
+
// We can't query the version of the Bitcoin app if we're coming from Exchange;
|
|
224
|
+
// therefore, we use a workaround to distinguish legacy and new versions.
|
|
225
|
+
// This can be removed once Ledger Live enforces minimum bitcoin version >= 2.1.0.
|
|
226
|
+
isBtcLegacy = yield (0, getAppAndVersion_1.checkIsBtcLegacy)(this._transport);
|
|
227
|
+
}
|
|
228
|
+
if (isBtcLegacy) {
|
|
229
|
+
this._impl = new BtcOld_1.default(this._transport);
|
|
230
|
+
}
|
|
231
|
+
return this._impl;
|
|
295
232
|
});
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
exports["default"] = Btc;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
exports.default = Btc;
|
|
300
236
|
//# sourceMappingURL=Btc.js.map
|
package/lib/Btc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Btc.js","sourceRoot":"","sources":["../src/Btc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Btc.js","sourceRoot":"","sources":["../src/Btc.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,sDAA8B;AAC9B,sDAA8B;AAE9B,uDAAoD;AACpD,mEAAgE;AAEhE,kDAA+C;AAC/C,iEAAqE;AAErE,yDAAsD;AAGtD,+DAA4D;AAC5D,+CAA4C;AAC5C,yDAAwE;AAExE;;;;;;GAMG;AAEH,MAAqB,GAAG;IAItB,YAAY,EACV,SAAS,EACT,WAAW,GAAG,KAAK,EACnB,QAAQ,GAAG,SAAS,GAKrB;QACC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,UAAU,CAAC,qBAAqB,CACnC,IAA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