@ledgerhq/hw-app-btc 10.0.1-recover-beta.0 → 10.0.2-nightly.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +16 -2
- package/lib/Btc.js +72 -136
- package/lib/Btc.js.map +1 -1
- package/lib/BtcNew.js +217 -313
- package/lib/BtcNew.js.map +1 -1
- package/lib/BtcOld.js +46 -106
- package/lib/BtcOld.js.map +1 -1
- package/lib/bip32.js +12 -12
- package/lib/bip32.js.map +1 -1
- package/lib/buffertools.js +66 -69
- package/lib/buffertools.js.map +1 -1
- package/lib/compressPublicKey.js +3 -3
- package/lib/compressPublicKey.js.map +1 -1
- package/lib/constants.js +1 -1
- package/lib/createTransaction.d.ts +1 -1
- package/lib/createTransaction.d.ts.map +1 -1
- package/lib/createTransaction.js +285 -398
- package/lib/createTransaction.js.map +1 -1
- package/lib/debug.js +11 -13
- package/lib/debug.js.map +1 -1
- package/lib/finalizeInput.js +23 -62
- package/lib/finalizeInput.js.map +1 -1
- package/lib/getAppAndVersion.d.ts +1 -1
- package/lib/getAppAndVersion.d.ts.map +1 -1
- package/lib/getAppAndVersion.js +29 -72
- package/lib/getAppAndVersion.js.map +1 -1
- package/lib/getTrustedInput.js +108 -251
- package/lib/getTrustedInput.js.map +1 -1
- package/lib/getTrustedInputBIP143.js +9 -10
- package/lib/getTrustedInputBIP143.js.map +1 -1
- package/lib/getWalletPublicKey.d.ts +1 -1
- package/lib/getWalletPublicKey.d.ts.map +1 -1
- package/lib/getWalletPublicKey.js +27 -73
- package/lib/getWalletPublicKey.js.map +1 -1
- package/lib/hashPublicKey.js +4 -4
- package/lib/hashPublicKey.js.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/newops/accounttype.d.ts +2 -2
- package/lib/newops/accounttype.d.ts.map +1 -1
- package/lib/newops/accounttype.js +85 -125
- package/lib/newops/accounttype.js.map +1 -1
- package/lib/newops/appClient.js +98 -205
- package/lib/newops/appClient.js.map +1 -1
- package/lib/newops/clientCommands.js +122 -213
- package/lib/newops/clientCommands.js.map +1 -1
- package/lib/newops/merkelizedPsbt.js +28 -75
- package/lib/newops/merkelizedPsbt.js.map +1 -1
- package/lib/newops/merkle.js +38 -67
- package/lib/newops/merkle.js.map +1 -1
- package/lib/newops/merkleMap.js +11 -12
- package/lib/newops/merkleMap.js.map +1 -1
- package/lib/newops/policy.d.ts +1 -1
- package/lib/newops/policy.d.ts.map +1 -1
- package/lib/newops/policy.js +17 -18
- package/lib/newops/policy.js.map +1 -1
- package/lib/newops/psbtExtractor.js +9 -9
- package/lib/newops/psbtExtractor.js.map +1 -1
- package/lib/newops/psbtFinalizer.js +22 -22
- package/lib/newops/psbtFinalizer.js.map +1 -1
- package/lib/newops/psbtv2.d.ts +1 -1
- package/lib/newops/psbtv2.d.ts.map +1 -1
- package/lib/newops/psbtv2.js +227 -286
- package/lib/newops/psbtv2.js.map +1 -1
- package/lib/serializeTransaction.js +13 -15
- package/lib/serializeTransaction.js.map +1 -1
- package/lib/shouldUseTrustedInputForSegwit.js +4 -5
- package/lib/shouldUseTrustedInputForSegwit.js.map +1 -1
- package/lib/signMessage.js +47 -99
- package/lib/signMessage.js.map +1 -1
- package/lib/signP2SHTransaction.d.ts +1 -1
- package/lib/signP2SHTransaction.d.ts.map +1 -1
- package/lib/signP2SHTransaction.js +91 -187
- package/lib/signP2SHTransaction.js.map +1 -1
- package/lib/signTransaction.js +8 -9
- package/lib/signTransaction.js.map +1 -1
- package/lib/splitTransaction.js +50 -54
- package/lib/splitTransaction.js.map +1 -1
- package/lib/startUntrustedHashTransactionInput.js +65 -167
- package/lib/startUntrustedHashTransactionInput.js.map +1 -1
- package/lib/types.js +1 -1
- package/lib/varint.js +10 -10
- package/lib/varint.js.map +1 -1
- package/lib-es/Btc.js +58 -123
- package/lib-es/Btc.js.map +1 -1
- package/lib-es/BtcNew.js +205 -302
- package/lib-es/BtcNew.js.map +1 -1
- package/lib-es/BtcOld.js +35 -96
- package/lib-es/BtcOld.js.map +1 -1
- package/lib-es/bip32.js +7 -7
- package/lib-es/bip32.js.map +1 -1
- package/lib-es/buffertools.js +62 -67
- package/lib-es/buffertools.js.map +1 -1
- package/lib-es/compressPublicKey.js +2 -2
- package/lib-es/compressPublicKey.js.map +1 -1
- package/lib-es/constants.js +12 -12
- package/lib-es/constants.js.map +1 -1
- package/lib-es/createTransaction.d.ts +1 -1
- package/lib-es/createTransaction.d.ts.map +1 -1
- package/lib-es/createTransaction.js +271 -384
- package/lib-es/createTransaction.js.map +1 -1
- package/lib-es/debug.js +10 -12
- package/lib-es/debug.js.map +1 -1
- package/lib-es/finalizeInput.js +20 -59
- package/lib-es/finalizeInput.js.map +1 -1
- package/lib-es/getAppAndVersion.d.ts +1 -1
- package/lib-es/getAppAndVersion.d.ts.map +1 -1
- package/lib-es/getAppAndVersion.js +27 -70
- package/lib-es/getAppAndVersion.js.map +1 -1
- package/lib-es/getTrustedInput.js +104 -247
- package/lib-es/getTrustedInput.js.map +1 -1
- package/lib-es/getTrustedInputBIP143.js +5 -6
- package/lib-es/getTrustedInputBIP143.js.map +1 -1
- package/lib-es/getWalletPublicKey.d.ts +1 -1
- package/lib-es/getWalletPublicKey.d.ts.map +1 -1
- package/lib-es/getWalletPublicKey.js +25 -71
- package/lib-es/getWalletPublicKey.js.map +1 -1
- package/lib-es/newops/accounttype.d.ts +2 -2
- package/lib-es/newops/accounttype.d.ts.map +1 -1
- package/lib-es/newops/accounttype.js +79 -123
- package/lib-es/newops/accounttype.js.map +1 -1
- package/lib-es/newops/appClient.js +92 -200
- package/lib-es/newops/appClient.js.map +1 -1
- package/lib-es/newops/clientCommands.js +117 -214
- package/lib-es/newops/clientCommands.js.map +1 -1
- package/lib-es/newops/merkelizedPsbt.js +25 -73
- package/lib-es/newops/merkelizedPsbt.js.map +1 -1
- package/lib-es/newops/merkle.js +36 -66
- package/lib-es/newops/merkle.js.map +1 -1
- package/lib-es/newops/merkleMap.js +8 -10
- package/lib-es/newops/merkleMap.js.map +1 -1
- package/lib-es/newops/policy.d.ts +1 -1
- package/lib-es/newops/policy.d.ts.map +1 -1
- package/lib-es/newops/policy.js +12 -14
- package/lib-es/newops/policy.js.map +1 -1
- package/lib-es/newops/psbtExtractor.js +7 -7
- package/lib-es/newops/psbtExtractor.js.map +1 -1
- package/lib-es/newops/psbtFinalizer.js +19 -19
- package/lib-es/newops/psbtFinalizer.js.map +1 -1
- package/lib-es/newops/psbtv2.d.ts +1 -1
- package/lib-es/newops/psbtv2.d.ts.map +1 -1
- package/lib-es/newops/psbtv2.js +225 -286
- package/lib-es/newops/psbtv2.js.map +1 -1
- package/lib-es/serializeTransaction.js +11 -13
- package/lib-es/serializeTransaction.js.map +1 -1
- package/lib-es/shouldUseTrustedInputForSegwit.js +1 -2
- package/lib-es/shouldUseTrustedInputForSegwit.js.map +1 -1
- package/lib-es/signMessage.js +44 -96
- package/lib-es/signMessage.js.map +1 -1
- package/lib-es/signP2SHTransaction.d.ts +1 -1
- package/lib-es/signP2SHTransaction.d.ts.map +1 -1
- package/lib-es/signP2SHTransaction.js +84 -180
- package/lib-es/signP2SHTransaction.js.map +1 -1
- package/lib-es/signTransaction.js +6 -7
- package/lib-es/signTransaction.js.map +1 -1
- package/lib-es/splitTransaction.js +46 -50
- package/lib-es/splitTransaction.js.map +1 -1
- package/lib-es/startUntrustedHashTransactionInput.js +62 -164
- package/lib-es/startUntrustedHashTransactionInput.js.map +1 -1
- package/lib-es/varint.js +9 -9
- package/lib-es/varint.js.map +1 -1
- package/package.json +5 -6
|
@@ -8,53 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __values = (this && this.__values) || function(o) {
|
|
39
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
-
if (m) return m.call(o);
|
|
41
|
-
if (o && typeof o.length === "number") return {
|
|
42
|
-
next: function () {
|
|
43
|
-
if (o && i >= o.length) o = void 0;
|
|
44
|
-
return { value: o && o[i++], done: !o };
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
-
};
|
|
49
|
-
exports.__esModule = true;
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
12
|
exports.startUntrustedHashTransactionInput = exports.startUntrustedHashTransactionInputRaw = void 0;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
function startUntrustedHashTransactionInputRaw(transport, newTransaction, firstRound, transactionData, bip143, overwinter, additionals) {
|
|
54
|
-
|
|
55
|
-
if (overwinter === void 0) { overwinter = false; }
|
|
56
|
-
if (additionals === void 0) { additionals = []; }
|
|
57
|
-
var p2 = additionals.includes("cashaddr")
|
|
13
|
+
const varint_1 = require("./varint");
|
|
14
|
+
const constants_1 = require("./constants");
|
|
15
|
+
function startUntrustedHashTransactionInputRaw(transport, newTransaction, firstRound, transactionData, bip143 = false, overwinter = false, additionals = []) {
|
|
16
|
+
const p2 = additionals.includes("cashaddr")
|
|
58
17
|
? 0x03
|
|
59
18
|
: bip143
|
|
60
19
|
? additionals.includes("sapling")
|
|
@@ -66,131 +25,70 @@ function startUntrustedHashTransactionInputRaw(transport, newTransaction, firstR
|
|
|
66
25
|
return transport.send(0xe0, 0x44, firstRound ? 0x00 : 0x80, newTransaction ? p2 : 0x80, transactionData);
|
|
67
26
|
}
|
|
68
27
|
exports.startUntrustedHashTransactionInputRaw = startUntrustedHashTransactionInputRaw;
|
|
69
|
-
function startUntrustedHashTransactionInput(transport, newTransaction, transaction, inputs, bip143, overwinter, additionals, useTrustedInputForSegwit) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
]);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
prefix,
|
|
119
|
-
inputValue,
|
|
120
|
-
isDecred ? Buffer.from([0x00]) : Buffer.alloc(0),
|
|
121
|
-
(0, varint_1.createVarint)(input.script.length),
|
|
122
|
-
]);
|
|
123
|
-
return [4 /*yield*/, startUntrustedHashTransactionInputRaw(transport, newTransaction, false, data, bip143, overwinter, additionals)];
|
|
124
|
-
case 4:
|
|
125
|
-
_e.sent();
|
|
126
|
-
scriptBlocks = [];
|
|
127
|
-
offset = 0;
|
|
128
|
-
if (input.script.length === 0) {
|
|
129
|
-
scriptBlocks.push(input.sequence);
|
|
28
|
+
function startUntrustedHashTransactionInput(transport, newTransaction, transaction, inputs, bip143 = false, overwinter = false, additionals = [], useTrustedInputForSegwit = false) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
let data = Buffer.concat([
|
|
31
|
+
transaction.version,
|
|
32
|
+
transaction.timestamp || Buffer.alloc(0),
|
|
33
|
+
transaction.nVersionGroupId || Buffer.alloc(0),
|
|
34
|
+
(0, varint_1.createVarint)(transaction.inputs.length),
|
|
35
|
+
]);
|
|
36
|
+
yield startUntrustedHashTransactionInputRaw(transport, newTransaction, true, data, bip143, overwinter, additionals);
|
|
37
|
+
let i = 0;
|
|
38
|
+
const isDecred = additionals.includes("decred");
|
|
39
|
+
for (const input of transaction.inputs) {
|
|
40
|
+
let prefix;
|
|
41
|
+
const inputValue = inputs[i].value;
|
|
42
|
+
if (bip143) {
|
|
43
|
+
if (useTrustedInputForSegwit && inputs[i].trustedInput) {
|
|
44
|
+
prefix = Buffer.from([0x01, inputValue.length]);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
prefix = Buffer.from([0x02]);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
if (inputs[i].trustedInput) {
|
|
52
|
+
prefix = Buffer.from([0x01, inputs[i].value.length]);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
prefix = Buffer.from([0x00]);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
data = Buffer.concat([
|
|
59
|
+
prefix,
|
|
60
|
+
inputValue,
|
|
61
|
+
isDecred ? Buffer.from([0x00]) : Buffer.alloc(0),
|
|
62
|
+
(0, varint_1.createVarint)(input.script.length),
|
|
63
|
+
]);
|
|
64
|
+
yield startUntrustedHashTransactionInputRaw(transport, newTransaction, false, data, bip143, overwinter, additionals);
|
|
65
|
+
const scriptBlocks = [];
|
|
66
|
+
let offset = 0;
|
|
67
|
+
if (input.script.length === 0) {
|
|
68
|
+
scriptBlocks.push(input.sequence);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
while (offset !== input.script.length) {
|
|
72
|
+
const blockSize = input.script.length - offset > constants_1.MAX_SCRIPT_BLOCK
|
|
73
|
+
? constants_1.MAX_SCRIPT_BLOCK
|
|
74
|
+
: input.script.length - offset;
|
|
75
|
+
if (offset + blockSize !== input.script.length) {
|
|
76
|
+
scriptBlocks.push(input.script.slice(offset, offset + blockSize));
|
|
130
77
|
}
|
|
131
78
|
else {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (offset + blockSize !== input.script.length) {
|
|
137
|
-
scriptBlocks.push(input.script.slice(offset, offset + blockSize));
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
scriptBlocks.push(Buffer.concat([
|
|
141
|
-
input.script.slice(offset, offset + blockSize),
|
|
142
|
-
input.sequence,
|
|
143
|
-
]));
|
|
144
|
-
}
|
|
145
|
-
offset += blockSize;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
_e.label = 5;
|
|
149
|
-
case 5:
|
|
150
|
-
_e.trys.push([5, 10, 11, 12]);
|
|
151
|
-
scriptBlocks_1 = (e_1 = void 0, __values(scriptBlocks)), scriptBlocks_1_1 = scriptBlocks_1.next();
|
|
152
|
-
_e.label = 6;
|
|
153
|
-
case 6:
|
|
154
|
-
if (!!scriptBlocks_1_1.done) return [3 /*break*/, 9];
|
|
155
|
-
scriptBlock = scriptBlocks_1_1.value;
|
|
156
|
-
return [4 /*yield*/, startUntrustedHashTransactionInputRaw(transport, newTransaction, false, scriptBlock, bip143, overwinter, additionals)];
|
|
157
|
-
case 7:
|
|
158
|
-
_e.sent();
|
|
159
|
-
_e.label = 8;
|
|
160
|
-
case 8:
|
|
161
|
-
scriptBlocks_1_1 = scriptBlocks_1.next();
|
|
162
|
-
return [3 /*break*/, 6];
|
|
163
|
-
case 9: return [3 /*break*/, 12];
|
|
164
|
-
case 10:
|
|
165
|
-
e_1_1 = _e.sent();
|
|
166
|
-
e_1 = { error: e_1_1 };
|
|
167
|
-
return [3 /*break*/, 12];
|
|
168
|
-
case 11:
|
|
169
|
-
try {
|
|
170
|
-
if (scriptBlocks_1_1 && !scriptBlocks_1_1.done && (_d = scriptBlocks_1["return"])) _d.call(scriptBlocks_1);
|
|
79
|
+
scriptBlocks.push(Buffer.concat([
|
|
80
|
+
input.script.slice(offset, offset + blockSize),
|
|
81
|
+
input.sequence,
|
|
82
|
+
]));
|
|
171
83
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
case 13:
|
|
178
|
-
_b = _a.next();
|
|
179
|
-
return [3 /*break*/, 3];
|
|
180
|
-
case 14: return [3 /*break*/, 17];
|
|
181
|
-
case 15:
|
|
182
|
-
e_2_1 = _e.sent();
|
|
183
|
-
e_2 = { error: e_2_1 };
|
|
184
|
-
return [3 /*break*/, 17];
|
|
185
|
-
case 16:
|
|
186
|
-
try {
|
|
187
|
-
if (_b && !_b.done && (_c = _a["return"])) _c.call(_a);
|
|
188
|
-
}
|
|
189
|
-
finally { if (e_2) throw e_2.error; }
|
|
190
|
-
return [7 /*endfinally*/];
|
|
191
|
-
case 17: return [2 /*return*/];
|
|
84
|
+
offset += blockSize;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
for (const scriptBlock of scriptBlocks) {
|
|
88
|
+
yield startUntrustedHashTransactionInputRaw(transport, newTransaction, false, scriptBlock, bip143, overwinter, additionals);
|
|
192
89
|
}
|
|
193
|
-
|
|
90
|
+
i++;
|
|
91
|
+
}
|
|
194
92
|
});
|
|
195
93
|
}
|
|
196
94
|
exports.startUntrustedHashTransactionInput = startUntrustedHashTransactionInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startUntrustedHashTransactionInput.js","sourceRoot":"","sources":["../src/startUntrustedHashTransactionInput.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"startUntrustedHashTransactionInput.js","sourceRoot":"","sources":["../src/startUntrustedHashTransactionInput.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,qCAAwC;AACxC,2CAA+C;AAC/C,SAAgB,qCAAqC,CACnD,SAAoB,EACpB,cAAuB,EACvB,UAAmB,EACnB,eAAuB,EACvB,MAAM,GAAG,KAAK,EACd,UAAU,GAAG,KAAK,EAClB,cAA6B,EAAE;IAE/B,MAAM,EAAE,GAAG,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC;QACzC,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC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G,MAAM,GAAG,4BAAgB;wBAC7C,CAAC,CAAC,4BAAgB;wBAClB,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;oBAEnC,IAAI,MAAM,GAAG,SAAS,KAAK,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE;wBAC9C,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;qBACnE;yBAAM;wBACL,YAAY,CAAC,IAAI,CACf,MAAM,CAAC,MAAM,CAAC;4BACZ,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;4BAC9C,KAAK,CAAC,QAAQ;yBACf,CAAC,CACH,CAAC;qBACH;oBAED,MAAM,IAAI,SAAS,CAAC;iBACrB;aACF;YAED,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE;gBACtC,MAAM,qCAAqC,CACzC,SAAS,EACT,cAAc,EACd,KAAK,EACL,WAAW,EACX,MAAM,EACN,UAAU,EACV,WAAW,CACZ,CAAC;aACH;YAED,CAAC,EAAE,CAAC;SACL;IACH,CAAC;CAAA;AAzGD,gFAyGC"}
|
package/lib/types.js
CHANGED
package/lib/varint.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createVarint = exports.getVarint = void 0;
|
|
4
4
|
function getVarint(data, offset) {
|
|
5
5
|
if (data[offset] < 0xfd) {
|
|
@@ -22,18 +22,18 @@ function getVarint(data, offset) {
|
|
|
22
22
|
exports.getVarint = getVarint;
|
|
23
23
|
function createVarint(value) {
|
|
24
24
|
if (value < 0xfd) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return
|
|
25
|
+
const buffer = Buffer.alloc(1);
|
|
26
|
+
buffer[0] = value;
|
|
27
|
+
return buffer;
|
|
28
28
|
}
|
|
29
29
|
if (value <= 0xffff) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return
|
|
30
|
+
const buffer = Buffer.alloc(3);
|
|
31
|
+
buffer[0] = 0xfd;
|
|
32
|
+
buffer[1] = value & 0xff;
|
|
33
|
+
buffer[2] = (value >> 8) & 0xff;
|
|
34
|
+
return buffer;
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
const buffer = Buffer.alloc(5);
|
|
37
37
|
buffer[0] = 0xfe;
|
|
38
38
|
buffer[1] = value & 0xff;
|
|
39
39
|
buffer[2] = (value >> 8) & 0xff;
|
package/lib/varint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"varint.js","sourceRoot":"","sources":["../src/varint.ts"],"names":[],"mappings":";;;AAAA,SAAgB,SAAS,CAAC,IAAY,EAAE,MAAc;IACpD,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,EAAE;QACvB,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;KAC1B;IAED,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;QACzB,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KACxD;IAED,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE;QACzB,OAAO;YACL,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;gBACtB,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;gBACxB,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;gBACvB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;YAClB,CAAC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ACf;IAED,IAAI,KAAK,IAAI,MAAM,EAAE;QACnB,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;QACjB,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC;QACzB,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC;QAChC,OAAO,MAAM,CAAC;KACf;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACjB,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC;IACzB,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC;IAChC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IACjC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IACjC,OAAO,MAAM,CAAC;AAChB,CAAC;AAtBD,oCAsBC"}
|
package/lib-es/Btc.js
CHANGED
|
@@ -7,49 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
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
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
38
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
39
|
-
if (!m) return o;
|
|
40
|
-
var i = m.call(o), r, ar = [], e;
|
|
41
|
-
try {
|
|
42
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
43
|
-
}
|
|
44
|
-
catch (error) { e = { error: error }; }
|
|
45
|
-
finally {
|
|
46
|
-
try {
|
|
47
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
48
|
-
}
|
|
49
|
-
finally { if (e) throw e.error; }
|
|
50
|
-
}
|
|
51
|
-
return ar;
|
|
52
|
-
};
|
|
53
10
|
import BtcNew from "./BtcNew";
|
|
54
11
|
import BtcOld from "./BtcOld";
|
|
55
12
|
import { getTrustedInput } from "./getTrustedInput";
|
|
@@ -67,9 +24,8 @@ import { checkIsBtcLegacy, getAppAndVersion } from "./getAppAndVersion";
|
|
|
67
24
|
* import Btc from "@ledgerhq/hw-app-btc";
|
|
68
25
|
* const btc = new Btc({ transport, currency: "bitcoin" });
|
|
69
26
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
var transport = _a.transport, _b = _a.scrambleKey, scrambleKey = _b === void 0 ? "BTC" : _b, _c = _a.currency, currency = _c === void 0 ? "bitcoin" : _c;
|
|
27
|
+
export default class Btc {
|
|
28
|
+
constructor({ transport, scrambleKey = "BTC", currency = "bitcoin", }) {
|
|
73
29
|
this._transport = transport;
|
|
74
30
|
this._transport.decorateAppAPIMethods(this, [
|
|
75
31
|
"getWalletXpub",
|
|
@@ -95,11 +51,11 @@ var Btc = /** @class */ (function () {
|
|
|
95
51
|
* - xpubVersion: the XPUBVersion of the coin used. (use @ledgerhq/currencies if needed)
|
|
96
52
|
* @returns XPUB of the account
|
|
97
53
|
*/
|
|
98
|
-
|
|
99
|
-
return this.changeImplIfNecessary().then(
|
|
54
|
+
getWalletXpub(arg) {
|
|
55
|
+
return this.changeImplIfNecessary().then((impl) => {
|
|
100
56
|
return impl.getWalletXpub(arg);
|
|
101
57
|
});
|
|
102
|
-
}
|
|
58
|
+
}
|
|
103
59
|
/**
|
|
104
60
|
* @param path a BIP 32 path
|
|
105
61
|
* @param options an object with optional these fields:
|
|
@@ -122,23 +78,23 @@ var Btc = /** @class */ (function () {
|
|
|
122
78
|
* btc.getWalletPublicKey("44'/0'/0'/0/0").then(o => o.bitcoinAddress)
|
|
123
79
|
* btc.getWalletPublicKey("49'/0'/0'/0/0", { format: "p2sh" }).then(o => o.bitcoinAddress)
|
|
124
80
|
*/
|
|
125
|
-
|
|
126
|
-
|
|
81
|
+
getWalletPublicKey(path, opts) {
|
|
82
|
+
let options;
|
|
127
83
|
if (arguments.length > 2 || typeof opts === "boolean") {
|
|
128
84
|
console.warn("btc.getWalletPublicKey deprecated signature used. Please switch to getWalletPublicKey(path, { format, verify })");
|
|
129
85
|
options = {
|
|
130
86
|
verify: !!opts,
|
|
131
87
|
// eslint-disable-next-line prefer-rest-params
|
|
132
|
-
format: arguments[2] ? "p2sh" : "legacy"
|
|
88
|
+
format: arguments[2] ? "p2sh" : "legacy",
|
|
133
89
|
};
|
|
134
90
|
}
|
|
135
91
|
else {
|
|
136
92
|
options = opts || {};
|
|
137
93
|
}
|
|
138
|
-
return this.changeImplIfNecessary().then(
|
|
94
|
+
return this.changeImplIfNecessary().then((impl) => {
|
|
139
95
|
return impl.getWalletPublicKey(path, options);
|
|
140
96
|
});
|
|
141
|
-
}
|
|
97
|
+
}
|
|
142
98
|
/**
|
|
143
99
|
* 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.
|
|
144
100
|
* @example
|
|
@@ -148,12 +104,12 @@ var Btc = /** @class */ (function () {
|
|
|
148
104
|
console.log("Signature : " + signature);
|
|
149
105
|
}).catch(function(ex) {console.log(ex);});
|
|
150
106
|
*/
|
|
151
|
-
|
|
107
|
+
signMessage(path, messageHex) {
|
|
152
108
|
return signMessage(this._transport, {
|
|
153
|
-
path
|
|
154
|
-
messageHex
|
|
109
|
+
path,
|
|
110
|
+
messageHex,
|
|
155
111
|
});
|
|
156
|
-
}
|
|
112
|
+
}
|
|
157
113
|
/**
|
|
158
114
|
* To sign a transaction involving standard (P2PKH) inputs, call createTransaction with the following parameters
|
|
159
115
|
* @param inputs is an array of [ transaction, output_index, optional redeem script, optional sequence ] where
|
|
@@ -187,14 +143,14 @@ var Btc = /** @class */ (function () {
|
|
|
187
143
|
outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
|
|
188
144
|
}).then(res => ...);
|
|
189
145
|
*/
|
|
190
|
-
|
|
146
|
+
createPaymentTransaction(arg) {
|
|
191
147
|
if (arguments.length > 1) {
|
|
192
148
|
throw new Error("@ledgerhq/hw-app-btc: createPaymentTransaction multi argument signature is deprecated. please switch to named parameters.");
|
|
193
149
|
}
|
|
194
|
-
return this.changeImplIfNecessary().then(
|
|
150
|
+
return this.changeImplIfNecessary().then((impl) => {
|
|
195
151
|
return impl.createPaymentTransaction(arg);
|
|
196
152
|
});
|
|
197
|
-
}
|
|
153
|
+
}
|
|
198
154
|
/**
|
|
199
155
|
* To obtain the signature of multisignature (P2SH) inputs, call signP2SHTransaction_async with the folowing parameters
|
|
200
156
|
* @param inputs is an array of [ transaction, output_index, redeem script, optional sequence ] where
|
|
@@ -214,82 +170,61 @@ var Btc = /** @class */ (function () {
|
|
|
214
170
|
outputScriptHex: "01905f0100000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88ac"
|
|
215
171
|
}).then(result => ...);
|
|
216
172
|
*/
|
|
217
|
-
|
|
173
|
+
signP2SHTransaction(arg) {
|
|
218
174
|
return signP2SHTransaction(this._transport, arg);
|
|
219
|
-
}
|
|
175
|
+
}
|
|
220
176
|
/**
|
|
221
177
|
* For each UTXO included in your transaction, create a transaction object from the raw serialized version of the transaction used in this UTXO.
|
|
222
178
|
* @example
|
|
223
179
|
const tx1 = btc.splitTransaction("01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000");
|
|
224
180
|
*/
|
|
225
|
-
|
|
226
|
-
if (isSegwitSupported === void 0) { isSegwitSupported = false; }
|
|
227
|
-
if (hasTimestamp === void 0) { hasTimestamp = false; }
|
|
228
|
-
if (hasExtraData === void 0) { hasExtraData = false; }
|
|
229
|
-
if (additionals === void 0) { additionals = []; }
|
|
181
|
+
splitTransaction(transactionHex, isSegwitSupported = false, hasTimestamp = false, hasExtraData = false, additionals = []) {
|
|
230
182
|
return splitTransaction(transactionHex, isSegwitSupported, hasTimestamp, hasExtraData, additionals);
|
|
231
|
-
}
|
|
183
|
+
}
|
|
232
184
|
/**
|
|
233
185
|
@example
|
|
234
186
|
const tx1 = btc.splitTransaction("01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000");
|
|
235
187
|
const outputScript = btc.serializeTransactionOutputs(tx1).toString('hex');
|
|
236
188
|
*/
|
|
237
|
-
|
|
189
|
+
serializeTransactionOutputs(t) {
|
|
238
190
|
return serializeTransactionOutputs(t);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
if (additionals === void 0) { additionals = []; }
|
|
191
|
+
}
|
|
192
|
+
getTrustedInput(indexLookup, transaction, additionals = []) {
|
|
242
193
|
return getTrustedInput(this._transport, indexLookup, transaction, additionals);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (additionals === void 0) { additionals = []; }
|
|
194
|
+
}
|
|
195
|
+
getTrustedInputBIP143(indexLookup, transaction, additionals = []) {
|
|
246
196
|
return getTrustedInputBIP143(this._transport, indexLookup, transaction, additionals);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
case 4:
|
|
278
|
-
// We can't query the version of the Bitcoin app if we're coming from Exchange;
|
|
279
|
-
// therefore, we use a workaround to distinguish legacy and new versions.
|
|
280
|
-
// This can be removed once Ledger Live enforces minimum bitcoin version >= 2.1.0.
|
|
281
|
-
isBtcLegacy = _b.sent();
|
|
282
|
-
_b.label = 5;
|
|
283
|
-
case 5:
|
|
284
|
-
if (isBtcLegacy) {
|
|
285
|
-
this._impl = new BtcOld(this._transport);
|
|
286
|
-
}
|
|
287
|
-
return [2 /*return*/, this._impl];
|
|
288
|
-
}
|
|
289
|
-
});
|
|
197
|
+
}
|
|
198
|
+
changeImplIfNecessary() {
|
|
199
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
200
|
+
// if BtcOld was instantiated, stick with it
|
|
201
|
+
if (this._impl instanceof BtcOld)
|
|
202
|
+
return this._impl;
|
|
203
|
+
const appAndVersion = yield getAppAndVersion(this._transport);
|
|
204
|
+
let isBtcLegacy = true; // default for all altcoins
|
|
205
|
+
if (appAndVersion.name === "Bitcoin" ||
|
|
206
|
+
appAndVersion.name === "Bitcoin Test") {
|
|
207
|
+
const [major, minor] = appAndVersion.version.split(".");
|
|
208
|
+
// we use the legacy protocol for versions below 2.1.0 of the Bitcoin app.
|
|
209
|
+
isBtcLegacy =
|
|
210
|
+
parseInt(major) <= 1 || (parseInt(major) == 2 && parseInt(minor) == 0);
|
|
211
|
+
}
|
|
212
|
+
else if (appAndVersion.name === "Bitcoin Legacy" ||
|
|
213
|
+
appAndVersion.name === "Bitcoin Test Legacy") {
|
|
214
|
+
// the "Bitcoin Legacy" and "Bitcoin Testnet Legacy" app use the legacy protocol, regardless of the version
|
|
215
|
+
isBtcLegacy = true;
|
|
216
|
+
}
|
|
217
|
+
else if (appAndVersion.name === "Exchange") {
|
|
218
|
+
// We can't query the version of the Bitcoin app if we're coming from Exchange;
|
|
219
|
+
// therefore, we use a workaround to distinguish legacy and new versions.
|
|
220
|
+
// This can be removed once Ledger Live enforces minimum bitcoin version >= 2.1.0.
|
|
221
|
+
isBtcLegacy = yield checkIsBtcLegacy(this._transport);
|
|
222
|
+
}
|
|
223
|
+
if (isBtcLegacy) {
|
|
224
|
+
this._impl = new BtcOld(this._transport);
|
|
225
|
+
}
|
|
226
|
+
return this._impl;
|
|
290
227
|
});
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
}());
|
|
294
|
-
export default Btc;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
295
230
|
//# sourceMappingURL=Btc.js.map
|
package/lib-es/Btc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Btc.js","sourceRoot":"","sources":["../src/Btc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Btc.js","sourceRoot":"","sources":["../src/Btc.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,M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