@ledgerhq/hw-app-btc 10.0.1 → 10.0.2-nightly.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 +7 -0
- package/lib/Btc.d.ts.map +1 -1
- package/lib/Btc.js +72 -97
- 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.d.ts.map +1 -1
- package/lib-es/Btc.js +58 -84
- 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/src/Btc.ts +28 -5
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @ledgerhq/hw-app-btc@10.0.
|
|
2
|
+
> @ledgerhq/hw-app-btc@10.0.2-nightly.0 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
package/lib/Btc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Btc.d.ts","sourceRoot":"","sources":["../src/Btc.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAC;AACpD,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAGhE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,YAAY,EAAE,aAAa,EAAE,CAAC;AAK9B;;;;;;GAMG;AAEH,MAAM,CAAC,OAAO,OAAO,GAAG;IACtB,OAAO,CAAC,UAAU,CAAY;IAC9B,OAAO,CAAC,KAAK,CAAkB;gBAEnB,EACV,SAAS,EACT,WAAmB,EACnB,QAAoB,GACrB,EAAE;QACD,SAAS,EAAE,SAAS,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB;IAuBD;;;;;;OAMG;IACH,aAAa,CAAC,GAAG,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAM1E;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,kBAAkB,CAChB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE;QACL,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,MAAM,CAAC,EAAE,aAAa,CAAC;KACxB,GACA,OA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,MAAM,CAAC;KACX,CAAC;IAOF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,wBAAwB,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC;IAWpE;;;;;;;;;;;;;;;;;;OAkBG;IACH,mBAAmB,CAAC,GAAG,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAInE;;;;OAIG;IACH,gBAAgB,CACd,cAAc,EAAE,MAAM,EACtB,iBAAiB,GAAE,OAAO,GAAG,IAAI,GAAG,SAAiB,EACrD,YAAY,UAAQ,EACpB,YAAY,UAAQ,EACpB,WAAW,GAAE,KAAK,CAAC,MAAM,CAAM,GAC9B,WAAW;IAUd;;;;MAIE;IACF,2BAA2B,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM;IAInD,eAAe,CACb,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,WAAW,EACxB,WAAW,GAAE,KAAK,CAAC,MAAM,CAAM,GAC9B,OAAO,CAAC,MAAM,CAAC;IASlB,qBAAqB,CACnB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,WAAW,EACxB,WAAW,GAAE,KAAK,CAAC,MAAM,CAAM,GAC9B,MAAM;IASH,qBAAqB,IAAI,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;CAiCxD"}
|
package/lib/Btc.js
CHANGED
|
@@ -8,47 +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
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
13
|
};
|
|
41
|
-
exports
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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");
|
|
52
25
|
/**
|
|
53
26
|
* Bitcoin API.
|
|
54
27
|
*
|
|
@@ -56,9 +29,8 @@ var getAppAndVersion_1 = require("./getAppAndVersion");
|
|
|
56
29
|
* import Btc from "@ledgerhq/hw-app-btc";
|
|
57
30
|
* const btc = new Btc({ transport, currency: "bitcoin" });
|
|
58
31
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
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", }) {
|
|
62
34
|
this._transport = transport;
|
|
63
35
|
this._transport.decorateAppAPIMethods(this, [
|
|
64
36
|
"getWalletXpub",
|
|
@@ -71,10 +43,10 @@ var Btc = /** @class */ (function () {
|
|
|
71
43
|
], scrambleKey);
|
|
72
44
|
// new APDU (nano app API) for bitcoin and old APDU for altcoin
|
|
73
45
|
if (currency === "bitcoin" || currency === "bitcoin_testnet") {
|
|
74
|
-
this._impl = new BtcNew_1
|
|
46
|
+
this._impl = new BtcNew_1.default(new appClient_1.AppClient(this._transport));
|
|
75
47
|
}
|
|
76
48
|
else {
|
|
77
|
-
this._impl = new BtcOld_1
|
|
49
|
+
this._impl = new BtcOld_1.default(this._transport);
|
|
78
50
|
}
|
|
79
51
|
}
|
|
80
52
|
/**
|
|
@@ -84,11 +56,11 @@ var Btc = /** @class */ (function () {
|
|
|
84
56
|
* - xpubVersion: the XPUBVersion of the coin used. (use @ledgerhq/currencies if needed)
|
|
85
57
|
* @returns XPUB of the account
|
|
86
58
|
*/
|
|
87
|
-
|
|
88
|
-
return this.changeImplIfNecessary().then(
|
|
59
|
+
getWalletXpub(arg) {
|
|
60
|
+
return this.changeImplIfNecessary().then((impl) => {
|
|
89
61
|
return impl.getWalletXpub(arg);
|
|
90
62
|
});
|
|
91
|
-
}
|
|
63
|
+
}
|
|
92
64
|
/**
|
|
93
65
|
* @param path a BIP 32 path
|
|
94
66
|
* @param options an object with optional these fields:
|
|
@@ -111,23 +83,23 @@ var Btc = /** @class */ (function () {
|
|
|
111
83
|
* btc.getWalletPublicKey("44'/0'/0'/0/0").then(o => o.bitcoinAddress)
|
|
112
84
|
* btc.getWalletPublicKey("49'/0'/0'/0/0", { format: "p2sh" }).then(o => o.bitcoinAddress)
|
|
113
85
|
*/
|
|
114
|
-
|
|
115
|
-
|
|
86
|
+
getWalletPublicKey(path, opts) {
|
|
87
|
+
let options;
|
|
116
88
|
if (arguments.length > 2 || typeof opts === "boolean") {
|
|
117
89
|
console.warn("btc.getWalletPublicKey deprecated signature used. Please switch to getWalletPublicKey(path, { format, verify })");
|
|
118
90
|
options = {
|
|
119
91
|
verify: !!opts,
|
|
120
92
|
// eslint-disable-next-line prefer-rest-params
|
|
121
|
-
format: arguments[2] ? "p2sh" : "legacy"
|
|
93
|
+
format: arguments[2] ? "p2sh" : "legacy",
|
|
122
94
|
};
|
|
123
95
|
}
|
|
124
96
|
else {
|
|
125
97
|
options = opts || {};
|
|
126
98
|
}
|
|
127
|
-
return this.changeImplIfNecessary().then(
|
|
99
|
+
return this.changeImplIfNecessary().then((impl) => {
|
|
128
100
|
return impl.getWalletPublicKey(path, options);
|
|
129
101
|
});
|
|
130
|
-
}
|
|
102
|
+
}
|
|
131
103
|
/**
|
|
132
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.
|
|
133
105
|
* @example
|
|
@@ -137,12 +109,12 @@ var Btc = /** @class */ (function () {
|
|
|
137
109
|
console.log("Signature : " + signature);
|
|
138
110
|
}).catch(function(ex) {console.log(ex);});
|
|
139
111
|
*/
|
|
140
|
-
|
|
112
|
+
signMessage(path, messageHex) {
|
|
141
113
|
return (0, signMessage_1.signMessage)(this._transport, {
|
|
142
|
-
path
|
|
143
|
-
messageHex
|
|
114
|
+
path,
|
|
115
|
+
messageHex,
|
|
144
116
|
});
|
|
145
|
-
}
|
|
117
|
+
}
|
|
146
118
|
/**
|
|
147
119
|
* To sign a transaction involving standard (P2PKH) inputs, call createTransaction with the following parameters
|
|
148
120
|
* @param inputs is an array of [ transaction, output_index, optional redeem script, optional sequence ] where
|
|
@@ -176,14 +148,14 @@ var Btc = /** @class */ (function () {
|
|
|
176
148
|
outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
|
|
177
149
|
}).then(res => ...);
|
|
178
150
|
*/
|
|
179
|
-
|
|
151
|
+
createPaymentTransaction(arg) {
|
|
180
152
|
if (arguments.length > 1) {
|
|
181
153
|
throw new Error("@ledgerhq/hw-app-btc: createPaymentTransaction multi argument signature is deprecated. please switch to named parameters.");
|
|
182
154
|
}
|
|
183
|
-
return this.changeImplIfNecessary().then(
|
|
155
|
+
return this.changeImplIfNecessary().then((impl) => {
|
|
184
156
|
return impl.createPaymentTransaction(arg);
|
|
185
157
|
});
|
|
186
|
-
}
|
|
158
|
+
}
|
|
187
159
|
/**
|
|
188
160
|
* To obtain the signature of multisignature (P2SH) inputs, call signP2SHTransaction_async with the folowing parameters
|
|
189
161
|
* @param inputs is an array of [ transaction, output_index, redeem script, optional sequence ] where
|
|
@@ -203,59 +175,62 @@ var Btc = /** @class */ (function () {
|
|
|
203
175
|
outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
|
|
204
176
|
}).then(result => ...);
|
|
205
177
|
*/
|
|
206
|
-
|
|
178
|
+
signP2SHTransaction(arg) {
|
|
207
179
|
return (0, signP2SHTransaction_1.signP2SHTransaction)(this._transport, arg);
|
|
208
|
-
}
|
|
180
|
+
}
|
|
209
181
|
/**
|
|
210
182
|
* For each UTXO included in your transaction, create a transaction object from the raw serialized version of the transaction used in this UTXO.
|
|
211
183
|
* @example
|
|
212
184
|
const tx1 = btc.splitTransaction("01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000");
|
|
213
185
|
*/
|
|
214
|
-
|
|
215
|
-
if (isSegwitSupported === void 0) { isSegwitSupported = false; }
|
|
216
|
-
if (hasTimestamp === void 0) { hasTimestamp = false; }
|
|
217
|
-
if (hasExtraData === void 0) { hasExtraData = false; }
|
|
218
|
-
if (additionals === void 0) { additionals = []; }
|
|
186
|
+
splitTransaction(transactionHex, isSegwitSupported = false, hasTimestamp = false, hasExtraData = false, additionals = []) {
|
|
219
187
|
return (0, splitTransaction_1.splitTransaction)(transactionHex, isSegwitSupported, hasTimestamp, hasExtraData, additionals);
|
|
220
|
-
}
|
|
188
|
+
}
|
|
221
189
|
/**
|
|
222
190
|
@example
|
|
223
191
|
const tx1 = btc.splitTransaction("01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000");
|
|
224
192
|
const outputScript = btc.serializeTransactionOutputs(tx1).toString('hex');
|
|
225
193
|
*/
|
|
226
|
-
|
|
194
|
+
serializeTransactionOutputs(t) {
|
|
227
195
|
return (0, serializeTransaction_1.serializeTransactionOutputs)(t);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
if (additionals === void 0) { additionals = []; }
|
|
196
|
+
}
|
|
197
|
+
getTrustedInput(indexLookup, transaction, additionals = []) {
|
|
231
198
|
return (0, getTrustedInput_1.getTrustedInput)(this._transport, indexLookup, transaction, additionals);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
if (additionals === void 0) { additionals = []; }
|
|
199
|
+
}
|
|
200
|
+
getTrustedInputBIP143(indexLookup, transaction, additionals = []) {
|
|
235
201
|
return (0, getTrustedInputBIP143_1.getTrustedInputBIP143)(this._transport, indexLookup, transaction, additionals);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
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;
|
|
256
232
|
});
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
exports["default"] = Btc;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
exports.default = Btc;
|
|
261
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,IAAI,EACJ;YACE,eAAe;YACf,oBAAoB;YACpB,qBAAqB;YACrB,aAAa;YACb,0BAA0B;YAC1B,iBAAiB;YACjB,uBAAuB;SACxB,EACD,WAAW,CACZ,CAAC;QACF,+DAA+D;QAC/D,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,iBAAiB,EAAE;YAC5D,IAAI,CAAC,KAAK,GAAG,IAAI,gBAAM,CAAC,IAAI,qBAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;SACzD;aAAM;YACL,IAAI,CAAC,KAAK,GAAG,IAAI,gBAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SAC1C;IACH,CAAC;IAED;;;;;;OAMG;IACH,aAAa,CAAC,GAA0C;QACtD,OAAO,IAAI,CAAC,qBAAqB,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;YAChD,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,kBAAkB,CAChB,IAAY,EACZ,IAGC;QAMD,IAAI,OA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