@ledgerhq/hw-app-btc 6.2.0 → 6.9.1-6.9.1-taproot.0.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/lib/Btc.d.ts +7 -3
- package/lib/Btc.d.ts.map +1 -1
- package/lib/Btc.js +99 -30
- package/lib/Btc.js.map +1 -1
- package/lib/BtcNew.d.ts +70 -0
- package/lib/BtcNew.d.ts.map +1 -0
- package/lib/BtcNew.js +372 -0
- package/lib/BtcNew.js.map +1 -0
- package/lib/BtcOld.d.ts +114 -0
- package/lib/BtcOld.d.ts.map +1 -0
- package/lib/BtcOld.js +138 -0
- package/lib/BtcOld.js.map +1 -0
- package/lib/bip32.d.ts +8 -0
- package/lib/bip32.d.ts.map +1 -1
- package/lib/bip32.js +32 -3
- package/lib/bip32.js.map +1 -1
- package/lib/buffertools.d.ts +28 -0
- package/lib/buffertools.d.ts.map +1 -0
- package/lib/buffertools.js +100 -0
- package/lib/buffertools.js.map +1 -0
- package/lib/createTransaction.d.ts.map +1 -1
- package/lib/createTransaction.js +16 -16
- package/lib/createTransaction.js.map +1 -1
- package/lib/finalizeInput.js +1 -1
- package/lib/finalizeInput.js.map +1 -1
- package/lib/getAppAndVersion.js +1 -1
- package/lib/getAppAndVersion.js.map +1 -1
- package/lib/getTrustedInput.js +6 -6
- package/lib/getTrustedInput.js.map +1 -1
- package/lib/getTrustedInputBIP143.js +2 -2
- 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 +1 -1
- package/lib/getWalletPublicKey.js.map +1 -1
- package/lib/hashPublicKey.d.ts +1 -1
- package/lib/hashPublicKey.d.ts.map +1 -1
- package/lib/hashPublicKey.js +1 -1
- package/lib/hashPublicKey.js.map +1 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -0
- package/lib/newops/appClient.d.ts +14 -0
- package/lib/newops/appClient.d.ts.map +1 -0
- package/lib/newops/appClient.js +242 -0
- package/lib/newops/appClient.js.map +1 -0
- package/lib/newops/clientCommands.d.ts +61 -0
- package/lib/newops/clientCommands.d.ts.map +1 -0
- package/lib/newops/clientCommands.js +331 -0
- package/lib/newops/clientCommands.js.map +1 -0
- package/lib/newops/merkelizedPsbt.d.ts +15 -0
- package/lib/newops/merkelizedPsbt.d.ts.map +1 -0
- package/lib/newops/merkelizedPsbt.js +91 -0
- package/lib/newops/merkelizedPsbt.js.map +1 -0
- package/lib/newops/merkle.d.ts +29 -0
- package/lib/newops/merkle.d.ts.map +1 -0
- package/lib/newops/merkle.js +133 -0
- package/lib/newops/merkle.js.map +1 -0
- package/lib/newops/merkleMap.d.ts +15 -0
- package/lib/newops/merkleMap.d.ts.map +1 -0
- package/lib/newops/merkleMap.js +37 -0
- package/lib/newops/merkleMap.js.map +1 -0
- package/lib/newops/policy.d.ts +14 -0
- package/lib/newops/policy.d.ts.map +1 -0
- package/lib/newops/policy.js +40 -0
- package/lib/newops/policy.js.map +1 -0
- package/lib/newops/psbtExtractor.d.ts +4 -0
- package/lib/newops/psbtExtractor.d.ts.map +1 -0
- package/lib/newops/psbtExtractor.js +36 -0
- package/lib/newops/psbtExtractor.js.map +1 -0
- package/lib/newops/psbtFinalizer.d.ts +7 -0
- package/lib/newops/psbtFinalizer.d.ts.map +1 -0
- package/lib/newops/psbtFinalizer.js +111 -0
- package/lib/newops/psbtFinalizer.js.map +1 -0
- package/lib/newops/psbtv2.d.ts +129 -0
- package/lib/newops/psbtv2.d.ts.map +1 -0
- package/lib/newops/psbtv2.js +478 -0
- package/lib/newops/psbtv2.js.map +1 -0
- package/lib/serializeTransaction.js +4 -4
- package/lib/serializeTransaction.js.map +1 -1
- package/lib/signP2SHTransaction.js +5 -5
- package/lib/signP2SHTransaction.js.map +1 -1
- package/lib/signTransaction.js +1 -1
- package/lib/signTransaction.js.map +1 -1
- package/lib/splitTransaction.js +7 -7
- package/lib/splitTransaction.js.map +1 -1
- package/lib/startUntrustedHashTransactionInput.js +2 -2
- package/lib/startUntrustedHashTransactionInput.js.map +1 -1
- package/lib/varint.d.ts.map +1 -1
- package/lib/varint.js +1 -0
- package/lib/varint.js.map +1 -1
- package/lib-es/Btc.d.ts +7 -3
- package/lib-es/Btc.d.ts.map +1 -1
- package/lib-es/Btc.js +92 -26
- package/lib-es/Btc.js.map +1 -1
- package/lib-es/BtcNew.d.ts +70 -0
- package/lib-es/BtcNew.d.ts.map +1 -0
- package/lib-es/BtcNew.js +370 -0
- package/lib-es/BtcNew.js.map +1 -0
- package/lib-es/BtcOld.d.ts +114 -0
- package/lib-es/BtcOld.d.ts.map +1 -0
- package/lib-es/BtcOld.js +136 -0
- package/lib-es/BtcOld.js.map +1 -0
- package/lib-es/bip32.d.ts +8 -0
- package/lib-es/bip32.d.ts.map +1 -1
- package/lib-es/bip32.js +26 -2
- package/lib-es/bip32.js.map +1 -1
- package/lib-es/buffertools.d.ts +28 -0
- package/lib-es/buffertools.d.ts.map +1 -0
- package/lib-es/buffertools.js +94 -0
- package/lib-es/buffertools.js.map +1 -0
- package/lib-es/createTransaction.d.ts.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.map +1 -1
- package/lib-es/hashPublicKey.d.ts +1 -1
- package/lib-es/hashPublicKey.d.ts.map +1 -1
- package/lib-es/index.d.ts +3 -0
- package/lib-es/index.d.ts.map +1 -0
- package/lib-es/index.js +3 -0
- package/lib-es/index.js.map +1 -0
- package/lib-es/newops/appClient.d.ts +14 -0
- package/lib-es/newops/appClient.d.ts.map +1 -0
- package/lib-es/newops/appClient.js +239 -0
- package/lib-es/newops/appClient.js.map +1 -0
- package/lib-es/newops/clientCommands.d.ts +61 -0
- package/lib-es/newops/clientCommands.d.ts.map +1 -0
- package/lib-es/newops/clientCommands.js +328 -0
- package/lib-es/newops/clientCommands.js.map +1 -0
- package/lib-es/newops/merkelizedPsbt.d.ts +15 -0
- package/lib-es/newops/merkelizedPsbt.d.ts.map +1 -0
- package/lib-es/newops/merkelizedPsbt.js +88 -0
- package/lib-es/newops/merkelizedPsbt.js.map +1 -0
- package/lib-es/newops/merkle.d.ts +29 -0
- package/lib-es/newops/merkle.d.ts.map +1 -0
- package/lib-es/newops/merkle.js +129 -0
- package/lib-es/newops/merkle.js.map +1 -0
- package/lib-es/newops/merkleMap.d.ts +15 -0
- package/lib-es/newops/merkleMap.d.ts.map +1 -0
- package/lib-es/newops/merkleMap.js +34 -0
- package/lib-es/newops/merkleMap.js.map +1 -0
- package/lib-es/newops/policy.d.ts +14 -0
- package/lib-es/newops/policy.d.ts.map +1 -0
- package/lib-es/newops/policy.js +36 -0
- package/lib-es/newops/policy.js.map +1 -0
- package/lib-es/newops/psbtExtractor.d.ts +4 -0
- package/lib-es/newops/psbtExtractor.d.ts.map +1 -0
- package/lib-es/newops/psbtExtractor.js +32 -0
- package/lib-es/newops/psbtExtractor.js.map +1 -0
- package/lib-es/newops/psbtFinalizer.d.ts +7 -0
- package/lib-es/newops/psbtFinalizer.d.ts.map +1 -0
- package/lib-es/newops/psbtFinalizer.js +107 -0
- package/lib-es/newops/psbtFinalizer.js.map +1 -0
- package/lib-es/newops/psbtv2.d.ts +129 -0
- package/lib-es/newops/psbtv2.d.ts.map +1 -0
- package/lib-es/newops/psbtv2.js +475 -0
- package/lib-es/newops/psbtv2.js.map +1 -0
- package/lib-es/varint.d.ts.map +1 -1
- package/lib-es/varint.js +1 -0
- package/lib-es/varint.js.map +1 -1
- package/package.json +7 -4
- package/src/Btc.ts +42 -25
- package/src/BtcNew.ts +326 -0
- package/src/BtcOld.ts +156 -0
- package/src/bip32.ts +34 -2
- package/src/buffertools.ts +102 -0
- package/src/createTransaction.ts +2 -2
- package/src/getWalletPublicKey.ts +6 -1
- package/src/hashPublicKey.ts +1 -1
- package/src/index.ts +2 -0
- package/src/newops/appClient.ts +178 -0
- package/src/newops/clientCommands.ts +312 -0
- package/src/newops/merkelizedPsbt.ts +55 -0
- package/src/newops/merkle.ts +123 -0
- package/src/newops/merkleMap.ts +39 -0
- package/src/newops/policy.ts +52 -0
- package/src/newops/psbtExtractor.ts +33 -0
- package/src/newops/psbtFinalizer.ts +110 -0
- package/src/newops/psbtv2.ts +548 -0
- package/src/varint.ts +2 -0
- package/tests/Btc.integration.test.ts +89 -0
- package/tests/Btc.test.ts +6 -0
- package/tests/newops/BtcNew.test.ts +646 -0
- package/tests/newops/common.ts +25 -0
- package/tests/newops/merkle.test.ts +97 -0
- package/tests/trustedInputs.test.ts +4 -0
package/lib/Btc.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type Transport from "@ledgerhq/hw-transport";
|
|
3
|
-
import type { AddressFormat } from "./getWalletPublicKey";
|
|
4
|
-
import type { Transaction } from "./types";
|
|
5
3
|
import type { CreateTransactionArg } from "./createTransaction";
|
|
4
|
+
import type { AddressFormat } from "./getWalletPublicKey";
|
|
6
5
|
import type { SignP2SHTransactionArg } from "./signP2SHTransaction";
|
|
6
|
+
import type { Transaction } from "./types";
|
|
7
7
|
export type { AddressFormat };
|
|
8
8
|
/**
|
|
9
9
|
* Bitcoin API.
|
|
@@ -21,7 +21,7 @@ export default class Btc {
|
|
|
21
21
|
*
|
|
22
22
|
* - verify (boolean) will ask user to confirm the address on the device
|
|
23
23
|
*
|
|
24
|
-
* - format ("legacy" | "p2sh" | "bech32" | "cashaddr") to use different bitcoin address formatter.
|
|
24
|
+
* - format ("legacy" | "p2sh" | "bech32" | "bech32m" | "cashaddr") to use different bitcoin address formatter.
|
|
25
25
|
*
|
|
26
26
|
* NB The normal usage is to use:
|
|
27
27
|
*
|
|
@@ -126,5 +126,9 @@ export default class Btc {
|
|
|
126
126
|
serializeTransactionOutputs(t: Transaction): Buffer;
|
|
127
127
|
getTrustedInput(indexLookup: number, transaction: Transaction, additionals?: Array<string>): Promise<string>;
|
|
128
128
|
getTrustedInputBIP143(indexLookup: number, transaction: Transaction, additionals?: Array<string>): string;
|
|
129
|
+
private getCorrectImpl;
|
|
130
|
+
private old;
|
|
131
|
+
private new;
|
|
132
|
+
private useNewApp;
|
|
129
133
|
}
|
|
130
134
|
//# sourceMappingURL=Btc.d.ts.map
|
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;
|
|
1
|
+
{"version":3,"file":"Btc.d.ts","sourceRoot":"","sources":["../src/Btc.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAC;AAIpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAIhE,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;AAC9B;;;;;;GAMG;AAEH,MAAM,CAAC,OAAO,OAAO,GAAG;IACtB,SAAS,EAAE,SAAS,CAAC;gBAET,SAAS,EAAE,SAAS,EAAE,WAAW,SAAQ;IAgBrD;;;;;;;;;;;;;;;;;;;;;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,OAAO,CAAC;QACT,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,EAAE,MAAM,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;KACnB,C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iter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
40
|
};
|
|
13
41
|
exports.__esModule = true;
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
42
|
+
var semver_1 = __importDefault(require("semver"));
|
|
43
|
+
var BtcNew_1 = __importDefault(require("./BtcNew"));
|
|
44
|
+
var BtcOld_1 = __importDefault(require("./BtcOld"));
|
|
45
|
+
var getAppAndVersion_1 = require("./getAppAndVersion");
|
|
17
46
|
var getTrustedInput_1 = require("./getTrustedInput");
|
|
18
47
|
var getTrustedInputBIP143_1 = require("./getTrustedInputBIP143");
|
|
19
|
-
var
|
|
20
|
-
var signP2SHTransaction_1 = require("./signP2SHTransaction");
|
|
48
|
+
var appClient_1 = require("./newops/appClient");
|
|
21
49
|
var serializeTransaction_1 = require("./serializeTransaction");
|
|
50
|
+
var splitTransaction_1 = require("./splitTransaction");
|
|
22
51
|
/**
|
|
23
52
|
* Bitcoin API.
|
|
24
53
|
*
|
|
@@ -45,7 +74,7 @@ var Btc = /** @class */ (function () {
|
|
|
45
74
|
*
|
|
46
75
|
* - verify (boolean) will ask user to confirm the address on the device
|
|
47
76
|
*
|
|
48
|
-
* - format ("legacy" | "p2sh" | "bech32" | "cashaddr") to use different bitcoin address formatter.
|
|
77
|
+
* - format ("legacy" | "p2sh" | "bech32" | "bech32m" | "cashaddr") to use different bitcoin address formatter.
|
|
49
78
|
*
|
|
50
79
|
* NB The normal usage is to use:
|
|
51
80
|
*
|
|
@@ -74,7 +103,9 @@ var Btc = /** @class */ (function () {
|
|
|
74
103
|
else {
|
|
75
104
|
options = opts || {};
|
|
76
105
|
}
|
|
77
|
-
return
|
|
106
|
+
return this.getCorrectImpl().then(function (impl) {
|
|
107
|
+
return impl.getWalletPublicKey(path, options);
|
|
108
|
+
});
|
|
78
109
|
};
|
|
79
110
|
/**
|
|
80
111
|
* 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.
|
|
@@ -86,10 +117,7 @@ var Btc = /** @class */ (function () {
|
|
|
86
117
|
}).catch(function(ex) {console.log(ex);});
|
|
87
118
|
*/
|
|
88
119
|
Btc.prototype.signMessageNew = function (path, messageHex) {
|
|
89
|
-
return
|
|
90
|
-
path: path,
|
|
91
|
-
messageHex: messageHex
|
|
92
|
-
});
|
|
120
|
+
return this.old().signMessageNew(path, messageHex);
|
|
93
121
|
};
|
|
94
122
|
/**
|
|
95
123
|
* To sign a transaction involving standard (P2PKH) inputs, call createTransaction with the following parameters
|
|
@@ -127,7 +155,9 @@ var Btc = /** @class */ (function () {
|
|
|
127
155
|
if (arguments.length > 1) {
|
|
128
156
|
console.warn("@ledgerhq/hw-app-btc: createPaymentTransactionNew multi argument signature is deprecated. please switch to named parameters.");
|
|
129
157
|
}
|
|
130
|
-
return
|
|
158
|
+
return this.getCorrectImpl().then(function (impl) {
|
|
159
|
+
return impl.createPaymentTransactionNew(arg);
|
|
160
|
+
});
|
|
131
161
|
};
|
|
132
162
|
/**
|
|
133
163
|
* To obtain the signature of multisignature (P2SH) inputs, call signP2SHTransaction_async with the folowing parameters
|
|
@@ -149,10 +179,7 @@ var Btc = /** @class */ (function () {
|
|
|
149
179
|
}).then(result => ...);
|
|
150
180
|
*/
|
|
151
181
|
Btc.prototype.signP2SHTransaction = function (arg) {
|
|
152
|
-
|
|
153
|
-
console.warn("@ledgerhq/hw-app-btc: signP2SHTransaction multi argument signature is deprecated. please switch to named parameters.");
|
|
154
|
-
}
|
|
155
|
-
return signP2SHTransaction_1.signP2SHTransaction(this.transport, arg);
|
|
182
|
+
return this.old().signP2SHTransaction(arg);
|
|
156
183
|
};
|
|
157
184
|
/**
|
|
158
185
|
* For each UTXO included in your transaction, create a transaction object from the raw serialized version of the transaction used in this UTXO.
|
|
@@ -164,7 +191,7 @@ var Btc = /** @class */ (function () {
|
|
|
164
191
|
if (hasTimestamp === void 0) { hasTimestamp = false; }
|
|
165
192
|
if (hasExtraData === void 0) { hasExtraData = false; }
|
|
166
193
|
if (additionals === void 0) { additionals = []; }
|
|
167
|
-
return splitTransaction_1.splitTransaction(transactionHex, isSegwitSupported, hasTimestamp, hasExtraData, additionals);
|
|
194
|
+
return (0, splitTransaction_1.splitTransaction)(transactionHex, isSegwitSupported, hasTimestamp, hasExtraData, additionals);
|
|
168
195
|
};
|
|
169
196
|
/**
|
|
170
197
|
@example
|
|
@@ -172,15 +199,57 @@ var Btc = /** @class */ (function () {
|
|
|
172
199
|
const outputScript = btc.serializeTransactionOutputs(tx1).toString('hex');
|
|
173
200
|
*/
|
|
174
201
|
Btc.prototype.serializeTransactionOutputs = function (t) {
|
|
175
|
-
return serializeTransaction_1.serializeTransactionOutputs(t);
|
|
202
|
+
return (0, serializeTransaction_1.serializeTransactionOutputs)(t);
|
|
176
203
|
};
|
|
177
204
|
Btc.prototype.getTrustedInput = function (indexLookup, transaction, additionals) {
|
|
178
205
|
if (additionals === void 0) { additionals = []; }
|
|
179
|
-
return getTrustedInput_1.getTrustedInput(this.transport, indexLookup, transaction, additionals);
|
|
206
|
+
return (0, getTrustedInput_1.getTrustedInput)(this.transport, indexLookup, transaction, additionals);
|
|
180
207
|
};
|
|
181
208
|
Btc.prototype.getTrustedInputBIP143 = function (indexLookup, transaction, additionals) {
|
|
182
209
|
if (additionals === void 0) { additionals = []; }
|
|
183
|
-
return getTrustedInputBIP143_1.getTrustedInputBIP143(this.transport, indexLookup, transaction, additionals);
|
|
210
|
+
return (0, getTrustedInputBIP143_1.getTrustedInputBIP143)(this.transport, indexLookup, transaction, additionals);
|
|
211
|
+
};
|
|
212
|
+
Btc.prototype.getCorrectImpl = function () {
|
|
213
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
214
|
+
var isNewApp;
|
|
215
|
+
return __generator(this, function (_a) {
|
|
216
|
+
switch (_a.label) {
|
|
217
|
+
case 0: return [4 /*yield*/, this.useNewApp()];
|
|
218
|
+
case 1:
|
|
219
|
+
isNewApp = _a.sent();
|
|
220
|
+
if (isNewApp) {
|
|
221
|
+
return [2 /*return*/, this["new"]()];
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
return [2 /*return*/, this.old()];
|
|
225
|
+
}
|
|
226
|
+
return [2 /*return*/];
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
Btc.prototype.old = function () {
|
|
232
|
+
return new BtcOld_1["default"](this.transport);
|
|
233
|
+
};
|
|
234
|
+
Btc.prototype["new"] = function () {
|
|
235
|
+
return new BtcNew_1["default"](new appClient_1.AppClient(this.transport));
|
|
236
|
+
};
|
|
237
|
+
Btc.prototype.useNewApp = function () {
|
|
238
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
239
|
+
var a, isNewApp;
|
|
240
|
+
return __generator(this, function (_a) {
|
|
241
|
+
switch (_a.label) {
|
|
242
|
+
case 0: return [4 /*yield*/, (0, getAppAndVersion_1.getAppAndVersion)(this.transport)];
|
|
243
|
+
case 1:
|
|
244
|
+
a = _a.sent();
|
|
245
|
+
isNewApp = semver_1["default"].major(a.version) >= 2;
|
|
246
|
+
if ((a.name == "Bitcoin" || a.name == "Bitcoin Test") && isNewApp) {
|
|
247
|
+
return [2 /*return*/, true];
|
|
248
|
+
}
|
|
249
|
+
return [2 /*return*/, false];
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
});
|
|
184
253
|
};
|
|
185
254
|
return Btc;
|
|
186
255
|
}());
|
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,kDAA4B;AAC5B,oDAA8B;AAC9B,oDAA8B;AAE9B,uDAAsD;AACtD,qDAAoD;AACpD,iEAAgE;AAEhE,gDAA+C;AAC/C,+DAAqE;AAErE,uDAAsD;AAGtD;;;;;;GAMG;AAEH;IAGE,aAAY,SAAoB,EAAE,WAAmB;QAAnB,4BAAA,EAAA,mBAAmB;QACnD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,SAAS,CAAC,qBAAqB,CAC7B,IAAI,EACJ;YACE,oBAAoB;YACpB,qBAAqB;YACrB,gBAAgB;YAChB,6BAA6B;YAC7B,iBAAiB;YACjB,uBAAuB;SACxB,EACD,WAAW,CACZ,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,gCAAkB,GAAlB,UACE,IAAY,EACZ,IAGC;QAMD,IAAI,OAAO,CAAC;QACZ,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,IAAI,KAAK,SAAS,EAAE;YACrD,OAAO,CAAC,IAAI,CACV,iHAAiH,CAClH,CAAC;YACF,OAAO,GAAG;gBACR,MAAM,EAAE,CAAC,CAAC,IAAI;gBACd,8CAA8C;gBAC9C,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ;aACzC,CAAC;SACH;aAAM;YACL,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC;SACtB;QACD,OAAO,IAAI,CA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,KAAK,EAAC;;;;KACd;IACH,UAAC;AAAD,CAAC,AA1OD,IA0OC"}
|
package/lib/BtcNew.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { CreateTransactionArg } from "./createTransaction";
|
|
2
|
+
import type { AddressFormat } from "./getWalletPublicKey";
|
|
3
|
+
import { AppClient as Client } from "./newops/appClient";
|
|
4
|
+
export default class BtcNew {
|
|
5
|
+
private client;
|
|
6
|
+
constructor(client: Client);
|
|
7
|
+
getWalletPublicKey(path: string, opts?: {
|
|
8
|
+
verify?: boolean;
|
|
9
|
+
format?: AddressFormat;
|
|
10
|
+
}): Promise<{
|
|
11
|
+
publicKey: string;
|
|
12
|
+
bitcoinAddress: string;
|
|
13
|
+
chainCode: string;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Get an address for the specified path.
|
|
17
|
+
*
|
|
18
|
+
* If display is true, we must get the address from the device, which would require
|
|
19
|
+
* us to determine WalletPolicy. This requires two *extra* queries to the device, one
|
|
20
|
+
* for the account xpub and one for master key fingerprint.
|
|
21
|
+
*
|
|
22
|
+
* If display is false we *could* generate the address ourselves, but chose to
|
|
23
|
+
* get it from the device to save development time. However, it shouldn't take
|
|
24
|
+
* more than a few hours to implement local address generation.
|
|
25
|
+
*
|
|
26
|
+
* Moreover, if the path is not for a leaf, ie accountPath+/X/Y, there is no
|
|
27
|
+
* way to get the address from the device. In this case we have to create it
|
|
28
|
+
* ourselves, but we don't at this time, and instead return an empty ("") address.
|
|
29
|
+
*/
|
|
30
|
+
private getWalletAddress;
|
|
31
|
+
private accountPathLength;
|
|
32
|
+
/**
|
|
33
|
+
* To sign a transaction involving standard (P2PKH) inputs, call createTransaction with the following parameters
|
|
34
|
+
* @param inputs is an array of [ transaction, output_index, optional redeem script, optional sequence ] where
|
|
35
|
+
*
|
|
36
|
+
* * transaction is the previously computed transaction object for this UTXO
|
|
37
|
+
* * output_index is the output in the transaction used as input for this UTXO (counting from 0)
|
|
38
|
+
* * redeem script is the optional redeem script to use when consuming a Segregated Witness input
|
|
39
|
+
* * sequence is the sequence number to use for this input (when using RBF), or non present
|
|
40
|
+
* @param associatedKeysets is an array of BIP 32 paths pointing to the path to the private key used for each UTXO
|
|
41
|
+
* @param changePath is an optional BIP 32 path pointing to the path to the public key used to compute the change address
|
|
42
|
+
* @param outputScriptHex is the hexadecimal serialized outputs of the transaction to sign, including leading vararg voutCount
|
|
43
|
+
* @param lockTime is the optional lockTime of the transaction to sign, or default (0)
|
|
44
|
+
* @param sigHashType is the hash type of the transaction to sign, or default (all)
|
|
45
|
+
* @param segwit is an optional boolean indicating wether to use segwit or not. This includes wrapped segwit.
|
|
46
|
+
* @param initialTimestamp is an optional timestamp of the function call to use for coins that necessitate timestamps only, (not the one that the tx will include)
|
|
47
|
+
* @param additionals list of additionnal options
|
|
48
|
+
*
|
|
49
|
+
* - "bech32" for spending native segwit outputs
|
|
50
|
+
* - "bech32m" for spending segwit v1+ outptus
|
|
51
|
+
* - "abc" for bch
|
|
52
|
+
* - "gold" for btg
|
|
53
|
+
* - "bipxxx" for using BIPxxx
|
|
54
|
+
* - "sapling" to indicate a zec transaction is supporting sapling (to be set over block 419200)
|
|
55
|
+
* @param expiryHeight is an optional Buffer for zec overwinter / sapling Txs
|
|
56
|
+
* @param useTrustedInputForSegwit trust inputs for segwit transactions. If app version >= 1.4.0 this should be true.
|
|
57
|
+
* @return the signed transaction ready to be broadcast
|
|
58
|
+
* @example
|
|
59
|
+
btc.createTransaction({
|
|
60
|
+
inputs: [ [tx1, 1] ],
|
|
61
|
+
associatedKeysets: ["0'/0/0"],
|
|
62
|
+
outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
|
|
63
|
+
}).then(res => ...);
|
|
64
|
+
*/
|
|
65
|
+
createPaymentTransactionNew(arg: CreateTransactionArg): Promise<string>;
|
|
66
|
+
private setInput;
|
|
67
|
+
private signPsbt;
|
|
68
|
+
private createRedeemScript;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=BtcNew.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BtcNew.d.ts","sourceRoot":"","sources":["../src/BtcNew.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,SAAS,IAAI,MAAM,EAAE,MAAM,oBAAoB,CAAC;AASzD,MAAM,CAAC,OAAO,OAAO,MAAM;IACb,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAE5B,kBAAkB,CACtB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE;QACL,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,MAAM,CAAC,EAAE,aAAa,CAAC;KACxB,GACA,OAAO,CAAC;QACT,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,EAAE,MAAM,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IAsBF;;;;;;;;;;;;;;OAcG;YACW,gBAAgB;IA0B9B,OAAO,CAAC,iBAAiB;IASzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACG,2BAA2B,CAC/B,GAAG,EAAE,oBAAoB,GACxB,OAAO,CAAC,MAAM,CAAC;YA6EJ,QAAQ;YAyDR,QAAQ;IA8BtB,OAAO,CAAC,kBAAkB;CAI3B"}
|