@ledgerhq/hw-app-btc 6.24.2-monorepo.0 → 6.24.2-monorepo.4
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 +5 -1
- package/CHANGELOG.md +36 -0
- package/lib/Btc.d.ts +149 -0
- package/lib/Btc.d.ts.map +1 -0
- package/lib/Btc.js +357 -0
- package/lib/Btc.js.map +1 -0
- package/lib/BtcNew.d.ts +122 -0
- package/lib/BtcNew.d.ts.map +1 -0
- package/lib/BtcNew.js +451 -0
- package/lib/BtcNew.js.map +1 -0
- package/lib/BtcOld.d.ts +120 -0
- package/lib/BtcOld.d.ts.map +1 -0
- package/lib/BtcOld.js +263 -0
- package/lib/BtcOld.js.map +1 -0
- package/lib/bip32.d.ts +13 -0
- package/lib/bip32.d.ts.map +1 -0
- package/lib/bip32.js +57 -0
- package/lib/bip32.js.map +1 -0
- package/lib/buffertools.d.ts +30 -0
- package/lib/buffertools.d.ts.map +1 -0
- package/lib/buffertools.js +132 -0
- package/lib/buffertools.js.map +1 -0
- package/lib/compressPublicKey.d.ts +3 -0
- package/lib/compressPublicKey.d.ts.map +1 -0
- package/lib/compressPublicKey.js +11 -0
- package/lib/compressPublicKey.js.map +1 -0
- package/lib/constants.d.ts +13 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +17 -0
- package/lib/constants.js.map +1 -0
- package/lib/createTransaction.d.ts +35 -0
- package/lib/createTransaction.d.ts.map +1 -0
- package/lib/createTransaction.js +411 -0
- package/lib/createTransaction.js.map +1 -0
- package/lib/debug.d.ts +4 -0
- package/lib/debug.d.ts.map +1 -0
- package/lib/debug.js +45 -0
- package/lib/debug.js.map +1 -0
- package/lib/finalizeInput.d.ts +5 -0
- package/lib/finalizeInput.d.ts.map +1 -0
- package/lib/finalizeInput.js +81 -0
- package/lib/finalizeInput.js.map +1 -0
- package/lib/getAppAndVersion.d.ts +9 -0
- package/lib/getAppAndVersion.d.ts.map +1 -0
- package/lib/getAppAndVersion.js +69 -0
- package/lib/getAppAndVersion.js.map +1 -0
- package/lib/getTrustedInput.d.ts +6 -0
- package/lib/getTrustedInput.d.ts.map +1 -0
- package/lib/getTrustedInput.js +275 -0
- package/lib/getTrustedInput.js.map +1 -0
- package/lib/getTrustedInputBIP143.d.ts +4 -0
- package/lib/getTrustedInputBIP143.d.ts.map +1 -0
- package/lib/getTrustedInputBIP143.js +34 -0
- package/lib/getTrustedInputBIP143.js.map +1 -0
- package/lib/getWalletPublicKey.d.ts +15 -0
- package/lib/getWalletPublicKey.d.ts.map +1 -0
- package/lib/getWalletPublicKey.js +93 -0
- package/lib/getWalletPublicKey.js.map +1 -0
- package/lib/hashPublicKey.d.ts +3 -0
- package/lib/hashPublicKey.d.ts.map +1 -0
- package/lib/hashPublicKey.js +13 -0
- package/lib/hashPublicKey.js.map +1 -0
- 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/accounttype.d.ts +110 -0
- package/lib/newops/accounttype.d.ts.map +1 -0
- package/lib/newops/accounttype.js +236 -0
- package/lib/newops/accounttype.js.map +1 -0
- package/lib/newops/appClient.d.ts +18 -0
- package/lib/newops/appClient.d.ts.map +1 -0
- package/lib/newops/appClient.js +243 -0
- package/lib/newops/appClient.js.map +1 -0
- package/lib/newops/clientCommands.d.ts +77 -0
- package/lib/newops/clientCommands.d.ts.map +1 -0
- package/lib/newops/clientCommands.js +353 -0
- package/lib/newops/clientCommands.js.map +1 -0
- package/lib/newops/merkelizedPsbt.d.ts +26 -0
- package/lib/newops/merkelizedPsbt.d.ts.map +1 -0
- package/lib/newops/merkelizedPsbt.js +102 -0
- package/lib/newops/merkelizedPsbt.js.map +1 -0
- package/lib/newops/merkle.d.ts +34 -0
- package/lib/newops/merkle.d.ts.map +1 -0
- package/lib/newops/merkle.js +138 -0
- package/lib/newops/merkle.js.map +1 -0
- package/lib/newops/merkleMap.d.ts +25 -0
- package/lib/newops/merkleMap.d.ts.map +1 -0
- package/lib/newops/merkleMap.js +47 -0
- package/lib/newops/merkleMap.js.map +1 -0
- package/lib/newops/policy.d.ts +22 -0
- package/lib/newops/policy.d.ts.map +1 -0
- package/lib/newops/policy.js +48 -0
- package/lib/newops/policy.js.map +1 -0
- package/lib/newops/psbtExtractor.d.ts +10 -0
- package/lib/newops/psbtExtractor.d.ts.map +1 -0
- package/lib/newops/psbtExtractor.js +42 -0
- package/lib/newops/psbtExtractor.js.map +1 -0
- package/lib/newops/psbtFinalizer.d.ts +17 -0
- package/lib/newops/psbtFinalizer.d.ts.map +1 -0
- package/lib/newops/psbtFinalizer.js +135 -0
- package/lib/newops/psbtFinalizer.js.map +1 -0
- package/lib/newops/psbtv2.d.ts +149 -0
- package/lib/newops/psbtv2.d.ts.map +1 -0
- package/lib/newops/psbtv2.js +506 -0
- package/lib/newops/psbtv2.js.map +1 -0
- package/lib/serializeTransaction.d.ts +10 -0
- package/lib/serializeTransaction.d.ts.map +1 -0
- package/lib/serializeTransaction.js +72 -0
- package/lib/serializeTransaction.js.map +1 -0
- package/lib/shouldUseTrustedInputForSegwit.d.ts +5 -0
- package/lib/shouldUseTrustedInputForSegwit.d.ts.map +1 -0
- package/lib/shouldUseTrustedInputForSegwit.js +17 -0
- package/lib/shouldUseTrustedInputForSegwit.js.map +1 -0
- package/lib/signMessage.d.ts +10 -0
- package/lib/signMessage.d.ts.map +1 -0
- package/lib/signMessage.js +118 -0
- package/lib/signMessage.js.map +1 -0
- package/lib/signP2SHTransaction.d.ts +21 -0
- package/lib/signP2SHTransaction.d.ts.map +1 -0
- package/lib/signP2SHTransaction.js +208 -0
- package/lib/signP2SHTransaction.js.map +1 -0
- package/lib/signTransaction.d.ts +4 -0
- package/lib/signTransaction.d.ts.map +1 -0
- package/lib/signTransaction.js +36 -0
- package/lib/signTransaction.js.map +1 -0
- package/lib/splitTransaction.d.ts +3 -0
- package/lib/splitTransaction.d.ts.map +1 -0
- package/lib/splitTransaction.js +142 -0
- package/lib/splitTransaction.js.map +1 -0
- package/lib/startUntrustedHashTransactionInput.d.ts +9 -0
- package/lib/startUntrustedHashTransactionInput.d.ts.map +1 -0
- package/lib/startUntrustedHashTransactionInput.js +197 -0
- package/lib/startUntrustedHashTransactionInput.js.map +1 -0
- package/lib/types.d.ts +34 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/lib/varint.d.ts +4 -0
- package/lib/varint.d.ts.map +1 -0
- package/lib/varint.js +45 -0
- package/lib/varint.js.map +1 -0
- package/lib-es/Btc.d.ts +149 -0
- package/lib-es/Btc.d.ts.map +1 -0
- package/lib-es/Btc.js +329 -0
- package/lib-es/Btc.js.map +1 -0
- package/lib-es/BtcNew.d.ts +122 -0
- package/lib-es/BtcNew.d.ts.map +1 -0
- package/lib-es/BtcNew.js +444 -0
- package/lib-es/BtcNew.js.map +1 -0
- package/lib-es/BtcOld.d.ts +120 -0
- package/lib-es/BtcOld.d.ts.map +1 -0
- package/lib-es/BtcOld.js +258 -0
- package/lib-es/BtcOld.js.map +1 -0
- package/lib-es/bip32.d.ts +13 -0
- package/lib-es/bip32.d.ts.map +1 -0
- package/lib-es/bip32.js +44 -0
- package/lib-es/bip32.js.map +1 -0
- package/lib-es/buffertools.d.ts +30 -0
- package/lib-es/buffertools.d.ts.map +1 -0
- package/lib-es/buffertools.js +124 -0
- package/lib-es/buffertools.js.map +1 -0
- package/lib-es/compressPublicKey.d.ts +3 -0
- package/lib-es/compressPublicKey.d.ts.map +1 -0
- package/lib-es/compressPublicKey.js +7 -0
- package/lib-es/compressPublicKey.js.map +1 -0
- package/lib-es/constants.d.ts +13 -0
- package/lib-es/constants.d.ts.map +1 -0
- package/lib-es/constants.js +14 -0
- package/lib-es/constants.js.map +1 -0
- package/lib-es/createTransaction.d.ts +35 -0
- package/lib-es/createTransaction.d.ts.map +1 -0
- package/lib-es/createTransaction.js +407 -0
- package/lib-es/createTransaction.js.map +1 -0
- package/lib-es/debug.d.ts +4 -0
- package/lib-es/debug.d.ts.map +1 -0
- package/lib-es/debug.js +40 -0
- package/lib-es/debug.js.map +1 -0
- package/lib-es/finalizeInput.d.ts +5 -0
- package/lib-es/finalizeInput.d.ts.map +1 -0
- package/lib-es/finalizeInput.js +76 -0
- package/lib-es/finalizeInput.js.map +1 -0
- package/lib-es/getAppAndVersion.d.ts +9 -0
- package/lib-es/getAppAndVersion.d.ts.map +1 -0
- package/lib-es/getAppAndVersion.js +62 -0
- package/lib-es/getAppAndVersion.js.map +1 -0
- package/lib-es/getTrustedInput.d.ts +6 -0
- package/lib-es/getTrustedInput.d.ts.map +1 -0
- package/lib-es/getTrustedInput.js +267 -0
- package/lib-es/getTrustedInput.js.map +1 -0
- package/lib-es/getTrustedInputBIP143.d.ts +4 -0
- package/lib-es/getTrustedInputBIP143.d.ts.map +1 -0
- package/lib-es/getTrustedInputBIP143.js +27 -0
- package/lib-es/getTrustedInputBIP143.js.map +1 -0
- package/lib-es/getWalletPublicKey.d.ts +15 -0
- package/lib-es/getWalletPublicKey.d.ts.map +1 -0
- package/lib-es/getWalletPublicKey.js +89 -0
- package/lib-es/getWalletPublicKey.js.map +1 -0
- package/lib-es/hashPublicKey.d.ts +3 -0
- package/lib-es/hashPublicKey.d.ts.map +1 -0
- package/lib-es/hashPublicKey.js +6 -0
- package/lib-es/hashPublicKey.js.map +1 -0
- 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/accounttype.d.ts +110 -0
- package/lib-es/newops/accounttype.d.ts.map +1 -0
- package/lib-es/newops/accounttype.js +233 -0
- package/lib-es/newops/accounttype.js.map +1 -0
- package/lib-es/newops/appClient.d.ts +18 -0
- package/lib-es/newops/appClient.d.ts.map +1 -0
- package/lib-es/newops/appClient.js +240 -0
- package/lib-es/newops/appClient.js.map +1 -0
- package/lib-es/newops/clientCommands.d.ts +77 -0
- package/lib-es/newops/clientCommands.d.ts.map +1 -0
- package/lib-es/newops/clientCommands.js +350 -0
- package/lib-es/newops/clientCommands.js.map +1 -0
- package/lib-es/newops/merkelizedPsbt.d.ts +26 -0
- package/lib-es/newops/merkelizedPsbt.d.ts.map +1 -0
- package/lib-es/newops/merkelizedPsbt.js +99 -0
- package/lib-es/newops/merkelizedPsbt.js.map +1 -0
- package/lib-es/newops/merkle.d.ts +34 -0
- package/lib-es/newops/merkle.d.ts.map +1 -0
- package/lib-es/newops/merkle.js +134 -0
- package/lib-es/newops/merkle.js.map +1 -0
- package/lib-es/newops/merkleMap.d.ts +25 -0
- package/lib-es/newops/merkleMap.d.ts.map +1 -0
- package/lib-es/newops/merkleMap.js +44 -0
- package/lib-es/newops/merkleMap.js.map +1 -0
- package/lib-es/newops/policy.d.ts +22 -0
- package/lib-es/newops/policy.d.ts.map +1 -0
- package/lib-es/newops/policy.js +44 -0
- package/lib-es/newops/policy.js.map +1 -0
- package/lib-es/newops/psbtExtractor.d.ts +10 -0
- package/lib-es/newops/psbtExtractor.d.ts.map +1 -0
- package/lib-es/newops/psbtExtractor.js +38 -0
- package/lib-es/newops/psbtExtractor.js.map +1 -0
- package/lib-es/newops/psbtFinalizer.d.ts +17 -0
- package/lib-es/newops/psbtFinalizer.d.ts.map +1 -0
- package/lib-es/newops/psbtFinalizer.js +131 -0
- package/lib-es/newops/psbtFinalizer.js.map +1 -0
- package/lib-es/newops/psbtv2.d.ts +149 -0
- package/lib-es/newops/psbtv2.d.ts.map +1 -0
- package/lib-es/newops/psbtv2.js +503 -0
- package/lib-es/newops/psbtv2.js.map +1 -0
- package/lib-es/serializeTransaction.d.ts +10 -0
- package/lib-es/serializeTransaction.d.ts.map +1 -0
- package/lib-es/serializeTransaction.js +67 -0
- package/lib-es/serializeTransaction.js.map +1 -0
- package/lib-es/shouldUseTrustedInputForSegwit.d.ts +5 -0
- package/lib-es/shouldUseTrustedInputForSegwit.d.ts.map +1 -0
- package/lib-es/shouldUseTrustedInputForSegwit.js +10 -0
- package/lib-es/shouldUseTrustedInputForSegwit.js.map +1 -0
- package/lib-es/signMessage.d.ts +10 -0
- package/lib-es/signMessage.d.ts.map +1 -0
- package/lib-es/signMessage.js +111 -0
- package/lib-es/signMessage.js.map +1 -0
- package/lib-es/signP2SHTransaction.d.ts +21 -0
- package/lib-es/signP2SHTransaction.d.ts.map +1 -0
- package/lib-es/signP2SHTransaction.js +204 -0
- package/lib-es/signP2SHTransaction.js.map +1 -0
- package/lib-es/signTransaction.d.ts +4 -0
- package/lib-es/signTransaction.d.ts.map +1 -0
- package/lib-es/signTransaction.js +32 -0
- package/lib-es/signTransaction.js.map +1 -0
- package/lib-es/splitTransaction.d.ts +3 -0
- package/lib-es/splitTransaction.d.ts.map +1 -0
- package/lib-es/splitTransaction.js +138 -0
- package/lib-es/splitTransaction.js.map +1 -0
- package/lib-es/startUntrustedHashTransactionInput.d.ts +9 -0
- package/lib-es/startUntrustedHashTransactionInput.d.ts.map +1 -0
- package/lib-es/startUntrustedHashTransactionInput.js +192 -0
- package/lib-es/startUntrustedHashTransactionInput.js.map +1 -0
- package/lib-es/types.d.ts +34 -0
- package/lib-es/types.d.ts.map +1 -0
- package/lib-es/types.js +2 -0
- package/lib-es/types.js.map +1 -0
- package/lib-es/varint.d.ts +4 -0
- package/lib-es/varint.d.ts.map +1 -0
- package/lib-es/varint.js +40 -0
- package/lib-es/varint.js.map +1 -0
- package/package.json +5 -5
package/lib-es/BtcOld.js
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (_) try {
|
|
28
|
+
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;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import bs58 from "bs58";
|
|
49
|
+
import RIPEMD160 from "ripemd160";
|
|
50
|
+
import sha from "sha.js";
|
|
51
|
+
import { createTransaction } from "./createTransaction";
|
|
52
|
+
import { getWalletPublicKey } from "./getWalletPublicKey";
|
|
53
|
+
import { signMessage } from "./signMessage";
|
|
54
|
+
import { signP2SHTransaction } from "./signP2SHTransaction";
|
|
55
|
+
import { pathArrayToString, pathStringToArray } from "./bip32";
|
|
56
|
+
/**
|
|
57
|
+
* Bitcoin API.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* import Btc from "@ledgerhq/hw-app-btc";
|
|
61
|
+
* const btc = new Btc(transport)
|
|
62
|
+
*/
|
|
63
|
+
var BtcOld = /** @class */ (function () {
|
|
64
|
+
function BtcOld(transport) {
|
|
65
|
+
this.transport = transport;
|
|
66
|
+
this.derivationsCache = {};
|
|
67
|
+
}
|
|
68
|
+
BtcOld.prototype.derivatePath = function (path) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
+
var res;
|
|
71
|
+
return __generator(this, function (_a) {
|
|
72
|
+
switch (_a.label) {
|
|
73
|
+
case 0:
|
|
74
|
+
if (this.derivationsCache[path])
|
|
75
|
+
return [2 /*return*/, this.derivationsCache[path]];
|
|
76
|
+
return [4 /*yield*/, getWalletPublicKey(this.transport, {
|
|
77
|
+
path: path
|
|
78
|
+
})];
|
|
79
|
+
case 1:
|
|
80
|
+
res = _a.sent();
|
|
81
|
+
this.derivationsCache[path] = res;
|
|
82
|
+
return [2 /*return*/, res];
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
BtcOld.prototype.getWalletXpub = function (_a) {
|
|
88
|
+
var path = _a.path, xpubVersion = _a.xpubVersion;
|
|
89
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
+
var pathElements, parentPath, parentDerivation, accountDerivation, fingerprint, xpub;
|
|
91
|
+
return __generator(this, function (_b) {
|
|
92
|
+
switch (_b.label) {
|
|
93
|
+
case 0:
|
|
94
|
+
pathElements = pathStringToArray(path);
|
|
95
|
+
parentPath = pathElements.slice(0, -1);
|
|
96
|
+
return [4 /*yield*/, this.derivatePath(pathArrayToString(parentPath))];
|
|
97
|
+
case 1:
|
|
98
|
+
parentDerivation = _b.sent();
|
|
99
|
+
return [4 /*yield*/, this.derivatePath(path)];
|
|
100
|
+
case 2:
|
|
101
|
+
accountDerivation = _b.sent();
|
|
102
|
+
fingerprint = makeFingerprint(compressPublicKeySECP256(Buffer.from(parentDerivation.publicKey, "hex")));
|
|
103
|
+
xpub = makeXpub(xpubVersion, pathElements.length, fingerprint, pathElements[pathElements.length - 1], Buffer.from(accountDerivation.chainCode, "hex"), compressPublicKeySECP256(Buffer.from(accountDerivation.publicKey, "hex")));
|
|
104
|
+
return [2 /*return*/, xpub];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* @param path a BIP 32 path
|
|
111
|
+
* @param options an object with optional these fields:
|
|
112
|
+
*
|
|
113
|
+
* - verify (boolean) will ask user to confirm the address on the device
|
|
114
|
+
*
|
|
115
|
+
* - format ("legacy" | "p2sh" | "bech32" | "cashaddr") to use different bitcoin address formatter.
|
|
116
|
+
*
|
|
117
|
+
* NB The normal usage is to use:
|
|
118
|
+
*
|
|
119
|
+
* - legacy format with 44' paths
|
|
120
|
+
*
|
|
121
|
+
* - p2sh format with 49' paths
|
|
122
|
+
*
|
|
123
|
+
* - bech32 format with 173' paths
|
|
124
|
+
*
|
|
125
|
+
* - cashaddr in case of Bitcoin Cash
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* btc.getWalletPublicKey("44'/0'/0'/0/0").then(o => o.bitcoinAddress)
|
|
129
|
+
* btc.getWalletPublicKey("49'/0'/0'/0/0", { format: "p2sh" }).then(o => o.bitcoinAddress)
|
|
130
|
+
*/
|
|
131
|
+
BtcOld.prototype.getWalletPublicKey = function (path, opts) {
|
|
132
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.format) === "bech32m") {
|
|
133
|
+
throw new Error("Unsupported address format bech32m");
|
|
134
|
+
}
|
|
135
|
+
return getWalletPublicKey(this.transport, __assign(__assign({}, opts), { path: path }));
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* 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.
|
|
139
|
+
* @example
|
|
140
|
+
btc.signMessageNew_async("44'/60'/0'/0'/0", Buffer.from("test").toString("hex")).then(function(result) {
|
|
141
|
+
var v = result['v'] + 27 + 4;
|
|
142
|
+
var signature = Buffer.from(v.toString(16) + result['r'] + result['s'], 'hex').toString('base64');
|
|
143
|
+
console.log("Signature : " + signature);
|
|
144
|
+
}).catch(function(ex) {console.log(ex);});
|
|
145
|
+
*/
|
|
146
|
+
BtcOld.prototype.signMessageNew = function (path, messageHex) {
|
|
147
|
+
return signMessage(this.transport, {
|
|
148
|
+
path: path,
|
|
149
|
+
messageHex: messageHex
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* To sign a transaction involving standard (P2PKH) inputs, call createTransaction with the following parameters
|
|
154
|
+
* @param inputs is an array of [ transaction, output_index, optional redeem script, optional sequence ] where
|
|
155
|
+
*
|
|
156
|
+
* * transaction is the previously computed transaction object for this UTXO
|
|
157
|
+
* * output_index is the output in the transaction used as input for this UTXO (counting from 0)
|
|
158
|
+
* * redeem script is the optional redeem script to use when consuming a Segregated Witness input
|
|
159
|
+
* * sequence is the sequence number to use for this input (when using RBF), or non present
|
|
160
|
+
* @param associatedKeysets is an array of BIP 32 paths pointing to the path to the private key used for each UTXO
|
|
161
|
+
* @param changePath is an optional BIP 32 path pointing to the path to the public key used to compute the change address
|
|
162
|
+
* @param outputScriptHex is the hexadecimal serialized outputs of the transaction to sign
|
|
163
|
+
* @param lockTime is the optional lockTime of the transaction to sign, or default (0)
|
|
164
|
+
* @param sigHashType is the hash type of the transaction to sign, or default (all)
|
|
165
|
+
* @param segwit is an optional boolean indicating wether to use segwit or not
|
|
166
|
+
* @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)
|
|
167
|
+
* @param additionals list of additionnal options
|
|
168
|
+
*
|
|
169
|
+
* - "bech32" for spending native segwit outputs
|
|
170
|
+
* - "abc" for bch
|
|
171
|
+
* - "gold" for btg
|
|
172
|
+
* - "bipxxx" for using BIPxxx
|
|
173
|
+
* - "sapling" to indicate a zec transaction is supporting sapling (to be set over block 419200)
|
|
174
|
+
* @param expiryHeight is an optional Buffer for zec overwinter / sapling Txs
|
|
175
|
+
* @param useTrustedInputForSegwit trust inputs for segwit transactions
|
|
176
|
+
* @return the signed transaction ready to be broadcast
|
|
177
|
+
* @example
|
|
178
|
+
btc.createTransaction({
|
|
179
|
+
inputs: [ [tx1, 1] ],
|
|
180
|
+
associatedKeysets: ["0'/0/0"],
|
|
181
|
+
outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
|
|
182
|
+
}).then(res => ...);
|
|
183
|
+
*/
|
|
184
|
+
BtcOld.prototype.createPaymentTransactionNew = function (arg) {
|
|
185
|
+
if (arguments.length > 1) {
|
|
186
|
+
console.warn("@ledgerhq/hw-app-btc: createPaymentTransactionNew multi argument signature is deprecated. please switch to named parameters.");
|
|
187
|
+
}
|
|
188
|
+
return createTransaction(this.transport, arg);
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* To obtain the signature of multisignature (P2SH) inputs, call signP2SHTransaction_async with the folowing parameters
|
|
192
|
+
* @param inputs is an array of [ transaction, output_index, redeem script, optional sequence ] where
|
|
193
|
+
* * transaction is the previously computed transaction object for this UTXO
|
|
194
|
+
* * output_index is the output in the transaction used as input for this UTXO (counting from 0)
|
|
195
|
+
* * redeem script is the mandatory redeem script associated to the current P2SH input
|
|
196
|
+
* * sequence is the sequence number to use for this input (when using RBF), or non present
|
|
197
|
+
* @param associatedKeysets is an array of BIP 32 paths pointing to the path to the private key used for each UTXO
|
|
198
|
+
* @param outputScriptHex is the hexadecimal serialized outputs of the transaction to sign
|
|
199
|
+
* @param lockTime is the optional lockTime of the transaction to sign, or default (0)
|
|
200
|
+
* @param sigHashType is the hash type of the transaction to sign, or default (all)
|
|
201
|
+
* @return the signed transaction ready to be broadcast
|
|
202
|
+
* @example
|
|
203
|
+
btc.signP2SHTransaction({
|
|
204
|
+
inputs: [ [tx, 1, "52210289b4a3ad52a919abd2bdd6920d8a6879b1e788c38aa76f0440a6f32a9f1996d02103a3393b1439d1693b063482c04bd40142db97bdf139eedd1b51ffb7070a37eac321030b9a409a1e476b0d5d17b804fcdb81cf30f9b99c6f3ae1178206e08bc500639853ae"] ],
|
|
205
|
+
associatedKeysets: ["0'/0/0"],
|
|
206
|
+
outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
|
|
207
|
+
}).then(result => ...);
|
|
208
|
+
*/
|
|
209
|
+
BtcOld.prototype.signP2SHTransaction = function (arg) {
|
|
210
|
+
if (arguments.length > 1) {
|
|
211
|
+
console.warn("@ledgerhq/hw-app-btc: signP2SHTransaction multi argument signature is deprecated. please switch to named parameters.");
|
|
212
|
+
}
|
|
213
|
+
return signP2SHTransaction(this.transport, arg);
|
|
214
|
+
};
|
|
215
|
+
return BtcOld;
|
|
216
|
+
}());
|
|
217
|
+
export default BtcOld;
|
|
218
|
+
function makeFingerprint(compressedPubKey) {
|
|
219
|
+
return hash160(compressedPubKey).slice(0, 4);
|
|
220
|
+
}
|
|
221
|
+
function asBufferUInt32BE(n) {
|
|
222
|
+
var buf = Buffer.allocUnsafe(4);
|
|
223
|
+
buf.writeUInt32BE(n, 0);
|
|
224
|
+
return buf;
|
|
225
|
+
}
|
|
226
|
+
var compressPublicKeySECP256 = function (publicKey) {
|
|
227
|
+
return Buffer.concat([
|
|
228
|
+
Buffer.from([0x02 + (publicKey[64] & 0x01)]),
|
|
229
|
+
publicKey.slice(1, 33),
|
|
230
|
+
]);
|
|
231
|
+
};
|
|
232
|
+
function makeXpub(version, depth, parentFingerprint, index, chainCode, pubKey) {
|
|
233
|
+
var indexBuffer = asBufferUInt32BE(index);
|
|
234
|
+
indexBuffer[0] |= 0x80;
|
|
235
|
+
var extendedKeyBytes = Buffer.concat([
|
|
236
|
+
asBufferUInt32BE(version),
|
|
237
|
+
Buffer.from([depth]),
|
|
238
|
+
parentFingerprint,
|
|
239
|
+
indexBuffer,
|
|
240
|
+
chainCode,
|
|
241
|
+
pubKey,
|
|
242
|
+
]);
|
|
243
|
+
var checksum = hash256(extendedKeyBytes).slice(0, 4);
|
|
244
|
+
return bs58.encode(Buffer.concat([extendedKeyBytes, checksum]));
|
|
245
|
+
}
|
|
246
|
+
function sha256(buffer) {
|
|
247
|
+
return sha("sha256").update(buffer).digest();
|
|
248
|
+
}
|
|
249
|
+
function hash256(buffer) {
|
|
250
|
+
return sha256(sha256(buffer));
|
|
251
|
+
}
|
|
252
|
+
function ripemd160(buffer) {
|
|
253
|
+
return new RIPEMD160().update(buffer).digest();
|
|
254
|
+
}
|
|
255
|
+
function hash160(buffer) {
|
|
256
|
+
return ripemd160(sha256(buffer));
|
|
257
|
+
}
|
|
258
|
+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AAC,CAAC;IAC5C,WAAW,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;IACvB,IAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;QACrC,gBAAgB,CAAC,OAAO,CAAC;QACzB,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC;QACpB,iBAAiB;QACjB,WAAW;QACX,SAAS;QACT,MAAM;KACP,CAAC,CAAC;IACH,IAAM,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACvD,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,SAAS,MAAM,CAAC,MAAuB;IACrC,OAAO,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;AAC/C,CAAC;AACD,SAAS,OAAO,CAAC,MAAuB;IACtC,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;AAChC,CAAC;AACD,SAAS,SAAS,CAAC,MAAuB;IACxC,OAAO,IAAI,SAAS,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;AACjD,CAAC;AACD,SAAS,OAAO,CAAC,MAAuB;IACtC,OAAO,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare function pathElementsToBuffer(paths: number[]): Buffer;
|
|
3
|
+
export declare function bip32asBuffer(path: string): Buffer;
|
|
4
|
+
export declare function pathArrayToString(pathElements: number[]): string;
|
|
5
|
+
export declare function pathStringToArray(path: string): number[];
|
|
6
|
+
export declare function pubkeyFromXpub(xpub: string): Buffer;
|
|
7
|
+
export declare function getXpubComponents(xpub: string): {
|
|
8
|
+
chaincode: Buffer;
|
|
9
|
+
pubkey: Buffer;
|
|
10
|
+
version: number;
|
|
11
|
+
};
|
|
12
|
+
export declare function hardenedPathOf(pathElements: number[]): number[];
|
|
13
|
+
//# sourceMappingURL=bip32.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bip32.d.ts","sourceRoot":"","sources":["../src/bip32.ts"],"names":[],"mappings":";AAGA,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAO5D;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGlD;AAED,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,MAAM,CAKhE;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAExD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGnD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,CAOA;AAED,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAO/D"}
|
package/lib-es/bip32.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import bippath from "bip32-path";
|
|
2
|
+
import bs58check from "bs58check";
|
|
3
|
+
export function pathElementsToBuffer(paths) {
|
|
4
|
+
var buffer = Buffer.alloc(1 + paths.length * 4);
|
|
5
|
+
buffer[0] = paths.length;
|
|
6
|
+
paths.forEach(function (element, index) {
|
|
7
|
+
buffer.writeUInt32BE(element, 1 + 4 * index);
|
|
8
|
+
});
|
|
9
|
+
return buffer;
|
|
10
|
+
}
|
|
11
|
+
export function bip32asBuffer(path) {
|
|
12
|
+
var pathElements = !path ? [] : pathStringToArray(path);
|
|
13
|
+
return pathElementsToBuffer(pathElements);
|
|
14
|
+
}
|
|
15
|
+
export function pathArrayToString(pathElements) {
|
|
16
|
+
// Limitation: bippath can't handle and empty path. It shouldn't affect us
|
|
17
|
+
// right now, but might in the future.
|
|
18
|
+
// TODO: Fix support for empty path.
|
|
19
|
+
return bippath.fromPathArray(pathElements).toString();
|
|
20
|
+
}
|
|
21
|
+
export function pathStringToArray(path) {
|
|
22
|
+
return bippath.fromString(path).toPathArray();
|
|
23
|
+
}
|
|
24
|
+
export function pubkeyFromXpub(xpub) {
|
|
25
|
+
var xpubBuf = bs58check.decode(xpub);
|
|
26
|
+
return xpubBuf.slice(xpubBuf.length - 33);
|
|
27
|
+
}
|
|
28
|
+
export function getXpubComponents(xpub) {
|
|
29
|
+
var xpubBuf = bs58check.decode(xpub);
|
|
30
|
+
return {
|
|
31
|
+
chaincode: xpubBuf.slice(13, 13 + 32),
|
|
32
|
+
pubkey: xpubBuf.slice(xpubBuf.length - 33),
|
|
33
|
+
version: xpubBuf.readUInt32BE(0)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function hardenedPathOf(pathElements) {
|
|
37
|
+
for (var i = pathElements.length - 1; i >= 0; i--) {
|
|
38
|
+
if (pathElements[i] >= 0x80000000) {
|
|
39
|
+
return pathElements.slice(0, i + 1);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=bip32.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bip32.js","sourceRoot":"","sources":["../src/bip32.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,MAAM,UAAU,oBAAoB,CAAC,KAAe;IAClD,IAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC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C;QAC1C,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;KACjC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,YAAsB;IACnD,KAAK,IAAI,CAAC,GAAG,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QACjD,IAAI,YAAY,CAAC,CAAC,CAAC,IAAI,UAAU,EAAE;YACjC,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;SACrC;KACF;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare function unsafeTo64bitLE(n: number): Buffer;
|
|
3
|
+
export declare function unsafeFrom64bitLE(byteArray: Buffer): number;
|
|
4
|
+
export declare class BufferWriter {
|
|
5
|
+
private bufs;
|
|
6
|
+
write(alloc: number, fn: (b: Buffer) => void): void;
|
|
7
|
+
writeUInt8(i: number): void;
|
|
8
|
+
writeInt32(i: number): void;
|
|
9
|
+
writeUInt32(i: number): void;
|
|
10
|
+
writeUInt64(i: number): void;
|
|
11
|
+
writeVarInt(i: number): void;
|
|
12
|
+
writeSlice(slice: Buffer): void;
|
|
13
|
+
writeVarSlice(slice: Buffer): void;
|
|
14
|
+
buffer(): Buffer;
|
|
15
|
+
}
|
|
16
|
+
export declare class BufferReader {
|
|
17
|
+
buffer: Buffer;
|
|
18
|
+
offset: number;
|
|
19
|
+
constructor(buffer: Buffer, offset?: number);
|
|
20
|
+
available(): number;
|
|
21
|
+
readUInt8(): number;
|
|
22
|
+
readInt32(): number;
|
|
23
|
+
readUInt32(): number;
|
|
24
|
+
readUInt64(): number;
|
|
25
|
+
readVarInt(): number;
|
|
26
|
+
readSlice(n: number): Buffer;
|
|
27
|
+
readVarSlice(): Buffer;
|
|
28
|
+
readVector(): Buffer[];
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=buffertools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffertools.d.ts","sourceRoot":"","sources":["../src/buffertools.ts"],"names":[],"mappings":";AAEA,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAYjD;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAe3D;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,IAAI,CAAgB;IAE5B,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI;IAMnD,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAI3B,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAI3B,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAI5B,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAK5B,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAI5B,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI/B,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKlC,MAAM,IAAI,MAAM;CAGjB;AAED,qBAAa,YAAY;IACJ,MAAM,EAAE,MAAM;IAAS,MAAM,EAAE,MAAM;gBAArC,MAAM,EAAE,MAAM,EAAS,MAAM,GAAE,MAAU;IAE5D,SAAS,IAAI,MAAM;IAInB,SAAS,IAAI,MAAM;IAMnB,SAAS,IAAI,MAAM;IAMnB,UAAU,IAAI,MAAM;IAMpB,UAAU,IAAI,MAAM;IAMpB,UAAU,IAAI,MAAM;IAMpB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAS5B,YAAY,IAAI,MAAM;IAItB,UAAU,IAAI,MAAM,EAAE;CAMvB"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import varuint from "varuint-bitcoin";
|
|
2
|
+
export function unsafeTo64bitLE(n) {
|
|
3
|
+
// we want to represent the input as a 8-bytes array
|
|
4
|
+
if (n > Number.MAX_SAFE_INTEGER) {
|
|
5
|
+
throw new Error("Can't convert numbers > MAX_SAFE_INT");
|
|
6
|
+
}
|
|
7
|
+
var byteArray = Buffer.alloc(8, 0);
|
|
8
|
+
for (var index = 0; index < byteArray.length; index++) {
|
|
9
|
+
var byte = n & 0xff;
|
|
10
|
+
byteArray[index] = byte;
|
|
11
|
+
n = (n - byte) / 256;
|
|
12
|
+
}
|
|
13
|
+
return byteArray;
|
|
14
|
+
}
|
|
15
|
+
export function unsafeFrom64bitLE(byteArray) {
|
|
16
|
+
var value = 0;
|
|
17
|
+
if (byteArray.length != 8) {
|
|
18
|
+
throw new Error("Expected Bufffer of lenght 8");
|
|
19
|
+
}
|
|
20
|
+
if (byteArray[7] != 0) {
|
|
21
|
+
throw new Error("Can't encode numbers > MAX_SAFE_INT");
|
|
22
|
+
}
|
|
23
|
+
if (byteArray[6] > 0x1f) {
|
|
24
|
+
throw new Error("Can't encode numbers > MAX_SAFE_INT");
|
|
25
|
+
}
|
|
26
|
+
for (var i = byteArray.length - 1; i >= 0; i--) {
|
|
27
|
+
value = value * 256 + byteArray[i];
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
var BufferWriter = /** @class */ (function () {
|
|
32
|
+
function BufferWriter() {
|
|
33
|
+
this.bufs = [];
|
|
34
|
+
}
|
|
35
|
+
BufferWriter.prototype.write = function (alloc, fn) {
|
|
36
|
+
var b = Buffer.alloc(alloc);
|
|
37
|
+
fn(b);
|
|
38
|
+
this.bufs.push(b);
|
|
39
|
+
};
|
|
40
|
+
BufferWriter.prototype.writeUInt8 = function (i) {
|
|
41
|
+
this.write(1, function (b) { return b.writeUInt8(i, 0); });
|
|
42
|
+
};
|
|
43
|
+
BufferWriter.prototype.writeInt32 = function (i) {
|
|
44
|
+
this.write(4, function (b) { return b.writeInt32LE(i, 0); });
|
|
45
|
+
};
|
|
46
|
+
BufferWriter.prototype.writeUInt32 = function (i) {
|
|
47
|
+
this.write(4, function (b) { return b.writeUInt32LE(i, 0); });
|
|
48
|
+
};
|
|
49
|
+
BufferWriter.prototype.writeUInt64 = function (i) {
|
|
50
|
+
var bytes = unsafeTo64bitLE(i);
|
|
51
|
+
this.writeSlice(bytes);
|
|
52
|
+
};
|
|
53
|
+
BufferWriter.prototype.writeVarInt = function (i) {
|
|
54
|
+
this.bufs.push(varuint.encode(i));
|
|
55
|
+
};
|
|
56
|
+
BufferWriter.prototype.writeSlice = function (slice) {
|
|
57
|
+
this.bufs.push(Buffer.from(slice));
|
|
58
|
+
};
|
|
59
|
+
BufferWriter.prototype.writeVarSlice = function (slice) {
|
|
60
|
+
this.writeVarInt(slice.length);
|
|
61
|
+
this.writeSlice(slice);
|
|
62
|
+
};
|
|
63
|
+
BufferWriter.prototype.buffer = function () {
|
|
64
|
+
return Buffer.concat(this.bufs);
|
|
65
|
+
};
|
|
66
|
+
return BufferWriter;
|
|
67
|
+
}());
|
|
68
|
+
export { BufferWriter };
|
|
69
|
+
var BufferReader = /** @class */ (function () {
|
|
70
|
+
function BufferReader(buffer, offset) {
|
|
71
|
+
if (offset === void 0) { offset = 0; }
|
|
72
|
+
this.buffer = buffer;
|
|
73
|
+
this.offset = offset;
|
|
74
|
+
}
|
|
75
|
+
BufferReader.prototype.available = function () {
|
|
76
|
+
return this.buffer.length - this.offset;
|
|
77
|
+
};
|
|
78
|
+
BufferReader.prototype.readUInt8 = function () {
|
|
79
|
+
var result = this.buffer.readUInt8(this.offset);
|
|
80
|
+
this.offset++;
|
|
81
|
+
return result;
|
|
82
|
+
};
|
|
83
|
+
BufferReader.prototype.readInt32 = function () {
|
|
84
|
+
var result = this.buffer.readInt32LE(this.offset);
|
|
85
|
+
this.offset += 4;
|
|
86
|
+
return result;
|
|
87
|
+
};
|
|
88
|
+
BufferReader.prototype.readUInt32 = function () {
|
|
89
|
+
var result = this.buffer.readUInt32LE(this.offset);
|
|
90
|
+
this.offset += 4;
|
|
91
|
+
return result;
|
|
92
|
+
};
|
|
93
|
+
BufferReader.prototype.readUInt64 = function () {
|
|
94
|
+
var buf = this.readSlice(8);
|
|
95
|
+
var n = unsafeFrom64bitLE(buf);
|
|
96
|
+
return n;
|
|
97
|
+
};
|
|
98
|
+
BufferReader.prototype.readVarInt = function () {
|
|
99
|
+
var vi = varuint.decode(this.buffer, this.offset);
|
|
100
|
+
this.offset += varuint.decode.bytes;
|
|
101
|
+
return vi;
|
|
102
|
+
};
|
|
103
|
+
BufferReader.prototype.readSlice = function (n) {
|
|
104
|
+
if (this.buffer.length < this.offset + n) {
|
|
105
|
+
throw new Error("Cannot read slice out of bounds");
|
|
106
|
+
}
|
|
107
|
+
var result = this.buffer.slice(this.offset, this.offset + n);
|
|
108
|
+
this.offset += n;
|
|
109
|
+
return result;
|
|
110
|
+
};
|
|
111
|
+
BufferReader.prototype.readVarSlice = function () {
|
|
112
|
+
return this.readSlice(this.readVarInt());
|
|
113
|
+
};
|
|
114
|
+
BufferReader.prototype.readVector = function () {
|
|
115
|
+
var count = this.readVarInt();
|
|
116
|
+
var vector = [];
|
|
117
|
+
for (var i = 0; i < count; i++)
|
|
118
|
+
vector.push(this.readVarSlice());
|
|
119
|
+
return vector;
|
|
120
|
+
};
|
|
121
|
+
return BufferReader;
|
|
122
|
+
}());
|
|
123
|
+
export { BufferReader };
|
|
124
|
+
//# sourceMappingURL=buffertools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffertools.js","sourceRoot":"","sources":["../src/buffertools.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,iBAAiB,CAAC;AAEtC,MAAM,UAAU,eAAe,CAAC,CAAS;IACvC,oDAAoD;IACpD,IAAI,CAAC,GAAG,MAAM,CAAC,gBAAgB,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;KACzD;IACD,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AC;IAED,gCAAS,GAAT,UAAU,CAAS;QACjB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YACxC,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;SACpD;QACD,IAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC/D,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;QACjB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,mCAAY,GAAZ;QACE,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,iCAAU,GAAV;QACE,IAAM,KAAK,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAChC,IAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE;YAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;QACjE,OAAO,MAAM,CAAC;IAChB,CAAC;IACH,mBAAC;AAAD,CAAC,AAxDD,IAwDC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compressPublicKey.d.ts","sourceRoot":"","sources":["../src/compressPublicKey.ts"],"names":[],"mappings":";AAAA,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAK3D"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function compressPublicKey(publicKey) {
|
|
2
|
+
var prefix = (publicKey[64] & 1) !== 0 ? 0x03 : 0x02;
|
|
3
|
+
var prefixBuffer = Buffer.alloc(1);
|
|
4
|
+
prefixBuffer[0] = prefix;
|
|
5
|
+
return Buffer.concat([prefixBuffer, publicKey.slice(1, 1 + 32)]);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=compressPublicKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compressPublicKey.js","sourceRoot":"","sources":["../src/compressPublicKey.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,iBAAiB,CAAC,SAAiB;IACjD,IAAM,MAAM,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACvD,IAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACrC,YAAY,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IACzB,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const MAX_SCRIPT_BLOCK = 50;
|
|
2
|
+
export declare const DEFAULT_VERSION = 1;
|
|
3
|
+
export declare const DEFAULT_LOCKTIME = 0;
|
|
4
|
+
export declare const DEFAULT_SEQUENCE = 4294967295;
|
|
5
|
+
export declare const SIGHASH_ALL = 1;
|
|
6
|
+
export declare const OP_DUP = 118;
|
|
7
|
+
export declare const OP_HASH160 = 169;
|
|
8
|
+
export declare const HASH_SIZE = 20;
|
|
9
|
+
export declare const OP_EQUAL = 135;
|
|
10
|
+
export declare const OP_EQUALVERIFY = 136;
|
|
11
|
+
export declare const OP_CHECKSIG = 172;
|
|
12
|
+
export declare const OP_RETURN = 106;
|
|
13
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,eAAe,IAAI,CAAC;AACjC,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,eAAO,MAAM,gBAAgB,aAAa,CAAC;AAC3C,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,MAAM,MAAO,CAAC;AAC3B,eAAO,MAAM,UAAU,MAAO,CAAC;AAC/B,eAAO,MAAM,SAAS,KAAO,CAAC;AAC9B,eAAO,MAAM,QAAQ,MAAO,CAAC;AAC7B,eAAO,MAAM,cAAc,MAAO,CAAC;AACnC,eAAO,MAAM,WAAW,MAAO,CAAC;AAChC,eAAO,MAAM,SAAS,MAAO,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// flow
|
|
2
|
+
export var MAX_SCRIPT_BLOCK = 50;
|
|
3
|
+
export var DEFAULT_VERSION = 1;
|
|
4
|
+
export var DEFAULT_LOCKTIME = 0;
|
|
5
|
+
export var DEFAULT_SEQUENCE = 0xffffffff;
|
|
6
|
+
export var SIGHASH_ALL = 1;
|
|
7
|
+
export var OP_DUP = 0x76;
|
|
8
|
+
export var OP_HASH160 = 0xa9;
|
|
9
|
+
export var HASH_SIZE = 0x14;
|
|
10
|
+
export var OP_EQUAL = 0x87;
|
|
11
|
+
export var OP_EQUALVERIFY = 0x88;
|
|
12
|
+
export var OP_CHECKSIG = 0xac;
|
|
13
|
+
export var OP_RETURN = 0x6a;
|
|
14
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO;AACP,MAAM,CAAC,IAAM,gBAAgB,GAAG,EAAE,CAAC;AACnC,MAAM,CAAC,IAAM,eAAe,GAAG,CAAC,CAAC;AACjC,MAAM,CAAC,IAAM,gBAAgB,GAAG,CAAC,CAAC;AAClC,MAAM,CAAC,IAAM,gBAAgB,GAAG,UAAU,CAAC;AAC3C,MAAM,CAAC,IAAM,WAAW,GAAG,CAAC,CAAC;AAC7B,MAAM,CAAC,IAAM,MAAM,GAAG,IAAI,CAAC;AAC3B,MAAM,CAAC,IAAM,UAAU,GAAG,IAAI,CAAC;AAC/B,MAAM,CAAC,IAAM,SAAS,GAAG,IAAI,CAAC;AAC9B,MAAM,CAAC,IAAM,QAAQ,GAAG,IAAI,CAAC;AAC7B,MAAM,CAAC,IAAM,cAAc,GAAG,IAAI,CAAC;AACnC,MAAM,CAAC,IAAM,WAAW,GAAG,IAAI,CAAC;AAChC,MAAM,CAAC,IAAM,SAAS,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type Transport from "@ledgerhq/hw-transport";
|
|
3
|
+
import type { AddressFormat } from "./getWalletPublicKey";
|
|
4
|
+
import type { Transaction } from "./types";
|
|
5
|
+
export type { AddressFormat };
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
export declare type CreateTransactionArg = {
|
|
10
|
+
inputs: Array<[
|
|
11
|
+
Transaction,
|
|
12
|
+
number,
|
|
13
|
+
string | null | undefined,
|
|
14
|
+
number | null | undefined
|
|
15
|
+
]>;
|
|
16
|
+
associatedKeysets: string[];
|
|
17
|
+
changePath?: string;
|
|
18
|
+
outputScriptHex: string;
|
|
19
|
+
lockTime?: number;
|
|
20
|
+
sigHashType?: number;
|
|
21
|
+
segwit?: boolean;
|
|
22
|
+
initialTimestamp?: number;
|
|
23
|
+
additionals: Array<string>;
|
|
24
|
+
expiryHeight?: Buffer;
|
|
25
|
+
useTrustedInputForSegwit?: boolean;
|
|
26
|
+
onDeviceStreaming?: (arg0: {
|
|
27
|
+
progress: number;
|
|
28
|
+
total: number;
|
|
29
|
+
index: number;
|
|
30
|
+
}) => void;
|
|
31
|
+
onDeviceSignatureRequested?: () => void;
|
|
32
|
+
onDeviceSignatureGranted?: () => void;
|
|
33
|
+
};
|
|
34
|
+
export declare function createTransaction(transport: Transport, arg: CreateTransactionArg): Promise<string>;
|
|
35
|
+
//# sourceMappingURL=createTransaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTransaction.d.ts","sourceRoot":"","sources":["../src/createTransaction.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAC;AAGpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAS1D,OAAO,KAAK,EAAqB,WAAW,EAAE,MAAM,SAAS,CAAC;AAY9D,YAAY,EAAE,aAAa,EAAE,CAAC;AAW9B;;GAEG;AACH,oBAAY,oBAAoB,GAAG;IACjC,MAAM,EAAE,KAAK,CACX;QAAC,WAAW;QAAE,MAAM;QAAE,MAAM,GAAG,IAAI,GAAG,SAAS;QAAE,MAAM,GAAG,IAAI,GAAG,SAAS;KAAC,CAC5E,CAAC;IACF,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE;QACzB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,KAAK,IAAI,CAAC;IACX,0BAA0B,CAAC,EAAE,MAAM,IAAI,CAAC;IACxC,wBAAwB,CAAC,EAAE,MAAM,IAAI,CAAC;CACvC,CAAC;AACF,wBAAsB,iBAAiB,CACrC,SAAS,EAA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