@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
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Merkle } from "./merkle";
|
|
3
|
-
import { MerkleMap } from "./merkleMap";
|
|
4
|
-
declare enum ClientCommandCode {
|
|
5
|
-
YIELD = 16,
|
|
6
|
-
GET_PREIMAGE = 64,
|
|
7
|
-
GET_MERKLE_LEAF_PROOF = 65,
|
|
8
|
-
GET_MERKLE_LEAF_INDEX = 66,
|
|
9
|
-
GET_MORE_ELEMENTS = 160
|
|
10
|
-
}
|
|
11
|
-
declare abstract class ClientCommand {
|
|
12
|
-
abstract code: ClientCommandCode;
|
|
13
|
-
abstract execute(request: Buffer): Buffer;
|
|
14
|
-
}
|
|
15
|
-
export declare class YieldCommand extends ClientCommand {
|
|
16
|
-
private progressCallback;
|
|
17
|
-
private results;
|
|
18
|
-
code: ClientCommandCode;
|
|
19
|
-
constructor(results: Buffer[], progressCallback: () => void);
|
|
20
|
-
execute(request: Buffer): Buffer;
|
|
21
|
-
}
|
|
22
|
-
export declare class GetPreimageCommand extends ClientCommand {
|
|
23
|
-
private known_preimages;
|
|
24
|
-
private queue;
|
|
25
|
-
code: ClientCommandCode;
|
|
26
|
-
constructor(known_preimages: Map<string, Buffer>, queue: Buffer[]);
|
|
27
|
-
execute(request: Buffer): Buffer;
|
|
28
|
-
}
|
|
29
|
-
export declare class GetMerkleLeafProofCommand extends ClientCommand {
|
|
30
|
-
private known_trees;
|
|
31
|
-
private queue;
|
|
32
|
-
code: ClientCommandCode;
|
|
33
|
-
constructor(known_trees: Map<string, Merkle>, queue: Buffer[]);
|
|
34
|
-
execute(request: Buffer): Buffer;
|
|
35
|
-
}
|
|
36
|
-
export declare class GetMerkleLeafIndexCommand extends ClientCommand {
|
|
37
|
-
private known_trees;
|
|
38
|
-
code: ClientCommandCode;
|
|
39
|
-
constructor(known_trees: Map<string, Merkle>);
|
|
40
|
-
execute(request: Buffer): Buffer;
|
|
41
|
-
}
|
|
42
|
-
export declare class GetMoreElementsCommand extends ClientCommand {
|
|
43
|
-
queue: Buffer[];
|
|
44
|
-
code: ClientCommandCode;
|
|
45
|
-
constructor(queue: Buffer[]);
|
|
46
|
-
execute(request: Buffer): Buffer;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* This class will dispatch a client command coming from the hardware device to
|
|
50
|
-
* the appropriate client command implementation. Those client commands
|
|
51
|
-
* typically requests data from a merkle tree or merkelized maps.
|
|
52
|
-
*
|
|
53
|
-
* A ClientCommandInterpreter is prepared by adding the merkle trees and
|
|
54
|
-
* merkelized maps it should be able to serve to the hardware device. This class
|
|
55
|
-
* doesn't know anything about the semantics of the data it holds, it just
|
|
56
|
-
* serves merkle data. It doesn't even know in what context it is being
|
|
57
|
-
* executed, ie SignPsbt, getWalletAddress, etc.
|
|
58
|
-
*
|
|
59
|
-
* If the command yelds results to the client, as signPsbt does, the yielded
|
|
60
|
-
* data will be accessible after the command completed by calling getYielded(),
|
|
61
|
-
* which will return the yields in the same order as they came in.
|
|
62
|
-
*/
|
|
63
|
-
export declare class ClientCommandInterpreter {
|
|
64
|
-
private roots;
|
|
65
|
-
private preimages;
|
|
66
|
-
private yielded;
|
|
67
|
-
private queue;
|
|
68
|
-
private commands;
|
|
69
|
-
constructor(progressCallback: () => void);
|
|
70
|
-
getYielded(): Buffer[];
|
|
71
|
-
addKnownPreimage(preimage: Buffer): void;
|
|
72
|
-
addKnownList(elements: Buffer[]): void;
|
|
73
|
-
addKnownMapping(mm: MerkleMap): void;
|
|
74
|
-
execute(request: Buffer): Buffer;
|
|
75
|
-
}
|
|
76
|
-
export {};
|
|
77
|
-
//# sourceMappingURL=clientCommands.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clientCommands.d.ts","sourceRoot":"","sources":["../../src/newops/clientCommands.ts"],"names":[],"mappings":";AAGA,OAAO,EAAY,MAAM,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,aAAK,iBAAiB;IACpB,KAAK,KAAO;IACZ,YAAY,KAAO;IACnB,qBAAqB,KAAO;IAC5B,qBAAqB,KAAO;IAC5B,iBAAiB,MAAO;CACzB;AAED,uBAAe,aAAa;IAC1B,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;I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AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,KAAK,CAAkC;IAC/C,OAAO,CAAC,SAAS,CAAkC;IAEnD,OAAO,CAAC,OAAO,CAAgB;IAE/B,OAAO,CAAC,KAAK,CAAgB;IAE7B,OAAO,CAAC,QAAQ,CAAoD;gBAExD,gBAAgB,EAAE,MAAM,IAAI;IAiBxC,UAAU,IAAI,MAAM,EAAE;IAItB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAIxC,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI;IAStC,eAAe,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI;IAKpC,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;CAajC"}
|
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
|
2
|
-
var extendStatics = function (d, b) {
|
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
-
return extendStatics(d, b);
|
|
7
|
-
};
|
|
8
|
-
return function (d, b) {
|
|
9
|
-
if (typeof b !== "function" && b !== null)
|
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
-
extendStatics(d, b);
|
|
12
|
-
function __() { this.constructor = d; }
|
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
-
};
|
|
15
|
-
})();
|
|
16
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
17
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
18
|
-
if (!m) return o;
|
|
19
|
-
var i = m.call(o), r, ar = [], e;
|
|
20
|
-
try {
|
|
21
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
22
|
-
}
|
|
23
|
-
catch (error) { e = { error: error }; }
|
|
24
|
-
finally {
|
|
25
|
-
try {
|
|
26
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
27
|
-
}
|
|
28
|
-
finally { if (e) throw e.error; }
|
|
29
|
-
}
|
|
30
|
-
return ar;
|
|
31
|
-
};
|
|
32
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
33
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
34
|
-
if (ar || !(i in from)) {
|
|
35
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
36
|
-
ar[i] = from[i];
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
40
|
-
};
|
|
41
|
-
var __values = (this && this.__values) || function(o) {
|
|
42
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
43
|
-
if (m) return m.call(o);
|
|
44
|
-
if (o && typeof o.length === "number") return {
|
|
45
|
-
next: function () {
|
|
46
|
-
if (o && i >= o.length) o = void 0;
|
|
47
|
-
return { value: o && o[i++], done: !o };
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
51
|
-
};
|
|
52
|
-
import { crypto } from "bitcoinjs-lib";
|
|
53
|
-
import { BufferReader } from "../buffertools";
|
|
54
|
-
import { createVarint } from "../varint";
|
|
55
|
-
import { hashLeaf, Merkle } from "./merkle";
|
|
56
|
-
var ClientCommandCode;
|
|
57
|
-
(function (ClientCommandCode) {
|
|
58
|
-
ClientCommandCode[ClientCommandCode["YIELD"] = 16] = "YIELD";
|
|
59
|
-
ClientCommandCode[ClientCommandCode["GET_PREIMAGE"] = 64] = "GET_PREIMAGE";
|
|
60
|
-
ClientCommandCode[ClientCommandCode["GET_MERKLE_LEAF_PROOF"] = 65] = "GET_MERKLE_LEAF_PROOF";
|
|
61
|
-
ClientCommandCode[ClientCommandCode["GET_MERKLE_LEAF_INDEX"] = 66] = "GET_MERKLE_LEAF_INDEX";
|
|
62
|
-
ClientCommandCode[ClientCommandCode["GET_MORE_ELEMENTS"] = 160] = "GET_MORE_ELEMENTS";
|
|
63
|
-
})(ClientCommandCode || (ClientCommandCode = {}));
|
|
64
|
-
var ClientCommand = /** @class */ (function () {
|
|
65
|
-
function ClientCommand() {
|
|
66
|
-
}
|
|
67
|
-
return ClientCommand;
|
|
68
|
-
}());
|
|
69
|
-
var YieldCommand = /** @class */ (function (_super) {
|
|
70
|
-
__extends(YieldCommand, _super);
|
|
71
|
-
function YieldCommand(results, progressCallback) {
|
|
72
|
-
var _this = _super.call(this) || this;
|
|
73
|
-
_this.progressCallback = progressCallback;
|
|
74
|
-
_this.code = ClientCommandCode.YIELD;
|
|
75
|
-
_this.results = results;
|
|
76
|
-
return _this;
|
|
77
|
-
}
|
|
78
|
-
YieldCommand.prototype.execute = function (request) {
|
|
79
|
-
this.results.push(Buffer.from(request.subarray(1)));
|
|
80
|
-
this.progressCallback();
|
|
81
|
-
return Buffer.from("");
|
|
82
|
-
};
|
|
83
|
-
return YieldCommand;
|
|
84
|
-
}(ClientCommand));
|
|
85
|
-
export { YieldCommand };
|
|
86
|
-
var GetPreimageCommand = /** @class */ (function (_super) {
|
|
87
|
-
__extends(GetPreimageCommand, _super);
|
|
88
|
-
function GetPreimageCommand(known_preimages, queue) {
|
|
89
|
-
var _this = _super.call(this) || this;
|
|
90
|
-
_this.code = ClientCommandCode.GET_PREIMAGE;
|
|
91
|
-
_this.known_preimages = known_preimages;
|
|
92
|
-
_this.queue = queue;
|
|
93
|
-
return _this;
|
|
94
|
-
}
|
|
95
|
-
GetPreimageCommand.prototype.execute = function (request) {
|
|
96
|
-
var req = Buffer.from(request.subarray(1));
|
|
97
|
-
// we expect no more data to read
|
|
98
|
-
if (req.length != 1 + 32) {
|
|
99
|
-
throw new Error("Invalid request, unexpected trailing data");
|
|
100
|
-
}
|
|
101
|
-
if (req[0] != 0) {
|
|
102
|
-
throw new Error("Unsupported request, the first byte should be 0");
|
|
103
|
-
}
|
|
104
|
-
// read the hash
|
|
105
|
-
var hash = Buffer.alloc(32);
|
|
106
|
-
for (var i = 0; i < 32; i++) {
|
|
107
|
-
hash[i] = req[1 + i];
|
|
108
|
-
}
|
|
109
|
-
var req_hash_hex = hash.toString("hex");
|
|
110
|
-
var known_preimage = this.known_preimages.get(req_hash_hex);
|
|
111
|
-
if (known_preimage != undefined) {
|
|
112
|
-
var preimage_len_varint = createVarint(known_preimage.length);
|
|
113
|
-
// We can send at most 255 - len(preimage_len_out) - 1 bytes in a single message;
|
|
114
|
-
// the rest will be stored in the queue for GET_MORE_ELEMENTS
|
|
115
|
-
var max_payload_size = 255 - preimage_len_varint.length - 1;
|
|
116
|
-
var payload_size = Math.min(max_payload_size, known_preimage.length);
|
|
117
|
-
if (payload_size < known_preimage.length) {
|
|
118
|
-
for (var i = payload_size; i < known_preimage.length; i++) {
|
|
119
|
-
this.queue.push(Buffer.from([known_preimage[i]]));
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return Buffer.concat([
|
|
123
|
-
preimage_len_varint,
|
|
124
|
-
Buffer.from([payload_size]),
|
|
125
|
-
Buffer.from(known_preimage.subarray(0, payload_size)),
|
|
126
|
-
]);
|
|
127
|
-
}
|
|
128
|
-
throw Error("Requested unknown preimage for: ".concat(req_hash_hex));
|
|
129
|
-
};
|
|
130
|
-
return GetPreimageCommand;
|
|
131
|
-
}(ClientCommand));
|
|
132
|
-
export { GetPreimageCommand };
|
|
133
|
-
var GetMerkleLeafProofCommand = /** @class */ (function (_super) {
|
|
134
|
-
__extends(GetMerkleLeafProofCommand, _super);
|
|
135
|
-
function GetMerkleLeafProofCommand(known_trees, queue) {
|
|
136
|
-
var _this = _super.call(this) || this;
|
|
137
|
-
_this.code = ClientCommandCode.GET_MERKLE_LEAF_PROOF;
|
|
138
|
-
_this.known_trees = known_trees;
|
|
139
|
-
_this.queue = queue;
|
|
140
|
-
return _this;
|
|
141
|
-
}
|
|
142
|
-
GetMerkleLeafProofCommand.prototype.execute = function (request) {
|
|
143
|
-
var _a;
|
|
144
|
-
var req = Buffer.from(request.subarray(1));
|
|
145
|
-
if (req.length < 32 + 1 + 1) {
|
|
146
|
-
throw new Error("Invalid request, expected at least 34 bytes");
|
|
147
|
-
}
|
|
148
|
-
var reqBuf = new BufferReader(req);
|
|
149
|
-
var hash = reqBuf.readSlice(32);
|
|
150
|
-
var hash_hex = hash.toString("hex");
|
|
151
|
-
var tree_size;
|
|
152
|
-
var leaf_index;
|
|
153
|
-
try {
|
|
154
|
-
tree_size = reqBuf.readVarInt();
|
|
155
|
-
leaf_index = reqBuf.readVarInt();
|
|
156
|
-
}
|
|
157
|
-
catch (e) {
|
|
158
|
-
throw new Error("Invalid request, couldn't parse tree_size or leaf_index");
|
|
159
|
-
}
|
|
160
|
-
var mt = this.known_trees.get(hash_hex);
|
|
161
|
-
if (!mt) {
|
|
162
|
-
throw Error("Requested Merkle leaf proof for unknown tree: ".concat(hash_hex));
|
|
163
|
-
}
|
|
164
|
-
if (leaf_index >= tree_size || mt.size() != tree_size) {
|
|
165
|
-
throw Error("Invalid index or tree size.");
|
|
166
|
-
}
|
|
167
|
-
if (this.queue.length != 0) {
|
|
168
|
-
throw Error("This command should not execute when the queue is not empty.");
|
|
169
|
-
}
|
|
170
|
-
var proof = mt.getProof(leaf_index);
|
|
171
|
-
var n_response_elements = Math.min(Math.floor((255 - 32 - 1 - 1) / 32), proof.length);
|
|
172
|
-
var n_leftover_elements = proof.length - n_response_elements;
|
|
173
|
-
// Add to the queue any proof elements that do not fit the response
|
|
174
|
-
if (n_leftover_elements > 0) {
|
|
175
|
-
(_a = this.queue).push.apply(_a, __spreadArray([], __read(proof.slice(-n_leftover_elements)), false));
|
|
176
|
-
}
|
|
177
|
-
return Buffer.concat(__spreadArray([
|
|
178
|
-
mt.getLeafHash(leaf_index),
|
|
179
|
-
Buffer.from([proof.length]),
|
|
180
|
-
Buffer.from([n_response_elements])
|
|
181
|
-
], __read(proof.slice(0, n_response_elements)), false));
|
|
182
|
-
};
|
|
183
|
-
return GetMerkleLeafProofCommand;
|
|
184
|
-
}(ClientCommand));
|
|
185
|
-
export { GetMerkleLeafProofCommand };
|
|
186
|
-
var GetMerkleLeafIndexCommand = /** @class */ (function (_super) {
|
|
187
|
-
__extends(GetMerkleLeafIndexCommand, _super);
|
|
188
|
-
function GetMerkleLeafIndexCommand(known_trees) {
|
|
189
|
-
var _this = _super.call(this) || this;
|
|
190
|
-
_this.code = ClientCommandCode.GET_MERKLE_LEAF_INDEX;
|
|
191
|
-
_this.known_trees = known_trees;
|
|
192
|
-
return _this;
|
|
193
|
-
}
|
|
194
|
-
GetMerkleLeafIndexCommand.prototype.execute = function (request) {
|
|
195
|
-
var req = Buffer.from(request.subarray(1));
|
|
196
|
-
if (req.length != 32 + 32) {
|
|
197
|
-
throw new Error("Invalid request, unexpected trailing data");
|
|
198
|
-
}
|
|
199
|
-
// read the root hash
|
|
200
|
-
var root_hash = Buffer.alloc(32);
|
|
201
|
-
for (var i = 0; i < 32; i++) {
|
|
202
|
-
root_hash[i] = req.readUInt8(i);
|
|
203
|
-
}
|
|
204
|
-
var root_hash_hex = root_hash.toString("hex");
|
|
205
|
-
// read the leaf hash
|
|
206
|
-
var leef_hash = Buffer.alloc(32);
|
|
207
|
-
for (var i = 0; i < 32; i++) {
|
|
208
|
-
leef_hash[i] = req.readUInt8(32 + i);
|
|
209
|
-
}
|
|
210
|
-
var leef_hash_hex = leef_hash.toString("hex");
|
|
211
|
-
var mt = this.known_trees.get(root_hash_hex);
|
|
212
|
-
if (!mt) {
|
|
213
|
-
throw Error("Requested Merkle leaf index for unknown root: ".concat(root_hash_hex));
|
|
214
|
-
}
|
|
215
|
-
var leaf_index = 0;
|
|
216
|
-
var found = 0;
|
|
217
|
-
for (var i = 0; i < mt.size(); i++) {
|
|
218
|
-
if (mt.getLeafHash(i).toString("hex") == leef_hash_hex) {
|
|
219
|
-
found = 1;
|
|
220
|
-
leaf_index = i;
|
|
221
|
-
break;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
return Buffer.concat([Buffer.from([found]), createVarint(leaf_index)]);
|
|
225
|
-
};
|
|
226
|
-
return GetMerkleLeafIndexCommand;
|
|
227
|
-
}(ClientCommand));
|
|
228
|
-
export { GetMerkleLeafIndexCommand };
|
|
229
|
-
var GetMoreElementsCommand = /** @class */ (function (_super) {
|
|
230
|
-
__extends(GetMoreElementsCommand, _super);
|
|
231
|
-
function GetMoreElementsCommand(queue) {
|
|
232
|
-
var _this = _super.call(this) || this;
|
|
233
|
-
_this.code = ClientCommandCode.GET_MORE_ELEMENTS;
|
|
234
|
-
_this.queue = queue;
|
|
235
|
-
return _this;
|
|
236
|
-
}
|
|
237
|
-
GetMoreElementsCommand.prototype.execute = function (request) {
|
|
238
|
-
if (request.length != 1) {
|
|
239
|
-
throw new Error("Invalid request, unexpected trailing data");
|
|
240
|
-
}
|
|
241
|
-
if (this.queue.length === 0) {
|
|
242
|
-
throw new Error("No elements to get");
|
|
243
|
-
}
|
|
244
|
-
// all elements should have the same length
|
|
245
|
-
var element_len = this.queue[0].length;
|
|
246
|
-
if (this.queue.some(function (el) { return el.length != element_len; })) {
|
|
247
|
-
throw new Error("The queue contains elements with different byte length, which is not expected");
|
|
248
|
-
}
|
|
249
|
-
var max_elements = Math.floor(253 / element_len);
|
|
250
|
-
var n_returned_elements = Math.min(max_elements, this.queue.length);
|
|
251
|
-
var returned_elements = this.queue.splice(0, n_returned_elements);
|
|
252
|
-
return Buffer.concat(__spreadArray([
|
|
253
|
-
Buffer.from([n_returned_elements]),
|
|
254
|
-
Buffer.from([element_len])
|
|
255
|
-
], __read(returned_elements), false));
|
|
256
|
-
};
|
|
257
|
-
return GetMoreElementsCommand;
|
|
258
|
-
}(ClientCommand));
|
|
259
|
-
export { GetMoreElementsCommand };
|
|
260
|
-
/**
|
|
261
|
-
* This class will dispatch a client command coming from the hardware device to
|
|
262
|
-
* the appropriate client command implementation. Those client commands
|
|
263
|
-
* typically requests data from a merkle tree or merkelized maps.
|
|
264
|
-
*
|
|
265
|
-
* A ClientCommandInterpreter is prepared by adding the merkle trees and
|
|
266
|
-
* merkelized maps it should be able to serve to the hardware device. This class
|
|
267
|
-
* doesn't know anything about the semantics of the data it holds, it just
|
|
268
|
-
* serves merkle data. It doesn't even know in what context it is being
|
|
269
|
-
* executed, ie SignPsbt, getWalletAddress, etc.
|
|
270
|
-
*
|
|
271
|
-
* If the command yelds results to the client, as signPsbt does, the yielded
|
|
272
|
-
* data will be accessible after the command completed by calling getYielded(),
|
|
273
|
-
* which will return the yields in the same order as they came in.
|
|
274
|
-
*/
|
|
275
|
-
var ClientCommandInterpreter = /** @class */ (function () {
|
|
276
|
-
function ClientCommandInterpreter(progressCallback) {
|
|
277
|
-
var e_1, _a;
|
|
278
|
-
this.roots = new Map();
|
|
279
|
-
this.preimages = new Map();
|
|
280
|
-
this.yielded = [];
|
|
281
|
-
this.queue = [];
|
|
282
|
-
this.commands = new Map();
|
|
283
|
-
var commands = [
|
|
284
|
-
new YieldCommand(this.yielded, progressCallback),
|
|
285
|
-
new GetPreimageCommand(this.preimages, this.queue),
|
|
286
|
-
new GetMerkleLeafIndexCommand(this.roots),
|
|
287
|
-
new GetMerkleLeafProofCommand(this.roots, this.queue),
|
|
288
|
-
new GetMoreElementsCommand(this.queue),
|
|
289
|
-
];
|
|
290
|
-
try {
|
|
291
|
-
for (var commands_1 = __values(commands), commands_1_1 = commands_1.next(); !commands_1_1.done; commands_1_1 = commands_1.next()) {
|
|
292
|
-
var cmd = commands_1_1.value;
|
|
293
|
-
if (this.commands.has(cmd.code)) {
|
|
294
|
-
throw new Error("Multiple commands with code ".concat(cmd.code));
|
|
295
|
-
}
|
|
296
|
-
this.commands.set(cmd.code, cmd);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
300
|
-
finally {
|
|
301
|
-
try {
|
|
302
|
-
if (commands_1_1 && !commands_1_1.done && (_a = commands_1["return"])) _a.call(commands_1);
|
|
303
|
-
}
|
|
304
|
-
finally { if (e_1) throw e_1.error; }
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
ClientCommandInterpreter.prototype.getYielded = function () {
|
|
308
|
-
return this.yielded;
|
|
309
|
-
};
|
|
310
|
-
ClientCommandInterpreter.prototype.addKnownPreimage = function (preimage) {
|
|
311
|
-
this.preimages.set(crypto.sha256(preimage).toString("hex"), preimage);
|
|
312
|
-
};
|
|
313
|
-
ClientCommandInterpreter.prototype.addKnownList = function (elements) {
|
|
314
|
-
var e_2, _a;
|
|
315
|
-
try {
|
|
316
|
-
for (var elements_1 = __values(elements), elements_1_1 = elements_1.next(); !elements_1_1.done; elements_1_1 = elements_1.next()) {
|
|
317
|
-
var el = elements_1_1.value;
|
|
318
|
-
var preimage = Buffer.concat([Buffer.from([0]), el]);
|
|
319
|
-
this.addKnownPreimage(preimage);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
323
|
-
finally {
|
|
324
|
-
try {
|
|
325
|
-
if (elements_1_1 && !elements_1_1.done && (_a = elements_1["return"])) _a.call(elements_1);
|
|
326
|
-
}
|
|
327
|
-
finally { if (e_2) throw e_2.error; }
|
|
328
|
-
}
|
|
329
|
-
var mt = new Merkle(elements.map(function (el) { return hashLeaf(el); }));
|
|
330
|
-
this.roots.set(mt.getRoot().toString("hex"), mt);
|
|
331
|
-
};
|
|
332
|
-
ClientCommandInterpreter.prototype.addKnownMapping = function (mm) {
|
|
333
|
-
this.addKnownList(mm.keys);
|
|
334
|
-
this.addKnownList(mm.values);
|
|
335
|
-
};
|
|
336
|
-
ClientCommandInterpreter.prototype.execute = function (request) {
|
|
337
|
-
if (request.length == 0) {
|
|
338
|
-
throw new Error("Unexpected empty command");
|
|
339
|
-
}
|
|
340
|
-
var cmdCode = request[0];
|
|
341
|
-
var cmd = this.commands.get(cmdCode);
|
|
342
|
-
if (!cmd) {
|
|
343
|
-
throw new Error("Unexpected command code ".concat(cmdCode));
|
|
344
|
-
}
|
|
345
|
-
return cmd.execute(request);
|
|
346
|
-
};
|
|
347
|
-
return ClientCommandInterpreter;
|
|
348
|
-
}());
|
|
349
|
-
export { ClientCommandInterpreter };
|
|
350
|
-
//# sourceMappingURL=clientCommands.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clientCommands.js","sourceRoot":"","sources":["../../src/newops/clientCommands.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAG5C,IAAK,iBAMJ;AAND,WAAK,iBAAiB;IACpB,4DAAY,CAAA;IACZ,0EAAmB,CAAA;IACnB,4FAA4B,CAAA;IAC5B,4FAA4B,CAAA;IAC5B,qFAAwB,CAAA;AAC1B,CAAC,EANI,iBAAiB,KAAjB,iBAAiB,QAMrB;AAED;IAAA;IAGA,CAAC;IAAD,oBAAC;AAAD,CAAC,AAHD,IAGC;AAED;IAAkC,gCAAa;IAK7C,sBAAY,OAAiB,EAAU,gBAA4B;QAAnE,YACE,iBAAO,SAER;QAHsC,sBAAgB,GAAhB,gBAAgB,CAAY;QAFnE,UAAI,GAAG,iBAAiB,CAAC,KAAK,CAAC;QAI7B,KAAI,CAAC,OAAO,GAAG,OAAO,CAAC;;IACzB,CAAC;IAED,8BAAO,GAAP,UAAQ,OAAe;QACrB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM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from "./psbtv2";
|
|
4
|
-
/**
|
|
5
|
-
* This class merkelizes a PSBTv2, by merkelizing the different
|
|
6
|
-
* maps of the psbt. This is used during the transaction signing process,
|
|
7
|
-
* where the hardware app can request specific parts of the psbt from the
|
|
8
|
-
* client code and be sure that the response data actually belong to the psbt.
|
|
9
|
-
* The reason for this is the limited amount of memory available to the app,
|
|
10
|
-
* so it can't always store the full psbt in memory.
|
|
11
|
-
*
|
|
12
|
-
* The signing process is documented at
|
|
13
|
-
* https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md#sign_psbt
|
|
14
|
-
*/
|
|
15
|
-
export declare class MerkelizedPsbt extends PsbtV2 {
|
|
16
|
-
globalMerkleMap: MerkleMap;
|
|
17
|
-
inputMerkleMaps: MerkleMap[];
|
|
18
|
-
outputMerkleMaps: MerkleMap[];
|
|
19
|
-
inputMapCommitments: Buffer[];
|
|
20
|
-
outputMapCommitments: Buffer[];
|
|
21
|
-
constructor(psbt: PsbtV2);
|
|
22
|
-
getGlobalSize(): number;
|
|
23
|
-
getGlobalKeysValuesRoot(): Buffer;
|
|
24
|
-
private static createMerkleMap;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=merkelizedPsbt.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merkelizedPsbt.d.ts","sourceRoot":"","sources":["../../src/newops/merkelizedPsbt.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;;;;;;;;GAUG;AACH,qBAAa,cAAe,SAAQ,MAAM;IACjC,eAAe,EAAE,SAAS,CAAC;IAC3B,eAAe,EAAE,SAAS,EAAE,CAAM;IAClC,gBAAgB,EAAE,SAAS,EAAE,CAAM;IACnC,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,oBAAoB,EAAE,MAAM,EAAE,CAAC;gBAC1B,IAAI,EAAE,MAAM;IAwBxB,aAAa,IAAI,MAAM;IAGvB,uBAAuB,IAAI,MAAM;IAIjC,OAAO,CAAC,MAAM,CAAC,eAAe;CAc/B"}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
|
2
|
-
var extendStatics = function (d, b) {
|
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
-
return extendStatics(d, b);
|
|
7
|
-
};
|
|
8
|
-
return function (d, b) {
|
|
9
|
-
if (typeof b !== "function" && b !== null)
|
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
-
extendStatics(d, b);
|
|
12
|
-
function __() { this.constructor = d; }
|
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
-
};
|
|
15
|
-
})();
|
|
16
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
17
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
18
|
-
if (!m) return o;
|
|
19
|
-
var i = m.call(o), r, ar = [], e;
|
|
20
|
-
try {
|
|
21
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
22
|
-
}
|
|
23
|
-
catch (error) { e = { error: error }; }
|
|
24
|
-
finally {
|
|
25
|
-
try {
|
|
26
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
27
|
-
}
|
|
28
|
-
finally { if (e) throw e.error; }
|
|
29
|
-
}
|
|
30
|
-
return ar;
|
|
31
|
-
};
|
|
32
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
33
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
34
|
-
if (ar || !(i in from)) {
|
|
35
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
36
|
-
ar[i] = from[i];
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
40
|
-
};
|
|
41
|
-
import { MerkleMap } from "./merkleMap";
|
|
42
|
-
import { PsbtV2 } from "./psbtv2";
|
|
43
|
-
/**
|
|
44
|
-
* This class merkelizes a PSBTv2, by merkelizing the different
|
|
45
|
-
* maps of the psbt. This is used during the transaction signing process,
|
|
46
|
-
* where the hardware app can request specific parts of the psbt from the
|
|
47
|
-
* client code and be sure that the response data actually belong to the psbt.
|
|
48
|
-
* The reason for this is the limited amount of memory available to the app,
|
|
49
|
-
* so it can't always store the full psbt in memory.
|
|
50
|
-
*
|
|
51
|
-
* The signing process is documented at
|
|
52
|
-
* https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/bitcoin.md#sign_psbt
|
|
53
|
-
*/
|
|
54
|
-
var MerkelizedPsbt = /** @class */ (function (_super) {
|
|
55
|
-
__extends(MerkelizedPsbt, _super);
|
|
56
|
-
function MerkelizedPsbt(psbt) {
|
|
57
|
-
var _this = _super.call(this) || this;
|
|
58
|
-
_this.inputMerkleMaps = [];
|
|
59
|
-
_this.outputMerkleMaps = [];
|
|
60
|
-
psbt.copy(_this);
|
|
61
|
-
_this.globalMerkleMap = MerkelizedPsbt.createMerkleMap(_this.globalMap);
|
|
62
|
-
for (var i = 0; i < _this.getGlobalInputCount(); i++) {
|
|
63
|
-
_this.inputMerkleMaps.push(MerkelizedPsbt.createMerkleMap(_this.inputMaps[i]));
|
|
64
|
-
}
|
|
65
|
-
_this.inputMapCommitments = __spreadArray([], __read(_this.inputMerkleMaps.values()), false).map(function (v) {
|
|
66
|
-
return v.commitment();
|
|
67
|
-
});
|
|
68
|
-
for (var i = 0; i < _this.getGlobalOutputCount(); i++) {
|
|
69
|
-
_this.outputMerkleMaps.push(MerkelizedPsbt.createMerkleMap(_this.outputMaps[i]));
|
|
70
|
-
}
|
|
71
|
-
_this.outputMapCommitments = __spreadArray([], __read(_this.outputMerkleMaps.values()), false).map(function (v) {
|
|
72
|
-
return v.commitment();
|
|
73
|
-
});
|
|
74
|
-
return _this;
|
|
75
|
-
}
|
|
76
|
-
// These public functions are for MerkelizedPsbt.
|
|
77
|
-
MerkelizedPsbt.prototype.getGlobalSize = function () {
|
|
78
|
-
return this.globalMap.size;
|
|
79
|
-
};
|
|
80
|
-
MerkelizedPsbt.prototype.getGlobalKeysValuesRoot = function () {
|
|
81
|
-
return this.globalMerkleMap.commitment();
|
|
82
|
-
};
|
|
83
|
-
MerkelizedPsbt.createMerkleMap = function (map) {
|
|
84
|
-
var sortedKeysStrings = __spreadArray([], __read(map.keys()), false).sort();
|
|
85
|
-
var values = sortedKeysStrings.map(function (k) {
|
|
86
|
-
var v = map.get(k);
|
|
87
|
-
if (!v) {
|
|
88
|
-
throw new Error("No value for key " + k);
|
|
89
|
-
}
|
|
90
|
-
return v;
|
|
91
|
-
});
|
|
92
|
-
var sortedKeys = sortedKeysStrings.map(function (k) { return Buffer.from(k, "hex"); });
|
|
93
|
-
var merkleMap = new MerkleMap(sortedKeys, values);
|
|
94
|
-
return merkleMap;
|
|
95
|
-
};
|
|
96
|
-
return MerkelizedPsbt;
|
|
97
|
-
}(PsbtV2));
|
|
98
|
-
export { MerkelizedPsbt };
|
|
99
|
-
//# sourceMappingURL=merkelizedPsbt.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merkelizedPsbt.js","sourceRoot":"","sources":["../../src/newops/merkelizedPsbt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;;;;;;;;GAUG;AACH;IAAoC,kCAAM;IAMxC,wBAAY,IAAY;QAAxB,YACE,iBAAO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rD,IAAM,iBAAiB,GAAG,yBAAI,GAAG,CAAC,IAAI,EAAE,UAAE,IAAI,EAAE,CAAC;QACjD,IAAM,MAAM,GAAG,iBAAiB,CAAC,GAAG,CAAC,UAAC,CAAC;YACrC,IAAM,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACrB,IAAI,CAAC,CAAC,EAAE;gBACN,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,CAAC,CAAC,CAAC;aAC1C;YACD,OAAO,CAAC,CAAC;QACX,CAAC,CAAC,CAAC;QACH,IAAM,UAAU,GAAG,iBAAiB,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,EAArB,CAAqB,CAAC,CAAC;QAEvE,IAAM,SAAS,GAAG,IAAI,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACpD,OAAO,SAAS,CAAC;IACnB,CAAC;IACH,qBAAC;AAAD,CAAC,AAnDD,CAAoC,MAAM,GAmDzC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/**
|
|
3
|
-
* This class implements the merkle tree used by Ledger Bitcoin app v2+,
|
|
4
|
-
* which is documented at
|
|
5
|
-
* https://github.com/LedgerHQ/app-bitcoin-new/blob/master/doc/merkle.md
|
|
6
|
-
*/
|
|
7
|
-
export declare class Merkle {
|
|
8
|
-
private leaves;
|
|
9
|
-
private rootNode;
|
|
10
|
-
private leafNodes;
|
|
11
|
-
private h;
|
|
12
|
-
constructor(leaves: Buffer[], hasher?: (buf: Buffer) => Buffer);
|
|
13
|
-
getRoot(): Buffer;
|
|
14
|
-
size(): number;
|
|
15
|
-
getLeaves(): Buffer[];
|
|
16
|
-
getLeafHash(index: number): Buffer;
|
|
17
|
-
getProof(index: number): Buffer[];
|
|
18
|
-
calculateRoot(leaves: Buffer[]): {
|
|
19
|
-
root: Node;
|
|
20
|
-
leaves: Node[];
|
|
21
|
-
};
|
|
22
|
-
hashNode(left: Buffer, right: Buffer): Buffer;
|
|
23
|
-
}
|
|
24
|
-
export declare function hashLeaf(buf: Buffer, hashFunction?: (buf: Buffer) => Buffer): Buffer;
|
|
25
|
-
declare class Node {
|
|
26
|
-
leftChild?: Node;
|
|
27
|
-
rightChild?: Node;
|
|
28
|
-
parent?: Node;
|
|
29
|
-
hash: Buffer;
|
|
30
|
-
constructor(left: Node | undefined, right: Node | undefined, hash: Buffer);
|
|
31
|
-
isLeaf(): boolean;
|
|
32
|
-
}
|
|
33
|
-
export {};
|
|
34
|
-
//# sourceMappingURL=merkle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merkle.d.ts","sourceRoot":"","sources":["../../src/newops/merkle.ts"],"names":[],"mappings":";AAEA;;;;GAIG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAW;IACzB,OAAO,CAAC,QAAQ,CAAO;IACvB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,CAAC,CAA0B;gBAEjC,MAAM,EAAE,MAAM,EAAE,EAChB,MAAM,GAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAsB;IAQjD,OAAO,IAAI,MAAM;IAGjB,IAAI,IAAI,MAAM;IAGd,SAAS,IAAI,MAAM,EAAE;IAGrB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAGlC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAKjC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG;QAAE,IAAI,EAAE,IAAI,CAAC;QAAC,MAAM,EAAE,IAAI,EAAE,CAAA;KAAE;IAwB/D,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;CAG9C;AAED,wBAAgB,QAAQ,CACtB,GAAG,EAAE,MAAM,EACX,YAAY,GAAE,CAAC,GAAG,EAA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