@airgap/bitcoin 0.13.45-beta.3 → 0.13.45-beta.5
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/package.json +5 -5
- package/v0/index.js +10 -10
- package/v0/index.js.map +1 -1
- package/v0/protocol/BitcoinAddress.js +9 -8
- package/v0/protocol/BitcoinAddress.js.map +1 -1
- package/v0/protocol/BitcoinCryptoClient.js +85 -16
- package/v0/protocol/BitcoinCryptoClient.js.map +1 -1
- package/v0/protocol/BitcoinProtocol.js +987 -590
- package/v0/protocol/BitcoinProtocol.js.map +1 -1
- package/v0/protocol/BitcoinProtocolOptions.js +111 -45
- package/v0/protocol/BitcoinProtocolOptions.js.map +1 -1
- package/v0/protocol/BitcoinSegwitAddress.js +29 -12
- package/v0/protocol/BitcoinSegwitAddress.js.map +1 -1
- package/v0/protocol/BitcoinSegwitProtocol.js +483 -348
- package/v0/protocol/BitcoinSegwitProtocol.js.map +1 -1
- package/v0/protocol/BitcoinTestnetProtocol.js +36 -28
- package/v0/protocol/BitcoinTestnetProtocol.js.map +1 -1
- package/v0/serializer/validators/transaction-validator.js +30 -22
- package/v0/serializer/validators/transaction-validator.js.map +1 -1
- package/v0/serializer/validators/validators.js +23 -23
- package/v0/serializer/validators/validators.js.map +1 -1
- package/v1/block-explorer/BlockCypherBlockExplorer.js +61 -12
- package/v1/block-explorer/BlockCypherBlockExplorer.js.map +1 -1
- package/v1/data/BitcoinAddress.js +10 -9
- package/v1/data/BitcoinAddress.js.map +1 -1
- package/v1/data/BitcoinLegacyAddress.js +12 -11
- package/v1/data/BitcoinLegacyAddress.js.map +1 -1
- package/v1/data/BitcoinSegwitAddress.js +12 -11
- package/v1/data/BitcoinSegwitAddress.js.map +1 -1
- package/v1/data/BitcoinTaprootAddress.js +22 -31
- package/v1/data/BitcoinTaprootAddress.js.map +1 -1
- package/v1/index.js +11 -11
- package/v1/index.js.map +1 -1
- package/v1/module/BitcoinModule.d.ts +1 -1
- package/v1/module/BitcoinModule.js +102 -44
- package/v1/module/BitcoinModule.js.map +1 -1
- package/v1/module.js +3 -2
- package/v1/module.js.map +1 -1
- package/v1/protocol/BitcoinCryptoClient.js +90 -22
- package/v1/protocol/BitcoinCryptoClient.js.map +1 -1
- package/v1/protocol/BitcoinLegacyProtocol.js +796 -520
- package/v1/protocol/BitcoinLegacyProtocol.js.map +1 -1
- package/v1/protocol/BitcoinProtocol.js +1169 -735
- package/v1/protocol/BitcoinProtocol.js.map +1 -1
- package/v1/protocol/BitcoinSegwitProtocol.js +796 -542
- package/v1/protocol/BitcoinSegwitProtocol.js.map +1 -1
- package/v1/protocol/BitcoinTaprootProtocol.js +1000 -688
- package/v1/protocol/BitcoinTaprootProtocol.js.map +1 -1
- package/v1/protocol/BitcoinTestnetProtocol.js +33 -14
- package/v1/protocol/BitcoinTestnetProtocol.js.map +1 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +52 -29
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
- package/v1/serializer/v3/serializer-companion.js +165 -98
- package/v1/serializer/v3/serializer-companion.js.map +1 -1
- package/v1/serializer/v3/validators/transaction-validator.js +16 -13
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -1
- package/v1/serializer/v3/validators/validators.js +213 -122
- package/v1/serializer/v3/validators/validators.js.map +1 -1
- package/v1/types/crypto.d.ts +1 -1
- package/v1/types/key.d.ts +6 -6
- package/v1/types/protocol.d.ts +2 -2
- package/v1/types/transaction.d.ts +3 -3
- package/v1/utils/common.js +6 -4
- package/v1/utils/common.js.map +1 -1
- package/v1/utils/key.d.ts +6 -5
- package/v1/utils/key.js +39 -38
- package/v1/utils/key.js.map +1 -1
- package/v1/utils/network.js +4 -3
- package/v1/utils/network.js.map +1 -1
- package/v1/utils/protocol.js +19 -25
- package/v1/utils/protocol.js.map +1 -1
- package/v1/utils/signature.js +5 -4
- package/v1/utils/signature.js.map +1 -1
|
@@ -1,141 +1,232 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
2
38
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
40
|
};
|
|
5
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
42
|
exports.bitcoinValidators = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
43
|
+
var bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
44
|
+
var module_kit_1 = require("@airgap/module-kit");
|
|
45
|
+
var BitcoinProtocol_1 = require("../../../protocol/BitcoinProtocol");
|
|
10
46
|
exports.bitcoinValidators = {
|
|
11
|
-
isValidBitcoinInput:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (!value.hasOwnProperty('recipient')) {
|
|
73
|
-
return "doesn't have property recipient";
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
const protocol = (0, BitcoinProtocol_1.createBitcoinProtocol)();
|
|
77
|
-
const metadata = await protocol.getMetadata();
|
|
78
|
-
const pattern = RegExp(metadata.account?.address?.regex ?? '.*');
|
|
79
|
-
if (!pattern.test(value.recipient)) {
|
|
80
|
-
return 'invalid Bitcoin address';
|
|
81
|
-
}
|
|
47
|
+
isValidBitcoinInput: function (ins) { return __awaiter(void 0, void 0, void 0, function () {
|
|
48
|
+
var i, value, pattern, protocol, metadata, pattern;
|
|
49
|
+
var _a, _b, _c;
|
|
50
|
+
return __generator(this, function (_d) {
|
|
51
|
+
switch (_d.label) {
|
|
52
|
+
case 0:
|
|
53
|
+
// if (!Array.isArray(ins)) {
|
|
54
|
+
// ins = [ins]
|
|
55
|
+
// }
|
|
56
|
+
if (!Array.isArray(ins)) {
|
|
57
|
+
return [2 /*return*/, 'not an array'];
|
|
58
|
+
}
|
|
59
|
+
i = 0;
|
|
60
|
+
_d.label = 1;
|
|
61
|
+
case 1:
|
|
62
|
+
if (!(i < ins.length)) return [3 /*break*/, 5];
|
|
63
|
+
value = ins[i];
|
|
64
|
+
if (!value.hasOwnProperty('txId')) {
|
|
65
|
+
return [2 /*return*/, "doesn't have property txId "];
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
pattern = RegExp('^[a-fA-F0-9]{64}$');
|
|
69
|
+
if (!pattern.test(value.txId)) {
|
|
70
|
+
return [2 /*return*/, 'not a valid txId'];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (!value.hasOwnProperty('value')) {
|
|
74
|
+
return [2 /*return*/, "doesn't have property value "];
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
if (!bignumber_1.default.isBigNumber(value.value)) {
|
|
78
|
+
return [2 /*return*/, 'value not a valid BigNumber'];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (!value.hasOwnProperty('vout')) {
|
|
82
|
+
return [2 /*return*/, "doesn't have property vout"];
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
if (typeof value.vout !== 'number') {
|
|
86
|
+
return [2 /*return*/, 'vout is not a number'];
|
|
87
|
+
}
|
|
88
|
+
else if (value.vout < 0) {
|
|
89
|
+
return [2 /*return*/, 'vout is not a positive value'];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (!!value.hasOwnProperty('address')) return [3 /*break*/, 2];
|
|
93
|
+
return [2 /*return*/, "doesn't have property address "];
|
|
94
|
+
case 2:
|
|
95
|
+
protocol = (0, BitcoinProtocol_1.createBitcoinProtocol)();
|
|
96
|
+
return [4 /*yield*/, protocol.getMetadata()];
|
|
97
|
+
case 3:
|
|
98
|
+
metadata = _d.sent();
|
|
99
|
+
pattern = RegExp((_c = (_b = (_a = metadata.account) === null || _a === void 0 ? void 0 : _a.address) === null || _b === void 0 ? void 0 : _b.regex) !== null && _c !== void 0 ? _c : '.*');
|
|
100
|
+
if (!pattern.test(value.address)) {
|
|
101
|
+
return [2 /*return*/, 'not a valid bitcoin address'];
|
|
102
|
+
}
|
|
103
|
+
_d.label = 4;
|
|
104
|
+
case 4:
|
|
105
|
+
i++;
|
|
106
|
+
return [3 /*break*/, 1];
|
|
107
|
+
case 5: return [2 /*return*/, null];
|
|
82
108
|
}
|
|
83
|
-
|
|
84
|
-
|
|
109
|
+
});
|
|
110
|
+
}); },
|
|
111
|
+
isValidBitcoinOutput: function (outs) { return __awaiter(void 0, void 0, void 0, function () {
|
|
112
|
+
var i, value, protocol, metadata, pattern;
|
|
113
|
+
var _a, _b, _c;
|
|
114
|
+
return __generator(this, function (_d) {
|
|
115
|
+
switch (_d.label) {
|
|
116
|
+
case 0:
|
|
117
|
+
// console.log(outs)
|
|
118
|
+
// if (!Array.isArray(outs)) {
|
|
119
|
+
// outs = [outs]
|
|
120
|
+
// }
|
|
121
|
+
if (!Array.isArray(outs)) {
|
|
122
|
+
return [2 /*return*/, 'not an array'];
|
|
123
|
+
}
|
|
124
|
+
i = 0;
|
|
125
|
+
_d.label = 1;
|
|
126
|
+
case 1:
|
|
127
|
+
if (!(i < outs.length)) return [3 /*break*/, 6];
|
|
128
|
+
value = outs[i];
|
|
129
|
+
if (!!value.hasOwnProperty('recipient')) return [3 /*break*/, 2];
|
|
130
|
+
return [2 /*return*/, "doesn't have property recipient"];
|
|
131
|
+
case 2:
|
|
132
|
+
protocol = (0, BitcoinProtocol_1.createBitcoinProtocol)();
|
|
133
|
+
return [4 /*yield*/, protocol.getMetadata()];
|
|
134
|
+
case 3:
|
|
135
|
+
metadata = _d.sent();
|
|
136
|
+
pattern = RegExp((_c = (_b = (_a = metadata.account) === null || _a === void 0 ? void 0 : _a.address) === null || _b === void 0 ? void 0 : _b.regex) !== null && _c !== void 0 ? _c : '.*');
|
|
137
|
+
if (!pattern.test(value.recipient)) {
|
|
138
|
+
return [2 /*return*/, 'invalid Bitcoin address'];
|
|
139
|
+
}
|
|
140
|
+
_d.label = 4;
|
|
141
|
+
case 4:
|
|
142
|
+
if (!value.hasOwnProperty('isChange')) {
|
|
143
|
+
return [2 /*return*/, "doesn't have property isChange "];
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
if (typeof value.isChange !== 'boolean') {
|
|
147
|
+
return [2 /*return*/, 'change is not a boolean'];
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (!value.hasOwnProperty('value')) {
|
|
151
|
+
return [2 /*return*/, "doesn't have property value "];
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
if (!bignumber_1.default.isBigNumber(value.value)) {
|
|
155
|
+
return [2 /*return*/, 'value is not BigNumber'];
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
_d.label = 5;
|
|
159
|
+
case 5:
|
|
160
|
+
i++;
|
|
161
|
+
return [3 /*break*/, 1];
|
|
162
|
+
case 6: return [2 /*return*/, null];
|
|
85
163
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
164
|
+
});
|
|
165
|
+
}); },
|
|
166
|
+
isValidBitcoinFromArray: function (array) { return __awaiter(void 0, void 0, void 0, function () {
|
|
167
|
+
var i, address, protocol, metadata, pattern;
|
|
168
|
+
var _a, _b, _c;
|
|
169
|
+
return __generator(this, function (_d) {
|
|
170
|
+
switch (_d.label) {
|
|
171
|
+
case 0:
|
|
172
|
+
if (!Array.isArray(array)) {
|
|
173
|
+
return [2 /*return*/, 'not an array of Bitcoin addresses'];
|
|
174
|
+
}
|
|
175
|
+
i = 0;
|
|
176
|
+
_d.label = 1;
|
|
177
|
+
case 1:
|
|
178
|
+
if (!(i < array.length)) return [3 /*break*/, 4];
|
|
179
|
+
address = array[i];
|
|
180
|
+
protocol = (0, BitcoinProtocol_1.createBitcoinProtocol)();
|
|
181
|
+
return [4 /*yield*/, protocol.getMetadata()];
|
|
182
|
+
case 2:
|
|
183
|
+
metadata = _d.sent();
|
|
184
|
+
pattern = RegExp((_c = (_b = (_a = metadata.account) === null || _a === void 0 ? void 0 : _a.address) === null || _b === void 0 ? void 0 : _b.regex) !== null && _c !== void 0 ? _c : '.*');
|
|
185
|
+
if (!pattern.test(address)) {
|
|
186
|
+
return [2 /*return*/, 'not a valid bitcoin address'];
|
|
187
|
+
}
|
|
188
|
+
_d.label = 3;
|
|
189
|
+
case 3:
|
|
190
|
+
i++;
|
|
191
|
+
return [3 /*break*/, 1];
|
|
192
|
+
case 4: return [2 /*return*/, null];
|
|
90
193
|
}
|
|
91
|
-
|
|
92
|
-
|
|
194
|
+
});
|
|
195
|
+
}); },
|
|
196
|
+
isBitcoinAccount: function (accountIdentifier) { return __awaiter(void 0, void 0, void 0, function () {
|
|
197
|
+
var protocol, derivedKey, error_1;
|
|
198
|
+
return __generator(this, function (_a) {
|
|
199
|
+
switch (_a.label) {
|
|
200
|
+
case 0:
|
|
201
|
+
if (accountIdentifier === null || typeof accountIdentifier === 'undefined') {
|
|
202
|
+
return [2 /*return*/, null];
|
|
203
|
+
}
|
|
204
|
+
_a.label = 1;
|
|
205
|
+
case 1:
|
|
206
|
+
_a.trys.push([1, 4, , 5]);
|
|
207
|
+
protocol = (0, BitcoinProtocol_1.createBitcoinProtocol)();
|
|
208
|
+
return [4 /*yield*/, protocol.deriveFromExtendedPublicKey((0, module_kit_1.newExtendedPublicKey)(accountIdentifier, 'encoded'), 0, 0)];
|
|
209
|
+
case 2:
|
|
210
|
+
derivedKey = _a.sent();
|
|
211
|
+
return [4 /*yield*/, protocol.getAddressFromPublicKey(derivedKey)];
|
|
212
|
+
case 3:
|
|
213
|
+
_a.sent();
|
|
214
|
+
return [2 /*return*/, null];
|
|
215
|
+
case 4:
|
|
216
|
+
error_1 = _a.sent();
|
|
217
|
+
return [2 /*return*/, 'not a valid Bitcoin account'];
|
|
218
|
+
case 5: return [2 /*return*/];
|
|
93
219
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return null;
|
|
101
|
-
},
|
|
102
|
-
isValidBitcoinFromArray: async (array) => {
|
|
103
|
-
if (!Array.isArray(array)) {
|
|
104
|
-
return 'not an array of Bitcoin addresses';
|
|
105
|
-
}
|
|
106
|
-
for (let i = 0; i < array.length; i++) {
|
|
107
|
-
const address = array[i];
|
|
108
|
-
const protocol = (0, BitcoinProtocol_1.createBitcoinProtocol)();
|
|
109
|
-
const metadata = await protocol.getMetadata();
|
|
110
|
-
const pattern = RegExp(metadata.account?.address?.regex ?? '.*');
|
|
111
|
-
if (!pattern.test(address)) {
|
|
112
|
-
return 'not a valid bitcoin address';
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return null;
|
|
116
|
-
},
|
|
117
|
-
isBitcoinAccount: async (accountIdentifier) => {
|
|
118
|
-
if (accountIdentifier === null || typeof accountIdentifier === 'undefined') {
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
try {
|
|
122
|
-
const protocol = (0, BitcoinProtocol_1.createBitcoinProtocol)();
|
|
123
|
-
const derivedKey = await protocol.deriveFromExtendedPublicKey((0, module_kit_1.newExtendedPublicKey)(accountIdentifier, 'encoded'), 0, 0);
|
|
124
|
-
await protocol.getAddressFromPublicKey(derivedKey);
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
catch (error) {
|
|
128
|
-
return 'not a valid Bitcoin account';
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
isValidBitcoinTxString: (transaction) => {
|
|
220
|
+
});
|
|
221
|
+
}); },
|
|
222
|
+
isValidBitcoinTxString: function (transaction) {
|
|
132
223
|
// allow empty values by default (needs to be checked by "presence" check)
|
|
133
224
|
if (transaction === null || typeof transaction === 'undefined') {
|
|
134
225
|
return null;
|
|
135
226
|
}
|
|
136
227
|
try {
|
|
137
|
-
|
|
138
|
-
|
|
228
|
+
var protocol = new BitcoinProtocol_1.BitcoinProtocolImpl();
|
|
229
|
+
var bitcoinJSLib = protocol.bitcoinJS.lib;
|
|
139
230
|
bitcoinJSLib.Transaction.fromHex(transaction);
|
|
140
231
|
return null;
|
|
141
232
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../../../src/v1/serializer/v3/validators/validators.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot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AO,IAAI,EAAA;;;SACZ;IAED,gBAAgB,EAAE,UAAO,iBAAyB;;;;;oBAChD,IAAI,iBAAiB,KAAK,IAAI,IAAI,OAAO,iBAAiB,KAAK,WAAW,EAAE;wBAC1E,sBAAO,IAAI,EAAA;qBACZ;;;;oBAEO,QAAQ,GAAG,IAAA,uCAAqB,GAAE,CAAA;oBACrB,qBAAM,QAAQ,CAAC,2BAA2B,CAAC,IAAA,iCAAoB,EAAC,iBAAiB,EAAE,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAA;;oBAAjH,UAAU,GAAG,SAAoG;oBACvH,qBAAM,QAAQ,CAAC,uBAAuB,CAAC,UAAU,CAAC,EAAA;;oBAAlD,SAAkD,CAAA;oBAElD,sBAAO,IAAI,EAAA;;;oBAEX,sBAAO,6BAA6B,EAAA;;;;SAEvC;IAED,sBAAsB,EAAE,UAAC,WAAmB;QAC1C,0EAA0E;QAC1E,IAAI,WAAW,KAAK,IAAI,IAAI,OAAO,WAAW,KAAK,WAAW,EAAE;YAC9D,OAAO,IAAI,CAAA;SACZ;QACD,IAAI;YACF,IAAM,QAAQ,GAAG,IAAI,qCAAmB,EAAE,CAAA;YAC1C,IAAM,YAAY,GAAG,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAA;YAC3C,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;YAE7C,OAAO,IAAI,CAAA;SACZ;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,gDAAgD,CAAA;SACxD;IACH,CAAC;CACF,CAAA"}
|
package/v1/types/crypto.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Secp256K1CryptoConfiguration } from '@airgap/module-kit';
|
|
2
|
-
export type BitcoinCryptoConfiguration = Secp256K1CryptoConfiguration;
|
|
2
|
+
export declare type BitcoinCryptoConfiguration = Secp256K1CryptoConfiguration;
|
package/v1/types/key.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export type BitcoinExtendedSecretKeyEncoding = 'xprv';
|
|
2
|
-
export type BitcoinTestnetExtendedSecretKeyEncoding = 'tprv';
|
|
3
|
-
export type BitcoinSegwitExtendedSecretKeyEncoding = BitcoinExtendedSecretKeyEncoding | 'yprv' | 'zprv';
|
|
4
|
-
export type BitcoinExtendedPublicKeyEncoding = 'xpub';
|
|
5
|
-
export type BitcoinTestnetExtendedPublicKeyEncoding = 'tpub';
|
|
6
|
-
export type BitcoinSegwitExtendedPublicKeyEncoding = BitcoinExtendedPublicKeyEncoding | 'ypub' | 'zpub';
|
|
1
|
+
export declare type BitcoinExtendedSecretKeyEncoding = 'xprv';
|
|
2
|
+
export declare type BitcoinTestnetExtendedSecretKeyEncoding = 'tprv';
|
|
3
|
+
export declare type BitcoinSegwitExtendedSecretKeyEncoding = BitcoinExtendedSecretKeyEncoding | 'yprv' | 'zprv';
|
|
4
|
+
export declare type BitcoinExtendedPublicKeyEncoding = 'xpub';
|
|
5
|
+
export declare type BitcoinTestnetExtendedPublicKeyEncoding = 'tpub';
|
|
6
|
+
export declare type BitcoinSegwitExtendedPublicKeyEncoding = BitcoinExtendedPublicKeyEncoding | 'ypub' | 'zpub';
|
package/v1/types/protocol.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProtocolNetwork } from '@airgap/module-kit';
|
|
2
|
-
export type BitcoinUnits = 'BTC' | 'mBTC' | 'Satoshi';
|
|
2
|
+
export declare type BitcoinUnits = 'BTC' | 'mBTC' | 'Satoshi';
|
|
3
3
|
interface BitcoinBaseProtocolNetwork extends ProtocolNetwork {
|
|
4
4
|
indexerApi: string;
|
|
5
5
|
}
|
|
@@ -10,7 +10,7 @@ export interface BitcoinCustomProtocolNetwork extends BitcoinBaseProtocolNetwork
|
|
|
10
10
|
type: 'custom';
|
|
11
11
|
bitcoinjsNetworkName: string;
|
|
12
12
|
}
|
|
13
|
-
export type BitcoinProtocolNetwork = BitcoinStandardProtocolNetwork | BitcoinCustomProtocolNetwork;
|
|
13
|
+
export declare type BitcoinProtocolNetwork = BitcoinStandardProtocolNetwork | BitcoinCustomProtocolNetwork;
|
|
14
14
|
export interface BitcoinProtocolOptions {
|
|
15
15
|
network: BitcoinProtocolNetwork;
|
|
16
16
|
}
|
|
@@ -45,15 +45,15 @@ export interface BitcoinTaprootUnsignedTransaction extends UnsignedTransaction {
|
|
|
45
45
|
export interface BitcoinTransactionCursor extends TransactionCursor {
|
|
46
46
|
page?: number;
|
|
47
47
|
}
|
|
48
|
-
export type LegacyTransactionFullConfiguration<_Units extends BitcoinUnits> = TransactionFullConfiguration<_Units> & {
|
|
48
|
+
export declare type LegacyTransactionFullConfiguration<_Units extends BitcoinUnits> = TransactionFullConfiguration<_Units> & {
|
|
49
49
|
masterFingerprint: HexString;
|
|
50
50
|
replaceByFee?: boolean;
|
|
51
51
|
};
|
|
52
|
-
export type SegwitTransactionFullConfiguration<_Units extends BitcoinUnits> = TransactionFullConfiguration<_Units> & {
|
|
52
|
+
export declare type SegwitTransactionFullConfiguration<_Units extends BitcoinUnits> = TransactionFullConfiguration<_Units> & {
|
|
53
53
|
masterFingerprint: HexString;
|
|
54
54
|
replaceByFee?: boolean;
|
|
55
55
|
};
|
|
56
|
-
export type TaprootTransactionFullConfiguration<_Units extends BitcoinUnits> = TransactionFullConfiguration<_Units> & {
|
|
56
|
+
export declare type TaprootTransactionFullConfiguration<_Units extends BitcoinUnits> = TransactionFullConfiguration<_Units> & {
|
|
57
57
|
masterFingerprint: HexString;
|
|
58
58
|
replaceByFee?: boolean;
|
|
59
59
|
};
|
package/v1/utils/common.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.containsSome =
|
|
4
|
-
exports.eachRecursive = eachRecursive;
|
|
3
|
+
exports.eachRecursive = exports.containsSome = void 0;
|
|
5
4
|
function containsSome(needles, haystack) {
|
|
6
|
-
for (
|
|
5
|
+
for (var _i = 0, needles_1 = needles; _i < needles_1.length; _i++) {
|
|
6
|
+
var needle = needles_1[_i];
|
|
7
7
|
if (haystack.indexOf(needle) > -1) {
|
|
8
8
|
return true;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
return false;
|
|
12
12
|
}
|
|
13
|
+
exports.containsSome = containsSome;
|
|
13
14
|
// This function handles arrays and objects
|
|
14
15
|
function eachRecursive(obj) {
|
|
15
16
|
// tslint:disable-next-line: forin
|
|
16
|
-
for (
|
|
17
|
+
for (var k in obj) {
|
|
17
18
|
if (Buffer.isBuffer(obj[k])) {
|
|
18
19
|
obj[k] = obj[k].toString('hex');
|
|
19
20
|
}
|
|
@@ -23,4 +24,5 @@ function eachRecursive(obj) {
|
|
|
23
24
|
}
|
|
24
25
|
return obj;
|
|
25
26
|
}
|
|
27
|
+
exports.eachRecursive = eachRecursive;
|
|
26
28
|
//# sourceMappingURL=common.js.map
|
package/v1/utils/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/v1/utils/common.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/v1/utils/common.ts"],"names":[],"mappings":";;;AAAA,SAAgB,YAAY,CAAI,OAAY,EAAE,QAAa;IACzD,KAAqB,UAAO,EAAP,mBAAO,EAAP,qBAAO,EAAP,IAAO,EAAE;QAAzB,IAAM,MAAM,gBAAA;QACf,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE;YACjC,OAAO,IAAI,CAAA;SACZ;KACF;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AARD,oCAQC;AAED,2CAA2C;AAC3C,SAAgB,aAAa,CAAC,GAAsB;IAClD,kCAAkC;IAClC,KAAK,IAAM,CAAC,IAAI,GAAG,EAAE;QACnB,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE;YAC3B,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;SAChC;QACD,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;YACjD,GAAG,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;SAC/B;KACF;IAED,OAAO,GAAG,CAAA;AACZ,CAAC;AAZD,sCAYC"}
|
package/v1/utils/key.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { ExtendedPublicKey, ExtendedSecretKey, PublicKey, SecretKey } from '@airgap/module-kit';
|
|
2
3
|
import { ExcludeTyped, ExtractTyped } from '@airgap/module-kit/types/meta/utility-types';
|
|
3
4
|
import { BitcoinExtendedPublicKeyEncoding, BitcoinExtendedSecretKeyEncoding, BitcoinSegwitExtendedPublicKeyEncoding, BitcoinSegwitExtendedSecretKeyEncoding, BitcoinTestnetExtendedPublicKeyEncoding, BitcoinTestnetExtendedSecretKeyEncoding } from '../types/key';
|
|
4
5
|
declare const EXT_SK_PREFIX: Record<BitcoinExtendedSecretKeyEncoding, string>;
|
|
5
6
|
declare const EXT_SK_TESTNET_PREFIX: Record<BitcoinTestnetExtendedSecretKeyEncoding, string>;
|
|
6
7
|
declare const EXT_SK_SEGWIT_PREFIX: Record<BitcoinSegwitExtendedSecretKeyEncoding, string>;
|
|
7
|
-
export type ExtendedSecretKeyEncoding = keyof typeof EXT_SK_PREFIX | keyof typeof EXT_SK_TESTNET_PREFIX | keyof typeof EXT_SK_SEGWIT_PREFIX;
|
|
8
|
+
export declare type ExtendedSecretKeyEncoding = keyof typeof EXT_SK_PREFIX | keyof typeof EXT_SK_TESTNET_PREFIX | keyof typeof EXT_SK_SEGWIT_PREFIX;
|
|
8
9
|
declare const EXT_PK_PREFIX: Record<BitcoinExtendedPublicKeyEncoding, string>;
|
|
9
10
|
declare const EXT_PK_TESTNET_PREFIX: Record<BitcoinTestnetExtendedPublicKeyEncoding, string>;
|
|
10
11
|
declare const EXT_PK_SEGWIT_PREFIX: Record<BitcoinSegwitExtendedPublicKeyEncoding, string>;
|
|
11
|
-
export type ExtendedPublicKeyEncoding = keyof typeof EXT_PK_PREFIX | keyof typeof EXT_PK_TESTNET_PREFIX | keyof typeof EXT_PK_SEGWIT_PREFIX;
|
|
12
|
-
type HashFunction = (payload: Buffer) => Buffer;
|
|
12
|
+
export declare type ExtendedPublicKeyEncoding = keyof typeof EXT_PK_PREFIX | keyof typeof EXT_PK_TESTNET_PREFIX | keyof typeof EXT_PK_SEGWIT_PREFIX;
|
|
13
|
+
declare type HashFunction = (payload: Buffer) => Buffer;
|
|
13
14
|
export declare function convertSecretKey(secretKey: SecretKey, targetFormat: SecretKey['format']): SecretKey;
|
|
14
|
-
type ConvertExtendedSecretKeyTarget = {
|
|
15
|
+
declare type ConvertExtendedSecretKeyTarget = {
|
|
15
16
|
format: ExcludeTyped<ExtendedSecretKey['format'], 'encoded'>;
|
|
16
17
|
hashFunction?: HashFunction;
|
|
17
18
|
} | {
|
|
@@ -21,7 +22,7 @@ type ConvertExtendedSecretKeyTarget = {
|
|
|
21
22
|
};
|
|
22
23
|
export declare function convertExtendedSecretKey(extendedSecretKey: ExtendedSecretKey, target: ConvertExtendedSecretKeyTarget): ExtendedSecretKey;
|
|
23
24
|
export declare function convertPublicKey(publicKey: PublicKey, targetFormat: PublicKey['format']): PublicKey;
|
|
24
|
-
type ConvertExtendedPublicKeyTarget = {
|
|
25
|
+
declare type ConvertExtendedPublicKeyTarget = {
|
|
25
26
|
format: ExcludeTyped<ExtendedPublicKey['format'], 'encoded'>;
|
|
26
27
|
hashFunction?: HashFunction;
|
|
27
28
|
} | {
|