@ledgerhq/hw-app-btc 6.24.1 → 6.24.2-monorepo.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 -0
- package/CHANGELOG.md +10 -0
- package/jest.config.ts +6 -0
- package/package.json +15 -6
- package/src/bip32.ts +5 -3
- package/src/getTrustedInput.ts +2 -8
- package/src/newops/appClient.ts +8 -4
- package/src/newops/psbtv2.ts +13 -9
- package/LICENSE +0 -202
- package/lib/Btc.d.ts +0 -149
- package/lib/Btc.d.ts.map +0 -1
- package/lib/Btc.js +0 -353
- package/lib/Btc.js.map +0 -1
- package/lib/BtcNew.d.ts +0 -122
- package/lib/BtcNew.d.ts.map +0 -1
- package/lib/BtcNew.js +0 -451
- package/lib/BtcNew.js.map +0 -1
- package/lib/BtcOld.d.ts +0 -120
- package/lib/BtcOld.d.ts.map +0 -1
- package/lib/BtcOld.js +0 -263
- package/lib/BtcOld.js.map +0 -1
- package/lib/bip32.d.ts +0 -13
- package/lib/bip32.d.ts.map +0 -1
- package/lib/bip32.js +0 -57
- package/lib/bip32.js.map +0 -1
- package/lib/buffertools.d.ts +0 -30
- package/lib/buffertools.d.ts.map +0 -1
- package/lib/buffertools.js +0 -132
- package/lib/buffertools.js.map +0 -1
- package/lib/compressPublicKey.d.ts +0 -3
- package/lib/compressPublicKey.d.ts.map +0 -1
- package/lib/compressPublicKey.js +0 -11
- package/lib/compressPublicKey.js.map +0 -1
- package/lib/constants.d.ts +0 -13
- package/lib/constants.d.ts.map +0 -1
- package/lib/constants.js +0 -17
- package/lib/constants.js.map +0 -1
- package/lib/createTransaction.d.ts +0 -35
- package/lib/createTransaction.d.ts.map +0 -1
- package/lib/createTransaction.js +0 -411
- package/lib/createTransaction.js.map +0 -1
- package/lib/debug.d.ts +0 -4
- package/lib/debug.d.ts.map +0 -1
- package/lib/debug.js +0 -45
- package/lib/debug.js.map +0 -1
- package/lib/finalizeInput.d.ts +0 -5
- package/lib/finalizeInput.d.ts.map +0 -1
- package/lib/finalizeInput.js +0 -81
- package/lib/finalizeInput.js.map +0 -1
- package/lib/getAppAndVersion.d.ts +0 -9
- package/lib/getAppAndVersion.d.ts.map +0 -1
- package/lib/getAppAndVersion.js +0 -69
- package/lib/getAppAndVersion.js.map +0 -1
- package/lib/getTrustedInput.d.ts +0 -6
- package/lib/getTrustedInput.d.ts.map +0 -1
- package/lib/getTrustedInput.js +0 -275
- package/lib/getTrustedInput.js.map +0 -1
- package/lib/getTrustedInputBIP143.d.ts +0 -4
- package/lib/getTrustedInputBIP143.d.ts.map +0 -1
- package/lib/getTrustedInputBIP143.js +0 -34
- package/lib/getTrustedInputBIP143.js.map +0 -1
- package/lib/getWalletPublicKey.d.ts +0 -15
- package/lib/getWalletPublicKey.d.ts.map +0 -1
- package/lib/getWalletPublicKey.js +0 -93
- package/lib/getWalletPublicKey.js.map +0 -1
- package/lib/hashPublicKey.d.ts +0 -3
- package/lib/hashPublicKey.d.ts.map +0 -1
- package/lib/hashPublicKey.js +0 -13
- package/lib/hashPublicKey.js.map +0 -1
- package/lib/index.d.ts +0 -3
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -8
- package/lib/index.js.map +0 -1
- package/lib/newops/accounttype.d.ts +0 -110
- package/lib/newops/accounttype.d.ts.map +0 -1
- package/lib/newops/accounttype.js +0 -236
- package/lib/newops/accounttype.js.map +0 -1
- package/lib/newops/appClient.d.ts +0 -18
- package/lib/newops/appClient.d.ts.map +0 -1
- package/lib/newops/appClient.js +0 -246
- package/lib/newops/appClient.js.map +0 -1
- package/lib/newops/clientCommands.d.ts +0 -77
- package/lib/newops/clientCommands.d.ts.map +0 -1
- package/lib/newops/clientCommands.js +0 -353
- package/lib/newops/clientCommands.js.map +0 -1
- package/lib/newops/merkelizedPsbt.d.ts +0 -26
- package/lib/newops/merkelizedPsbt.d.ts.map +0 -1
- package/lib/newops/merkelizedPsbt.js +0 -102
- package/lib/newops/merkelizedPsbt.js.map +0 -1
- package/lib/newops/merkle.d.ts +0 -34
- package/lib/newops/merkle.d.ts.map +0 -1
- package/lib/newops/merkle.js +0 -138
- package/lib/newops/merkle.js.map +0 -1
- package/lib/newops/merkleMap.d.ts +0 -25
- package/lib/newops/merkleMap.d.ts.map +0 -1
- package/lib/newops/merkleMap.js +0 -47
- package/lib/newops/merkleMap.js.map +0 -1
- package/lib/newops/policy.d.ts +0 -22
- package/lib/newops/policy.d.ts.map +0 -1
- package/lib/newops/policy.js +0 -48
- package/lib/newops/policy.js.map +0 -1
- package/lib/newops/psbtExtractor.d.ts +0 -10
- package/lib/newops/psbtExtractor.d.ts.map +0 -1
- package/lib/newops/psbtExtractor.js +0 -42
- package/lib/newops/psbtExtractor.js.map +0 -1
- package/lib/newops/psbtFinalizer.d.ts +0 -17
- package/lib/newops/psbtFinalizer.d.ts.map +0 -1
- package/lib/newops/psbtFinalizer.js +0 -135
- package/lib/newops/psbtFinalizer.js.map +0 -1
- package/lib/newops/psbtv2.d.ts +0 -149
- package/lib/newops/psbtv2.d.ts.map +0 -1
- package/lib/newops/psbtv2.js +0 -506
- package/lib/newops/psbtv2.js.map +0 -1
- package/lib/serializeTransaction.d.ts +0 -10
- package/lib/serializeTransaction.d.ts.map +0 -1
- package/lib/serializeTransaction.js +0 -72
- package/lib/serializeTransaction.js.map +0 -1
- package/lib/shouldUseTrustedInputForSegwit.d.ts +0 -5
- package/lib/shouldUseTrustedInputForSegwit.d.ts.map +0 -1
- package/lib/shouldUseTrustedInputForSegwit.js +0 -17
- package/lib/shouldUseTrustedInputForSegwit.js.map +0 -1
- package/lib/signMessage.d.ts +0 -10
- package/lib/signMessage.d.ts.map +0 -1
- package/lib/signMessage.js +0 -118
- package/lib/signMessage.js.map +0 -1
- package/lib/signP2SHTransaction.d.ts +0 -21
- package/lib/signP2SHTransaction.d.ts.map +0 -1
- package/lib/signP2SHTransaction.js +0 -208
- package/lib/signP2SHTransaction.js.map +0 -1
- package/lib/signTransaction.d.ts +0 -4
- package/lib/signTransaction.d.ts.map +0 -1
- package/lib/signTransaction.js +0 -36
- package/lib/signTransaction.js.map +0 -1
- package/lib/splitTransaction.d.ts +0 -3
- package/lib/splitTransaction.d.ts.map +0 -1
- package/lib/splitTransaction.js +0 -142
- package/lib/splitTransaction.js.map +0 -1
- package/lib/startUntrustedHashTransactionInput.d.ts +0 -9
- package/lib/startUntrustedHashTransactionInput.d.ts.map +0 -1
- package/lib/startUntrustedHashTransactionInput.js +0 -197
- package/lib/startUntrustedHashTransactionInput.js.map +0 -1
- package/lib/types.d.ts +0 -34
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js +0 -3
- package/lib/types.js.map +0 -1
- package/lib/varint.d.ts +0 -4
- package/lib/varint.d.ts.map +0 -1
- package/lib/varint.js +0 -45
- package/lib/varint.js.map +0 -1
- package/lib-es/Btc.d.ts +0 -149
- package/lib-es/Btc.d.ts.map +0 -1
- package/lib-es/Btc.js +0 -329
- package/lib-es/Btc.js.map +0 -1
- package/lib-es/BtcNew.d.ts +0 -122
- package/lib-es/BtcNew.d.ts.map +0 -1
- package/lib-es/BtcNew.js +0 -444
- package/lib-es/BtcNew.js.map +0 -1
- package/lib-es/BtcOld.d.ts +0 -120
- package/lib-es/BtcOld.d.ts.map +0 -1
- package/lib-es/BtcOld.js +0 -258
- package/lib-es/BtcOld.js.map +0 -1
- package/lib-es/bip32.d.ts +0 -13
- package/lib-es/bip32.d.ts.map +0 -1
- package/lib-es/bip32.js +0 -44
- package/lib-es/bip32.js.map +0 -1
- package/lib-es/buffertools.d.ts +0 -30
- package/lib-es/buffertools.d.ts.map +0 -1
- package/lib-es/buffertools.js +0 -124
- package/lib-es/buffertools.js.map +0 -1
- package/lib-es/compressPublicKey.d.ts +0 -3
- package/lib-es/compressPublicKey.d.ts.map +0 -1
- package/lib-es/compressPublicKey.js +0 -7
- package/lib-es/compressPublicKey.js.map +0 -1
- package/lib-es/constants.d.ts +0 -13
- package/lib-es/constants.d.ts.map +0 -1
- package/lib-es/constants.js +0 -14
- package/lib-es/constants.js.map +0 -1
- package/lib-es/createTransaction.d.ts +0 -35
- package/lib-es/createTransaction.d.ts.map +0 -1
- package/lib-es/createTransaction.js +0 -407
- package/lib-es/createTransaction.js.map +0 -1
- package/lib-es/debug.d.ts +0 -4
- package/lib-es/debug.d.ts.map +0 -1
- package/lib-es/debug.js +0 -40
- package/lib-es/debug.js.map +0 -1
- package/lib-es/finalizeInput.d.ts +0 -5
- package/lib-es/finalizeInput.d.ts.map +0 -1
- package/lib-es/finalizeInput.js +0 -76
- package/lib-es/finalizeInput.js.map +0 -1
- package/lib-es/getAppAndVersion.d.ts +0 -9
- package/lib-es/getAppAndVersion.d.ts.map +0 -1
- package/lib-es/getAppAndVersion.js +0 -62
- package/lib-es/getAppAndVersion.js.map +0 -1
- package/lib-es/getTrustedInput.d.ts +0 -6
- package/lib-es/getTrustedInput.d.ts.map +0 -1
- package/lib-es/getTrustedInput.js +0 -267
- package/lib-es/getTrustedInput.js.map +0 -1
- package/lib-es/getTrustedInputBIP143.d.ts +0 -4
- package/lib-es/getTrustedInputBIP143.d.ts.map +0 -1
- package/lib-es/getTrustedInputBIP143.js +0 -27
- package/lib-es/getTrustedInputBIP143.js.map +0 -1
- package/lib-es/getWalletPublicKey.d.ts +0 -15
- package/lib-es/getWalletPublicKey.d.ts.map +0 -1
- package/lib-es/getWalletPublicKey.js +0 -89
- package/lib-es/getWalletPublicKey.js.map +0 -1
- package/lib-es/hashPublicKey.d.ts +0 -3
- package/lib-es/hashPublicKey.d.ts.map +0 -1
- package/lib-es/hashPublicKey.js +0 -6
- package/lib-es/hashPublicKey.js.map +0 -1
- package/lib-es/index.d.ts +0 -3
- package/lib-es/index.d.ts.map +0 -1
- package/lib-es/index.js +0 -3
- package/lib-es/index.js.map +0 -1
- package/lib-es/newops/accounttype.d.ts +0 -110
- package/lib-es/newops/accounttype.d.ts.map +0 -1
- package/lib-es/newops/accounttype.js +0 -233
- package/lib-es/newops/accounttype.js.map +0 -1
- package/lib-es/newops/appClient.d.ts +0 -18
- package/lib-es/newops/appClient.d.ts.map +0 -1
- package/lib-es/newops/appClient.js +0 -243
- package/lib-es/newops/appClient.js.map +0 -1
- package/lib-es/newops/clientCommands.d.ts +0 -77
- package/lib-es/newops/clientCommands.d.ts.map +0 -1
- package/lib-es/newops/clientCommands.js +0 -350
- package/lib-es/newops/clientCommands.js.map +0 -1
- package/lib-es/newops/merkelizedPsbt.d.ts +0 -26
- package/lib-es/newops/merkelizedPsbt.d.ts.map +0 -1
- package/lib-es/newops/merkelizedPsbt.js +0 -99
- package/lib-es/newops/merkelizedPsbt.js.map +0 -1
- package/lib-es/newops/merkle.d.ts +0 -34
- package/lib-es/newops/merkle.d.ts.map +0 -1
- package/lib-es/newops/merkle.js +0 -134
- package/lib-es/newops/merkle.js.map +0 -1
- package/lib-es/newops/merkleMap.d.ts +0 -25
- package/lib-es/newops/merkleMap.d.ts.map +0 -1
- package/lib-es/newops/merkleMap.js +0 -44
- package/lib-es/newops/merkleMap.js.map +0 -1
- package/lib-es/newops/policy.d.ts +0 -22
- package/lib-es/newops/policy.d.ts.map +0 -1
- package/lib-es/newops/policy.js +0 -44
- package/lib-es/newops/policy.js.map +0 -1
- package/lib-es/newops/psbtExtractor.d.ts +0 -10
- package/lib-es/newops/psbtExtractor.d.ts.map +0 -1
- package/lib-es/newops/psbtExtractor.js +0 -38
- package/lib-es/newops/psbtExtractor.js.map +0 -1
- package/lib-es/newops/psbtFinalizer.d.ts +0 -17
- package/lib-es/newops/psbtFinalizer.d.ts.map +0 -1
- package/lib-es/newops/psbtFinalizer.js +0 -131
- package/lib-es/newops/psbtFinalizer.js.map +0 -1
- package/lib-es/newops/psbtv2.d.ts +0 -149
- package/lib-es/newops/psbtv2.d.ts.map +0 -1
- package/lib-es/newops/psbtv2.js +0 -503
- package/lib-es/newops/psbtv2.js.map +0 -1
- package/lib-es/serializeTransaction.d.ts +0 -10
- package/lib-es/serializeTransaction.d.ts.map +0 -1
- package/lib-es/serializeTransaction.js +0 -67
- package/lib-es/serializeTransaction.js.map +0 -1
- package/lib-es/shouldUseTrustedInputForSegwit.d.ts +0 -5
- package/lib-es/shouldUseTrustedInputForSegwit.d.ts.map +0 -1
- package/lib-es/shouldUseTrustedInputForSegwit.js +0 -10
- package/lib-es/shouldUseTrustedInputForSegwit.js.map +0 -1
- package/lib-es/signMessage.d.ts +0 -10
- package/lib-es/signMessage.d.ts.map +0 -1
- package/lib-es/signMessage.js +0 -111
- package/lib-es/signMessage.js.map +0 -1
- package/lib-es/signP2SHTransaction.d.ts +0 -21
- package/lib-es/signP2SHTransaction.d.ts.map +0 -1
- package/lib-es/signP2SHTransaction.js +0 -204
- package/lib-es/signP2SHTransaction.js.map +0 -1
- package/lib-es/signTransaction.d.ts +0 -4
- package/lib-es/signTransaction.d.ts.map +0 -1
- package/lib-es/signTransaction.js +0 -32
- package/lib-es/signTransaction.js.map +0 -1
- package/lib-es/splitTransaction.d.ts +0 -3
- package/lib-es/splitTransaction.d.ts.map +0 -1
- package/lib-es/splitTransaction.js +0 -138
- package/lib-es/splitTransaction.js.map +0 -1
- package/lib-es/startUntrustedHashTransactionInput.d.ts +0 -9
- package/lib-es/startUntrustedHashTransactionInput.d.ts.map +0 -1
- package/lib-es/startUntrustedHashTransactionInput.js +0 -192
- package/lib-es/startUntrustedHashTransactionInput.js.map +0 -1
- package/lib-es/types.d.ts +0 -34
- package/lib-es/types.d.ts.map +0 -1
- package/lib-es/types.js +0 -2
- package/lib-es/types.js.map +0 -1
- package/lib-es/varint.d.ts +0 -4
- package/lib-es/varint.d.ts.map +0 -1
- package/lib-es/varint.js +0 -40
- package/lib-es/varint.js.map +0 -1
package/lib-es/BtcNew.js
DELETED
|
@@ -1,444 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
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;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import { crypto } from "bitcoinjs-lib";
|
|
38
|
-
import semver from "semver";
|
|
39
|
-
import { pointCompress } from "tiny-secp256k1";
|
|
40
|
-
import { getXpubComponents, hardenedPathOf, pathArrayToString, pathStringToArray, pubkeyFromXpub, } from "./bip32";
|
|
41
|
-
import { BufferReader } from "./buffertools";
|
|
42
|
-
import { p2pkh, p2tr, p2wpkh, p2wpkhWrapped, } from "./newops/accounttype";
|
|
43
|
-
import { createKey, WalletPolicy, } from "./newops/policy";
|
|
44
|
-
import { extract } from "./newops/psbtExtractor";
|
|
45
|
-
import { finalize } from "./newops/psbtFinalizer";
|
|
46
|
-
import { psbtIn, PsbtV2 } from "./newops/psbtv2";
|
|
47
|
-
import { serializeTransaction } from "./serializeTransaction";
|
|
48
|
-
var newSupportedApps = ["Bitcoin", "Bitcoin Test"];
|
|
49
|
-
export function canSupportApp(appAndVersion) {
|
|
50
|
-
return (newSupportedApps.includes(appAndVersion.name) &&
|
|
51
|
-
semver.major(appAndVersion.version) >= 2);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* This class implements the same interface as BtcOld (formerly
|
|
55
|
-
* named Btc), but interacts with Bitcoin hardware app version 2+
|
|
56
|
-
* which uses a totally new APDU protocol. This new
|
|
57
|
-
* protocol is documented at
|
|
58
|
-
* https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md
|
|
59
|
-
*
|
|
60
|
-
* Since the interface must remain compatible with BtcOld, the methods
|
|
61
|
-
* of this class are quite clunky, because it needs to adapt legacy
|
|
62
|
-
* input data into the PSBT process. In the future, a new interface should
|
|
63
|
-
* be developed that exposes PSBT to the outer world, which would render
|
|
64
|
-
* a much cleaner implementation.
|
|
65
|
-
*/
|
|
66
|
-
var BtcNew = /** @class */ (function () {
|
|
67
|
-
function BtcNew(client) {
|
|
68
|
-
this.client = client;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* This is a new method that allow users to get an xpub at a standard path.
|
|
72
|
-
* Standard paths are described at
|
|
73
|
-
* https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md#description
|
|
74
|
-
*
|
|
75
|
-
* This boils down to paths (N=0 for Bitcoin, N=1 for Testnet):
|
|
76
|
-
* M/44'/N'/x'/**
|
|
77
|
-
* M/48'/N'/x'/y'/**
|
|
78
|
-
* M/49'/N'/x'/**
|
|
79
|
-
* M/84'/N'/x'/**
|
|
80
|
-
* M/86'/N'/x'/**
|
|
81
|
-
*
|
|
82
|
-
* The method was added because of added security in the hardware app v2+. The
|
|
83
|
-
* new hardware app will allow export of any xpub up to and including the
|
|
84
|
-
* deepest hardened key of standard derivation paths, whereas the old app
|
|
85
|
-
* would allow export of any key.
|
|
86
|
-
*
|
|
87
|
-
* This caused an issue for callers of this class, who only had
|
|
88
|
-
* getWalletPublicKey() to call which means they have to constuct xpub
|
|
89
|
-
* themselves:
|
|
90
|
-
*
|
|
91
|
-
* Suppose a user of this class wants to create an account xpub on a standard
|
|
92
|
-
* path, M/44'/0'/Z'. The user must get the parent key fingerprint (see BIP32)
|
|
93
|
-
* by requesting the parent key M/44'/0'. The new app won't allow that, because
|
|
94
|
-
* it only allows exporting deepest level hardened path. So the options are to
|
|
95
|
-
* allow requesting M/44'/0' from the app, or to add a new function
|
|
96
|
-
* "getWalletXpub".
|
|
97
|
-
*
|
|
98
|
-
* We opted for adding a new function, which can greatly simplify client code.
|
|
99
|
-
*/
|
|
100
|
-
BtcNew.prototype.getWalletXpub = function (_a) {
|
|
101
|
-
var path = _a.path, xpubVersion = _a.xpubVersion;
|
|
102
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
103
|
-
var pathElements, xpub, xpubComponents;
|
|
104
|
-
return __generator(this, function (_b) {
|
|
105
|
-
switch (_b.label) {
|
|
106
|
-
case 0:
|
|
107
|
-
pathElements = pathStringToArray(path);
|
|
108
|
-
return [4 /*yield*/, this.client.getExtendedPubkey(false, pathElements)];
|
|
109
|
-
case 1:
|
|
110
|
-
xpub = _b.sent();
|
|
111
|
-
xpubComponents = getXpubComponents(xpub);
|
|
112
|
-
if (xpubComponents.version != xpubVersion) {
|
|
113
|
-
throw new Error("Expected xpub version ".concat(xpubVersion, " doesn't match the xpub version from the device ").concat(xpubComponents.version));
|
|
114
|
-
}
|
|
115
|
-
return [2 /*return*/, xpub];
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* This method returns a public key, a bitcoin address, and and a chaincode
|
|
122
|
-
* for a specific derivation path.
|
|
123
|
-
*
|
|
124
|
-
* Limitation: If the path is not a leaf node of a standard path, the address
|
|
125
|
-
* will be the empty string "", see this.getWalletAddress() for details.
|
|
126
|
-
*/
|
|
127
|
-
BtcNew.prototype.getWalletPublicKey = function (path, opts) {
|
|
128
|
-
var _a, _b;
|
|
129
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
130
|
-
var pathElements, xpub, display, address, components, uncompressedPubkey;
|
|
131
|
-
return __generator(this, function (_c) {
|
|
132
|
-
switch (_c.label) {
|
|
133
|
-
case 0:
|
|
134
|
-
pathElements = pathStringToArray(path);
|
|
135
|
-
return [4 /*yield*/, this.client.getExtendedPubkey(false, pathElements)];
|
|
136
|
-
case 1:
|
|
137
|
-
xpub = _c.sent();
|
|
138
|
-
display = (_a = opts === null || opts === void 0 ? void 0 : opts.verify) !== null && _a !== void 0 ? _a : false;
|
|
139
|
-
return [4 /*yield*/, this.getWalletAddress(pathElements, descrTemplFrom((_b = opts === null || opts === void 0 ? void 0 : opts.format) !== null && _b !== void 0 ? _b : "legacy"), display)];
|
|
140
|
-
case 2:
|
|
141
|
-
address = _c.sent();
|
|
142
|
-
components = getXpubComponents(xpub);
|
|
143
|
-
uncompressedPubkey = Buffer.from(pointCompress(components.pubkey, false));
|
|
144
|
-
return [2 /*return*/, {
|
|
145
|
-
publicKey: uncompressedPubkey.toString("hex"),
|
|
146
|
-
bitcoinAddress: address,
|
|
147
|
-
chainCode: components.chaincode.toString("hex")
|
|
148
|
-
}];
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
};
|
|
153
|
-
/**
|
|
154
|
-
* Get an address for the specified path.
|
|
155
|
-
*
|
|
156
|
-
* If display is true, we must get the address from the device, which would require
|
|
157
|
-
* us to determine WalletPolicy. This requires two *extra* queries to the device, one
|
|
158
|
-
* for the account xpub and one for master key fingerprint.
|
|
159
|
-
*
|
|
160
|
-
* If display is false we *could* generate the address ourselves, but chose to
|
|
161
|
-
* get it from the device to save development time. However, it shouldn't take
|
|
162
|
-
* too much time to implement local address generation.
|
|
163
|
-
*
|
|
164
|
-
* Moreover, if the path is not for a leaf, ie accountPath+/X/Y, there is no
|
|
165
|
-
* way to get the address from the device. In this case we have to create it
|
|
166
|
-
* ourselves, but we don't at this time, and instead return an empty ("") address.
|
|
167
|
-
*/
|
|
168
|
-
BtcNew.prototype.getWalletAddress = function (pathElements, descrTempl, display) {
|
|
169
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
170
|
-
var accountPath, accountXpub, masterFingerprint, policy, changeAndIndex;
|
|
171
|
-
return __generator(this, function (_a) {
|
|
172
|
-
switch (_a.label) {
|
|
173
|
-
case 0:
|
|
174
|
-
accountPath = hardenedPathOf(pathElements);
|
|
175
|
-
if (accountPath.length + 2 != pathElements.length) {
|
|
176
|
-
return [2 /*return*/, ""];
|
|
177
|
-
}
|
|
178
|
-
return [4 /*yield*/, this.client.getExtendedPubkey(false, accountPath)];
|
|
179
|
-
case 1:
|
|
180
|
-
accountXpub = _a.sent();
|
|
181
|
-
return [4 /*yield*/, this.client.getMasterFingerprint()];
|
|
182
|
-
case 2:
|
|
183
|
-
masterFingerprint = _a.sent();
|
|
184
|
-
policy = new WalletPolicy(descrTempl, createKey(masterFingerprint, accountPath, accountXpub));
|
|
185
|
-
changeAndIndex = pathElements.slice(-2, pathElements.length);
|
|
186
|
-
return [2 /*return*/, this.client.getWalletAddress(policy, Buffer.alloc(32, 0), changeAndIndex[0], changeAndIndex[1], display)];
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
};
|
|
191
|
-
/**
|
|
192
|
-
* Build and sign a transaction. See Btc.createPaymentTransactionNew for
|
|
193
|
-
* details on how to use this method.
|
|
194
|
-
*
|
|
195
|
-
* This method will convert the legacy arguments, CreateTransactionArg, into
|
|
196
|
-
* a psbt which is finally signed and finalized, and the extracted fully signed
|
|
197
|
-
* transaction is returned.
|
|
198
|
-
*/
|
|
199
|
-
BtcNew.prototype.createPaymentTransactionNew = function (arg) {
|
|
200
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
201
|
-
var inputCount, psbt, masterFp, accountType, notifyCount, progress, accountXpub, accountPath, i, pathElems, outputsConcat, outputsBufferReader, outputCount, changeData, changeFound, i, amount, outputScript, isChange, changePath, pubkey, key, p, firstSigned, progressCallback, serializedTx;
|
|
202
|
-
return __generator(this, function (_a) {
|
|
203
|
-
switch (_a.label) {
|
|
204
|
-
case 0:
|
|
205
|
-
inputCount = arg.inputs.length;
|
|
206
|
-
if (inputCount == 0) {
|
|
207
|
-
throw Error("No inputs");
|
|
208
|
-
}
|
|
209
|
-
psbt = new PsbtV2();
|
|
210
|
-
return [4 /*yield*/, this.client.getMasterFingerprint()];
|
|
211
|
-
case 1:
|
|
212
|
-
masterFp = _a.sent();
|
|
213
|
-
accountType = accountTypeFromArg(arg, psbt, masterFp);
|
|
214
|
-
if (arg.lockTime != undefined) {
|
|
215
|
-
// The signer will assume locktime 0 if unset
|
|
216
|
-
psbt.setGlobalFallbackLocktime(arg.lockTime);
|
|
217
|
-
}
|
|
218
|
-
psbt.setGlobalInputCount(inputCount);
|
|
219
|
-
psbt.setGlobalPsbtVersion(2);
|
|
220
|
-
psbt.setGlobalTxVersion(2);
|
|
221
|
-
notifyCount = 0;
|
|
222
|
-
progress = function () {
|
|
223
|
-
if (!arg.onDeviceStreaming)
|
|
224
|
-
return;
|
|
225
|
-
arg.onDeviceStreaming({
|
|
226
|
-
total: 2 * inputCount,
|
|
227
|
-
index: notifyCount,
|
|
228
|
-
progress: ++notifyCount / (2 * inputCount)
|
|
229
|
-
});
|
|
230
|
-
};
|
|
231
|
-
accountXpub = "";
|
|
232
|
-
accountPath = [];
|
|
233
|
-
i = 0;
|
|
234
|
-
_a.label = 2;
|
|
235
|
-
case 2:
|
|
236
|
-
if (!(i < inputCount)) return [3 /*break*/, 7];
|
|
237
|
-
progress();
|
|
238
|
-
pathElems = pathStringToArray(arg.associatedKeysets[i]);
|
|
239
|
-
if (!(accountXpub == "")) return [3 /*break*/, 4];
|
|
240
|
-
// We assume all inputs belong to the same account so we set
|
|
241
|
-
// the account xpub and path based on the first input.
|
|
242
|
-
accountPath = pathElems.slice(0, -2);
|
|
243
|
-
return [4 /*yield*/, this.client.getExtendedPubkey(false, accountPath)];
|
|
244
|
-
case 3:
|
|
245
|
-
accountXpub = _a.sent();
|
|
246
|
-
_a.label = 4;
|
|
247
|
-
case 4: return [4 /*yield*/, this.setInput(psbt, i, arg.inputs[i], pathElems, accountType, masterFp, arg.sigHashType)];
|
|
248
|
-
case 5:
|
|
249
|
-
_a.sent();
|
|
250
|
-
_a.label = 6;
|
|
251
|
-
case 6:
|
|
252
|
-
i++;
|
|
253
|
-
return [3 /*break*/, 2];
|
|
254
|
-
case 7:
|
|
255
|
-
outputsConcat = Buffer.from(arg.outputScriptHex, "hex");
|
|
256
|
-
outputsBufferReader = new BufferReader(outputsConcat);
|
|
257
|
-
outputCount = outputsBufferReader.readVarInt();
|
|
258
|
-
psbt.setGlobalOutputCount(outputCount);
|
|
259
|
-
return [4 /*yield*/, this.outputScriptAt(accountPath, accountType, arg.changePath)];
|
|
260
|
-
case 8:
|
|
261
|
-
changeData = _a.sent();
|
|
262
|
-
changeFound = !changeData;
|
|
263
|
-
for (i = 0; i < outputCount; i++) {
|
|
264
|
-
amount = Number(outputsBufferReader.readUInt64());
|
|
265
|
-
outputScript = outputsBufferReader.readVarSlice();
|
|
266
|
-
psbt.setOutputAmount(i, amount);
|
|
267
|
-
psbt.setOutputScript(i, outputScript);
|
|
268
|
-
isChange = changeData && outputScript.equals(changeData === null || changeData === void 0 ? void 0 : changeData.cond.scriptPubKey);
|
|
269
|
-
if (isChange) {
|
|
270
|
-
changeFound = true;
|
|
271
|
-
changePath = pathStringToArray(arg.changePath);
|
|
272
|
-
pubkey = changeData.pubkey;
|
|
273
|
-
accountType.setOwnOutput(i, changeData.cond, [pubkey], [changePath]);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
if (!changeFound) {
|
|
277
|
-
throw new Error("Change script not found among outputs! " +
|
|
278
|
-
(changeData === null || changeData === void 0 ? void 0 : changeData.cond.scriptPubKey.toString("hex")));
|
|
279
|
-
}
|
|
280
|
-
key = createKey(masterFp, accountPath, accountXpub);
|
|
281
|
-
p = new WalletPolicy(accountType.getDescriptorTemplate(), key);
|
|
282
|
-
// This is cheating, because it's not actually requested on the
|
|
283
|
-
// device yet, but it will be, soonish.
|
|
284
|
-
if (arg.onDeviceSignatureRequested)
|
|
285
|
-
arg.onDeviceSignatureRequested();
|
|
286
|
-
firstSigned = false;
|
|
287
|
-
progressCallback = function () {
|
|
288
|
-
if (!firstSigned) {
|
|
289
|
-
firstSigned = true;
|
|
290
|
-
arg.onDeviceSignatureGranted && arg.onDeviceSignatureGranted();
|
|
291
|
-
}
|
|
292
|
-
progress();
|
|
293
|
-
};
|
|
294
|
-
return [4 /*yield*/, this.signPsbt(psbt, p, progressCallback)];
|
|
295
|
-
case 9:
|
|
296
|
-
_a.sent();
|
|
297
|
-
finalize(psbt);
|
|
298
|
-
serializedTx = extract(psbt);
|
|
299
|
-
return [2 /*return*/, serializedTx.toString("hex")];
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
});
|
|
303
|
-
};
|
|
304
|
-
/**
|
|
305
|
-
* Calculates an output script along with public key and possible redeemScript
|
|
306
|
-
* from a path and accountType. The accountPath must be a prefix of path.
|
|
307
|
-
*
|
|
308
|
-
* @returns an object with output script (property "script"), redeemScript (if
|
|
309
|
-
* wrapped p2wpkh), and pubkey at provided path. The values of these three
|
|
310
|
-
* properties depend on the accountType used.
|
|
311
|
-
*/
|
|
312
|
-
BtcNew.prototype.outputScriptAt = function (accountPath, accountType, path) {
|
|
313
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
314
|
-
var pathElems, i, xpub, pubkey, cond;
|
|
315
|
-
return __generator(this, function (_a) {
|
|
316
|
-
switch (_a.label) {
|
|
317
|
-
case 0:
|
|
318
|
-
if (!path)
|
|
319
|
-
return [2 /*return*/, undefined];
|
|
320
|
-
pathElems = pathStringToArray(path);
|
|
321
|
-
// Make sure path is in our account, otherwise something fishy is probably
|
|
322
|
-
// going on.
|
|
323
|
-
for (i = 0; i < accountPath.length; i++) {
|
|
324
|
-
if (accountPath[i] != pathElems[i]) {
|
|
325
|
-
throw new Error("Path ".concat(path, " not in account ").concat(pathArrayToString(accountPath)));
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
return [4 /*yield*/, this.client.getExtendedPubkey(false, pathElems)];
|
|
329
|
-
case 1:
|
|
330
|
-
xpub = _a.sent();
|
|
331
|
-
pubkey = pubkeyFromXpub(xpub);
|
|
332
|
-
cond = accountType.spendingCondition([pubkey]);
|
|
333
|
-
return [2 /*return*/, { cond: cond, pubkey: pubkey }];
|
|
334
|
-
}
|
|
335
|
-
});
|
|
336
|
-
});
|
|
337
|
-
};
|
|
338
|
-
/**
|
|
339
|
-
* Adds relevant data about an input to the psbt. This includes sequence,
|
|
340
|
-
* previous txid, output index, spent UTXO, redeem script for wrapped p2wpkh,
|
|
341
|
-
* public key and its derivation path.
|
|
342
|
-
*/
|
|
343
|
-
BtcNew.prototype.setInput = function (psbt, i, input, pathElements, accountType, masterFP, sigHashType) {
|
|
344
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
345
|
-
var inputTx, spentOutputIndex, redeemScript, sequence, inputTxBuffer, inputTxid, xpubBase58, pubkey, spentTxOutput, spendCondition, spentOutput;
|
|
346
|
-
return __generator(this, function (_a) {
|
|
347
|
-
switch (_a.label) {
|
|
348
|
-
case 0:
|
|
349
|
-
inputTx = input[0];
|
|
350
|
-
spentOutputIndex = input[1];
|
|
351
|
-
redeemScript = input[2] ? Buffer.from(input[2], "hex") : undefined;
|
|
352
|
-
sequence = input[3];
|
|
353
|
-
if (sequence != undefined) {
|
|
354
|
-
psbt.setInputSequence(i, sequence);
|
|
355
|
-
}
|
|
356
|
-
if (sigHashType != undefined) {
|
|
357
|
-
psbt.setInputSighashType(i, sigHashType);
|
|
358
|
-
}
|
|
359
|
-
inputTxBuffer = serializeTransaction(inputTx, true);
|
|
360
|
-
inputTxid = crypto.hash256(inputTxBuffer);
|
|
361
|
-
return [4 /*yield*/, this.client.getExtendedPubkey(false, pathElements)];
|
|
362
|
-
case 1:
|
|
363
|
-
xpubBase58 = _a.sent();
|
|
364
|
-
pubkey = pubkeyFromXpub(xpubBase58);
|
|
365
|
-
if (!inputTx.outputs)
|
|
366
|
-
throw Error("Missing outputs array in transaction to sign");
|
|
367
|
-
spentTxOutput = inputTx.outputs[spentOutputIndex];
|
|
368
|
-
spendCondition = {
|
|
369
|
-
scriptPubKey: spentTxOutput.script,
|
|
370
|
-
redeemScript: redeemScript
|
|
371
|
-
};
|
|
372
|
-
spentOutput = { cond: spendCondition, amount: spentTxOutput.amount };
|
|
373
|
-
accountType.setInput(i, inputTxBuffer, spentOutput, [pubkey], [pathElements]);
|
|
374
|
-
psbt.setInputPreviousTxId(i, inputTxid);
|
|
375
|
-
psbt.setInputOutputIndex(i, spentOutputIndex);
|
|
376
|
-
return [2 /*return*/];
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
});
|
|
380
|
-
};
|
|
381
|
-
/**
|
|
382
|
-
* This implements the "Signer" role of the BIP370 transaction signing
|
|
383
|
-
* process.
|
|
384
|
-
*
|
|
385
|
-
* It ssks the hardware device to sign the a psbt using the specified wallet
|
|
386
|
-
* policy. This method assumes BIP32 derived keys are used for all inputs, see
|
|
387
|
-
* comment in-line. The signatures returned from the hardware device is added
|
|
388
|
-
* to the appropriate input fields of the PSBT.
|
|
389
|
-
*/
|
|
390
|
-
BtcNew.prototype.signPsbt = function (psbt, walletPolicy, progressCallback) {
|
|
391
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
392
|
-
var sigs;
|
|
393
|
-
return __generator(this, function (_a) {
|
|
394
|
-
switch (_a.label) {
|
|
395
|
-
case 0: return [4 /*yield*/, this.client.signPsbt(psbt, walletPolicy, Buffer.alloc(32, 0), progressCallback)];
|
|
396
|
-
case 1:
|
|
397
|
-
sigs = _a.sent();
|
|
398
|
-
sigs.forEach(function (v, k) {
|
|
399
|
-
// Note: Looking at BIP32 derivation does not work in the generic case,
|
|
400
|
-
// since some inputs might not have a BIP32-derived pubkey.
|
|
401
|
-
var pubkeys = psbt.getInputKeyDatas(k, psbtIn.BIP32_DERIVATION);
|
|
402
|
-
var pubkey;
|
|
403
|
-
if (pubkeys.length != 1) {
|
|
404
|
-
// No legacy BIP32_DERIVATION, assume we're using taproot.
|
|
405
|
-
pubkey = psbt.getInputKeyDatas(k, psbtIn.TAP_BIP32_DERIVATION);
|
|
406
|
-
if (pubkey.length == 0) {
|
|
407
|
-
throw Error("Missing pubkey derivation for input ".concat(k));
|
|
408
|
-
}
|
|
409
|
-
psbt.setInputTapKeySig(k, v);
|
|
410
|
-
}
|
|
411
|
-
else {
|
|
412
|
-
pubkey = pubkeys[0];
|
|
413
|
-
psbt.setInputPartialSig(k, pubkey, v);
|
|
414
|
-
}
|
|
415
|
-
});
|
|
416
|
-
return [2 /*return*/];
|
|
417
|
-
}
|
|
418
|
-
});
|
|
419
|
-
});
|
|
420
|
-
};
|
|
421
|
-
return BtcNew;
|
|
422
|
-
}());
|
|
423
|
-
export default BtcNew;
|
|
424
|
-
function descrTemplFrom(addressFormat) {
|
|
425
|
-
if (addressFormat == "legacy")
|
|
426
|
-
return "pkh(@0)";
|
|
427
|
-
if (addressFormat == "p2sh")
|
|
428
|
-
return "sh(wpkh(@0))";
|
|
429
|
-
if (addressFormat == "bech32")
|
|
430
|
-
return "wpkh(@0)";
|
|
431
|
-
if (addressFormat == "bech32m")
|
|
432
|
-
return "tr(@0)";
|
|
433
|
-
throw new Error("Unsupported address format " + addressFormat);
|
|
434
|
-
}
|
|
435
|
-
function accountTypeFromArg(arg, psbt, masterFp) {
|
|
436
|
-
if (arg.additionals.includes("bech32m"))
|
|
437
|
-
return new p2tr(psbt, masterFp);
|
|
438
|
-
if (arg.additionals.includes("bech32"))
|
|
439
|
-
return new p2wpkh(psbt, masterFp);
|
|
440
|
-
if (arg.segwit)
|
|
441
|
-
return new p2wpkhWrapped(psbt, masterFp);
|
|
442
|
-
return new p2pkh(psbt, masterFp);
|
|
443
|
-
}
|
|
444
|
-
//# sourceMappingURL=BtcNew.js.map
|
package/lib-es/BtcNew.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BtcNew.js","sourceRoot":"","sources":["../src/BtcNew.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAE,MAAM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|
-
import type { CreateTransactionArg } from "./createTransaction";
|
|
3
|
-
import type { AddressFormat } from "./getWalletPublicKey";
|
|
4
|
-
import type { SignP2SHTransactionArg } from "./signP2SHTransaction";
|
|
5
|
-
export type { AddressFormat };
|
|
6
|
-
/**
|
|
7
|
-
* Bitcoin API.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* import Btc from "@ledgerhq/hw-app-btc";
|
|
11
|
-
* const btc = new Btc(transport)
|
|
12
|
-
*/
|
|
13
|
-
export default class BtcOld {
|
|
14
|
-
private transport;
|
|
15
|
-
constructor(transport: Transport);
|
|
16
|
-
private derivationsCache;
|
|
17
|
-
private derivatePath;
|
|
18
|
-
getWalletXpub({ path, xpubVersion, }: {
|
|
19
|
-
path: string;
|
|
20
|
-
xpubVersion: number;
|
|
21
|
-
}): Promise<string>;
|
|
22
|
-
/**
|
|
23
|
-
* @param path a BIP 32 path
|
|
24
|
-
* @param options an object with optional these fields:
|
|
25
|
-
*
|
|
26
|
-
* - verify (boolean) will ask user to confirm the address on the device
|
|
27
|
-
*
|
|
28
|
-
* - format ("legacy" | "p2sh" | "bech32" | "cashaddr") to use different bitcoin address formatter.
|
|
29
|
-
*
|
|
30
|
-
* NB The normal usage is to use:
|
|
31
|
-
*
|
|
32
|
-
* - legacy format with 44' paths
|
|
33
|
-
*
|
|
34
|
-
* - p2sh format with 49' paths
|
|
35
|
-
*
|
|
36
|
-
* - bech32 format with 173' paths
|
|
37
|
-
*
|
|
38
|
-
* - cashaddr in case of Bitcoin Cash
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* btc.getWalletPublicKey("44'/0'/0'/0/0").then(o => o.bitcoinAddress)
|
|
42
|
-
* btc.getWalletPublicKey("49'/0'/0'/0/0", { format: "p2sh" }).then(o => o.bitcoinAddress)
|
|
43
|
-
*/
|
|
44
|
-
getWalletPublicKey(path: string, opts?: {
|
|
45
|
-
verify?: boolean;
|
|
46
|
-
format?: AddressFormat;
|
|
47
|
-
}): Promise<{
|
|
48
|
-
publicKey: string;
|
|
49
|
-
bitcoinAddress: string;
|
|
50
|
-
chainCode: string;
|
|
51
|
-
}>;
|
|
52
|
-
/**
|
|
53
|
-
* 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.
|
|
54
|
-
* @example
|
|
55
|
-
btc.signMessageNew_async("44'/60'/0'/0'/0", Buffer.from("test").toString("hex")).then(function(result) {
|
|
56
|
-
var v = result['v'] + 27 + 4;
|
|
57
|
-
var signature = Buffer.from(v.toString(16) + result['r'] + result['s'], 'hex').toString('base64');
|
|
58
|
-
console.log("Signature : " + signature);
|
|
59
|
-
}).catch(function(ex) {console.log(ex);});
|
|
60
|
-
*/
|
|
61
|
-
signMessageNew(path: string, messageHex: string): Promise<{
|
|
62
|
-
v: number;
|
|
63
|
-
r: string;
|
|
64
|
-
s: string;
|
|
65
|
-
}>;
|
|
66
|
-
/**
|
|
67
|
-
* To sign a transaction involving standard (P2PKH) inputs, call createTransaction with the following parameters
|
|
68
|
-
* @param inputs is an array of [ transaction, output_index, optional redeem script, optional sequence ] where
|
|
69
|
-
*
|
|
70
|
-
* * transaction is the previously computed transaction object for this UTXO
|
|
71
|
-
* * output_index is the output in the transaction used as input for this UTXO (counting from 0)
|
|
72
|
-
* * redeem script is the optional redeem script to use when consuming a Segregated Witness input
|
|
73
|
-
* * sequence is the sequence number to use for this input (when using RBF), or non present
|
|
74
|
-
* @param associatedKeysets is an array of BIP 32 paths pointing to the path to the private key used for each UTXO
|
|
75
|
-
* @param changePath is an optional BIP 32 path pointing to the path to the public key used to compute the change address
|
|
76
|
-
* @param outputScriptHex is the hexadecimal serialized outputs of the transaction to sign
|
|
77
|
-
* @param lockTime is the optional lockTime of the transaction to sign, or default (0)
|
|
78
|
-
* @param sigHashType is the hash type of the transaction to sign, or default (all)
|
|
79
|
-
* @param segwit is an optional boolean indicating wether to use segwit or not
|
|
80
|
-
* @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)
|
|
81
|
-
* @param additionals list of additionnal options
|
|
82
|
-
*
|
|
83
|
-
* - "bech32" for spending native segwit outputs
|
|
84
|
-
* - "abc" for bch
|
|
85
|
-
* - "gold" for btg
|
|
86
|
-
* - "bipxxx" for using BIPxxx
|
|
87
|
-
* - "sapling" to indicate a zec transaction is supporting sapling (to be set over block 419200)
|
|
88
|
-
* @param expiryHeight is an optional Buffer for zec overwinter / sapling Txs
|
|
89
|
-
* @param useTrustedInputForSegwit trust inputs for segwit transactions
|
|
90
|
-
* @return the signed transaction ready to be broadcast
|
|
91
|
-
* @example
|
|
92
|
-
btc.createTransaction({
|
|
93
|
-
inputs: [ [tx1, 1] ],
|
|
94
|
-
associatedKeysets: ["0'/0/0"],
|
|
95
|
-
outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
|
|
96
|
-
}).then(res => ...);
|
|
97
|
-
*/
|
|
98
|
-
createPaymentTransactionNew(arg: CreateTransactionArg): Promise<string>;
|
|
99
|
-
/**
|
|
100
|
-
* To obtain the signature of multisignature (P2SH) inputs, call signP2SHTransaction_async with the folowing parameters
|
|
101
|
-
* @param inputs is an array of [ transaction, output_index, redeem script, optional sequence ] where
|
|
102
|
-
* * transaction is the previously computed transaction object for this UTXO
|
|
103
|
-
* * output_index is the output in the transaction used as input for this UTXO (counting from 0)
|
|
104
|
-
* * redeem script is the mandatory redeem script associated to the current P2SH input
|
|
105
|
-
* * sequence is the sequence number to use for this input (when using RBF), or non present
|
|
106
|
-
* @param associatedKeysets is an array of BIP 32 paths pointing to the path to the private key used for each UTXO
|
|
107
|
-
* @param outputScriptHex is the hexadecimal serialized outputs of the transaction to sign
|
|
108
|
-
* @param lockTime is the optional lockTime of the transaction to sign, or default (0)
|
|
109
|
-
* @param sigHashType is the hash type of the transaction to sign, or default (all)
|
|
110
|
-
* @return the signed transaction ready to be broadcast
|
|
111
|
-
* @example
|
|
112
|
-
btc.signP2SHTransaction({
|
|
113
|
-
inputs: [ [tx, 1, "52210289b4a3ad52a919abd2bdd6920d8a6879b1e788c38aa76f0440a6f32a9f1996d02103a3393b1439d1693b063482c04bd40142db97bdf139eedd1b51ffb7070a37eac321030b9a409a1e476b0d5d17b804fcdb81cf30f9b99c6f3ae1178206e08bc500639853ae"] ],
|
|
114
|
-
associatedKeysets: ["0'/0/0"],
|
|
115
|
-
outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
|
|
116
|
-
}).then(result => ...);
|
|
117
|
-
*/
|
|
118
|
-
signP2SHTransaction(arg: SignP2SHTransactionArg): Promise<string[]>;
|
|
119
|
-
}
|
|
120
|
-
//# sourceMappingURL=BtcOld.d.ts.map
|
package/lib-es/BtcOld.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BtcOld.d.ts","sourceRoot":"","sources":["../src/BtcOld.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAGpE,YAAY,EAAE,aAAa,EAAE,CAAC;AAE9B;;;;;;GAMG;AAEH,MAAM,CAAC,OAAO,OAAO,MAAM;IACb,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS;IAExC,OAAO,CAAC,gBAAgB,CAAM;YAChB,YAAY;IASpB,aAAa,CAAC,EAClB,IAAI,EACJ,WAAW,GACZ,EAAE;QACD,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC,MAAM,CAAC;IAqBnB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,kBAAkB,CAChB,IAAI,EAAE,MAAM,EAC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