@airgap/bitcoin 0.13.45-beta.1 → 0.13.45-beta.3
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 +8 -9
- package/v0/protocol/BitcoinAddress.js.map +1 -1
- package/v0/protocol/BitcoinCryptoClient.js +16 -85
- package/v0/protocol/BitcoinCryptoClient.js.map +1 -1
- package/v0/protocol/BitcoinProtocol.js +590 -987
- package/v0/protocol/BitcoinProtocol.js.map +1 -1
- package/v0/protocol/BitcoinProtocolOptions.js +45 -111
- package/v0/protocol/BitcoinProtocolOptions.js.map +1 -1
- package/v0/protocol/BitcoinSegwitAddress.js +12 -29
- package/v0/protocol/BitcoinSegwitAddress.js.map +1 -1
- package/v0/protocol/BitcoinSegwitProtocol.js +348 -483
- package/v0/protocol/BitcoinSegwitProtocol.js.map +1 -1
- package/v0/protocol/BitcoinTestnetProtocol.js +28 -36
- package/v0/protocol/BitcoinTestnetProtocol.js.map +1 -1
- package/v0/serializer/validators/transaction-validator.js +22 -30
- 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 +12 -61
- package/v1/block-explorer/BlockCypherBlockExplorer.js.map +1 -1
- package/v1/data/BitcoinAddress.js +9 -10
- package/v1/data/BitcoinAddress.js.map +1 -1
- package/v1/data/BitcoinLegacyAddress.js +11 -12
- package/v1/data/BitcoinLegacyAddress.js.map +1 -1
- package/v1/data/BitcoinSegwitAddress.js +11 -12
- package/v1/data/BitcoinSegwitAddress.js.map +1 -1
- package/v1/data/BitcoinTaprootAddress.js +31 -22
- 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 +44 -102
- package/v1/module/BitcoinModule.js.map +1 -1
- package/v1/module.js +2 -3
- package/v1/module.js.map +1 -1
- package/v1/protocol/BitcoinCryptoClient.js +22 -90
- package/v1/protocol/BitcoinCryptoClient.js.map +1 -1
- package/v1/protocol/BitcoinLegacyProtocol.js +520 -796
- package/v1/protocol/BitcoinLegacyProtocol.js.map +1 -1
- package/v1/protocol/BitcoinProtocol.js +735 -1169
- package/v1/protocol/BitcoinProtocol.js.map +1 -1
- package/v1/protocol/BitcoinSegwitProtocol.js +542 -796
- package/v1/protocol/BitcoinSegwitProtocol.js.map +1 -1
- package/v1/protocol/BitcoinTaprootProtocol.js +688 -1000
- package/v1/protocol/BitcoinTaprootProtocol.js.map +1 -1
- package/v1/protocol/BitcoinTestnetProtocol.js +14 -33
- package/v1/protocol/BitcoinTestnetProtocol.js.map +1 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +29 -52
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
- package/v1/serializer/v3/serializer-companion.js +98 -165
- package/v1/serializer/v3/serializer-companion.js.map +1 -1
- package/v1/serializer/v3/validators/transaction-validator.js +13 -16
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -1
- package/v1/serializer/v3/validators/validators.js +122 -213
- 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 +4 -6
- package/v1/utils/common.js.map +1 -1
- package/v1/utils/key.d.ts +5 -6
- package/v1/utils/key.js +38 -39
- package/v1/utils/key.js.map +1 -1
- package/v1/utils/network.js +3 -4
- package/v1/utils/network.js.map +1 -1
- package/v1/utils/protocol.js +25 -19
- package/v1/utils/protocol.js.map +1 -1
- package/v1/utils/signature.js +4 -5
- package/v1/utils/signature.js.map +1 -1
|
@@ -1,232 +1,141 @@
|
|
|
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
|
-
};
|
|
38
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
4
|
};
|
|
41
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
6
|
exports.bitcoinValidators = void 0;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
7
|
+
const bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
8
|
+
const module_kit_1 = require("@airgap/module-kit");
|
|
9
|
+
const BitcoinProtocol_1 = require("../../../protocol/BitcoinProtocol");
|
|
46
10
|
exports.bitcoinValidators = {
|
|
47
|
-
isValidBitcoinInput:
|
|
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
|
-
|
|
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
|
-
|
|
11
|
+
isValidBitcoinInput: async (ins) => {
|
|
12
|
+
// if (!Array.isArray(ins)) {
|
|
13
|
+
// ins = [ins]
|
|
14
|
+
// }
|
|
15
|
+
if (!Array.isArray(ins)) {
|
|
16
|
+
return 'not an array';
|
|
17
|
+
}
|
|
18
|
+
for (let i = 0; i < ins.length; i++) {
|
|
19
|
+
const value = ins[i];
|
|
20
|
+
if (!value.hasOwnProperty('txId')) {
|
|
21
|
+
return "doesn't have property txId ";
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const pattern = RegExp('^[a-fA-F0-9]{64}$');
|
|
25
|
+
if (!pattern.test(value.txId)) {
|
|
26
|
+
return 'not a valid txId';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (!value.hasOwnProperty('value')) {
|
|
30
|
+
return "doesn't have property value ";
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
if (!bignumber_1.default.isBigNumber(value.value)) {
|
|
34
|
+
return 'value not a valid BigNumber';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (!value.hasOwnProperty('vout')) {
|
|
38
|
+
return "doesn't have property vout";
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
if (typeof value.vout !== 'number') {
|
|
42
|
+
return 'vout is not a number';
|
|
43
|
+
}
|
|
44
|
+
else if (value.vout < 0) {
|
|
45
|
+
return 'vout is not a positive value';
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (!value.hasOwnProperty('address')) {
|
|
49
|
+
return "doesn't have property address ";
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const protocol = (0, BitcoinProtocol_1.createBitcoinProtocol)();
|
|
53
|
+
const metadata = await protocol.getMetadata();
|
|
54
|
+
const pattern = RegExp(metadata.account?.address?.regex ?? '.*');
|
|
55
|
+
if (!pattern.test(value.address)) {
|
|
56
|
+
return 'not a valid bitcoin address';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
},
|
|
62
|
+
isValidBitcoinOutput: async (outs) => {
|
|
63
|
+
// console.log(outs)
|
|
64
|
+
// if (!Array.isArray(outs)) {
|
|
65
|
+
// outs = [outs]
|
|
66
|
+
// }
|
|
67
|
+
if (!Array.isArray(outs)) {
|
|
68
|
+
return 'not an array';
|
|
69
|
+
}
|
|
70
|
+
for (let i = 0; i < outs.length; i++) {
|
|
71
|
+
const value = outs[i];
|
|
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
|
+
}
|
|
108
82
|
}
|
|
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];
|
|
83
|
+
if (!value.hasOwnProperty('isChange')) {
|
|
84
|
+
return "doesn't have property isChange ";
|
|
163
85
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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];
|
|
86
|
+
else {
|
|
87
|
+
if (typeof value.isChange !== 'boolean') {
|
|
88
|
+
return 'change is not a boolean';
|
|
89
|
+
}
|
|
193
90
|
}
|
|
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*/];
|
|
91
|
+
if (!value.hasOwnProperty('value')) {
|
|
92
|
+
return "doesn't have property value ";
|
|
219
93
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
94
|
+
else {
|
|
95
|
+
if (!bignumber_1.default.isBigNumber(value.value)) {
|
|
96
|
+
return 'value is not BigNumber';
|
|
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) => {
|
|
223
132
|
// allow empty values by default (needs to be checked by "presence" check)
|
|
224
133
|
if (transaction === null || typeof transaction === 'undefined') {
|
|
225
134
|
return null;
|
|
226
135
|
}
|
|
227
136
|
try {
|
|
228
|
-
|
|
229
|
-
|
|
137
|
+
const protocol = new BitcoinProtocol_1.BitcoinProtocolImpl();
|
|
138
|
+
const bitcoinJSLib = protocol.bitcoinJS.lib;
|
|
230
139
|
bitcoinJSLib.Transaction.fromHex(transaction);
|
|
231
140
|
return null;
|
|
232
141
|
}
|
|
@@ -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":"","sources":["../../../../../src/v1/serializer/v3/validators/validators.ts"],"names":[],"mappings":";;;;;;AAAA,mHAA0F;AAC1F,mDAAyD;AAEzD,uEAA8F;AAEjF,QAAA,iBAAiB,GAAG;IAC/B,mBAAmB,EAAE,KAAK,EAAE,GAAY,EAAE,EAAE;QAC1C,6BAA6B;QAC7B,gBAAgB;QAChB,IA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I,CAAA;IACb,CAAC;IAED,gBAAgB,EAAE,KAAK,EAAE,iBAAyB,EAAE,EAAE;QACpD,IAAI,iBAAiB,KAAK,IAAI,IAAI,OAAO,iBAAiB,KAAK,WAAW,EAAE,CAAC;YAC3E,OAAO,IAAI,CAAA;QACb,CAAC;QACD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAA,uCAAqB,GAAE,CAAA;YACxC,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,2BAA2B,CAAC,IAAA,iCAAoB,EAAC,iBAAiB,EAAE,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;YACvH,MAAM,QAAQ,CAAC,uBAAuB,CAAC,UAAU,CAAC,CAAA;YAElD,OAAO,IAAI,CAAA;QACb,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,6BAA6B,CAAA;QACtC,CAAC;IACH,CAAC;IAED,sBAAsB,EAAE,CAAC,WAAmB,EAAE,EAAE;QAC9C,0EAA0E;QAC1E,IAAI,WAAW,KAAK,IAAI,IAAI,OAAO,WAAW,KAAK,WAAW,EAAE,CAAC;YAC/D,OAAO,IAAI,CAAA;QACb,CAAC;QACD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAI,qCAAmB,EAAE,CAAA;YAC1C,MAAM,YAAY,GAAG,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAA;YAC3C,YAAY,CAAC,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;YAE7C,OAAO,IAAI,CAAA;QACb,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,gDAAgD,CAAA;QACzD,CAAC;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
|
|
2
|
+
export type BitcoinCryptoConfiguration = Secp256K1CryptoConfiguration;
|
package/v1/types/key.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
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';
|
package/v1/types/protocol.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProtocolNetwork } from '@airgap/module-kit';
|
|
2
|
-
export
|
|
2
|
+
export 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
|
|
13
|
+
export 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
|
|
48
|
+
export type LegacyTransactionFullConfiguration<_Units extends BitcoinUnits> = TransactionFullConfiguration<_Units> & {
|
|
49
49
|
masterFingerprint: HexString;
|
|
50
50
|
replaceByFee?: boolean;
|
|
51
51
|
};
|
|
52
|
-
export
|
|
52
|
+
export type SegwitTransactionFullConfiguration<_Units extends BitcoinUnits> = TransactionFullConfiguration<_Units> & {
|
|
53
53
|
masterFingerprint: HexString;
|
|
54
54
|
replaceByFee?: boolean;
|
|
55
55
|
};
|
|
56
|
-
export
|
|
56
|
+
export type TaprootTransactionFullConfiguration<_Units extends BitcoinUnits> = TransactionFullConfiguration<_Units> & {
|
|
57
57
|
masterFingerprint: HexString;
|
|
58
58
|
replaceByFee?: boolean;
|
|
59
59
|
};
|
package/v1/utils/common.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.containsSome = containsSome;
|
|
4
|
+
exports.eachRecursive = eachRecursive;
|
|
4
5
|
function containsSome(needles, haystack) {
|
|
5
|
-
for (
|
|
6
|
-
var needle = needles_1[_i];
|
|
6
|
+
for (const needle of needles) {
|
|
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;
|
|
14
13
|
// This function handles arrays and objects
|
|
15
14
|
function eachRecursive(obj) {
|
|
16
15
|
// tslint:disable-next-line: forin
|
|
17
|
-
for (
|
|
16
|
+
for (const k in obj) {
|
|
18
17
|
if (Buffer.isBuffer(obj[k])) {
|
|
19
18
|
obj[k] = obj[k].toString('hex');
|
|
20
19
|
}
|
|
@@ -24,5 +23,4 @@ function eachRecursive(obj) {
|
|
|
24
23
|
}
|
|
25
24
|
return obj;
|
|
26
25
|
}
|
|
27
|
-
exports.eachRecursive = eachRecursive;
|
|
28
26
|
//# 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,oCAQC;AAGD,sCAYC;AAvBD,SAAgB,YAAY,CAAI,OAAY,EAAE,QAAa;IACzD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YAClC,OAAO,IAAI,CAAA;QACb,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AAED,2CAA2C;AAC3C,SAAgB,aAAa,CAAC,GAAsB;IAClD,kCAAkC;IAClC,KAAK,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;QACpB,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5B,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACjC,CAAC;QACD,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YAClD,GAAG,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QAChC,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
package/v1/utils/key.d.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { ExtendedPublicKey, ExtendedSecretKey, PublicKey, SecretKey } from '@airgap/module-kit';
|
|
3
2
|
import { ExcludeTyped, ExtractTyped } from '@airgap/module-kit/types/meta/utility-types';
|
|
4
3
|
import { BitcoinExtendedPublicKeyEncoding, BitcoinExtendedSecretKeyEncoding, BitcoinSegwitExtendedPublicKeyEncoding, BitcoinSegwitExtendedSecretKeyEncoding, BitcoinTestnetExtendedPublicKeyEncoding, BitcoinTestnetExtendedSecretKeyEncoding } from '../types/key';
|
|
5
4
|
declare const EXT_SK_PREFIX: Record<BitcoinExtendedSecretKeyEncoding, string>;
|
|
6
5
|
declare const EXT_SK_TESTNET_PREFIX: Record<BitcoinTestnetExtendedSecretKeyEncoding, string>;
|
|
7
6
|
declare const EXT_SK_SEGWIT_PREFIX: Record<BitcoinSegwitExtendedSecretKeyEncoding, string>;
|
|
8
|
-
export
|
|
7
|
+
export type ExtendedSecretKeyEncoding = keyof typeof EXT_SK_PREFIX | keyof typeof EXT_SK_TESTNET_PREFIX | keyof typeof EXT_SK_SEGWIT_PREFIX;
|
|
9
8
|
declare const EXT_PK_PREFIX: Record<BitcoinExtendedPublicKeyEncoding, string>;
|
|
10
9
|
declare const EXT_PK_TESTNET_PREFIX: Record<BitcoinTestnetExtendedPublicKeyEncoding, string>;
|
|
11
10
|
declare const EXT_PK_SEGWIT_PREFIX: Record<BitcoinSegwitExtendedPublicKeyEncoding, string>;
|
|
12
|
-
export
|
|
13
|
-
|
|
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;
|
|
14
13
|
export declare function convertSecretKey(secretKey: SecretKey, targetFormat: SecretKey['format']): SecretKey;
|
|
15
|
-
|
|
14
|
+
type ConvertExtendedSecretKeyTarget = {
|
|
16
15
|
format: ExcludeTyped<ExtendedSecretKey['format'], 'encoded'>;
|
|
17
16
|
hashFunction?: HashFunction;
|
|
18
17
|
} | {
|
|
@@ -22,7 +21,7 @@ declare type ConvertExtendedSecretKeyTarget = {
|
|
|
22
21
|
};
|
|
23
22
|
export declare function convertExtendedSecretKey(extendedSecretKey: ExtendedSecretKey, target: ConvertExtendedSecretKeyTarget): ExtendedSecretKey;
|
|
24
23
|
export declare function convertPublicKey(publicKey: PublicKey, targetFormat: PublicKey['format']): PublicKey;
|
|
25
|
-
|
|
24
|
+
type ConvertExtendedPublicKeyTarget = {
|
|
26
25
|
format: ExcludeTyped<ExtendedPublicKey['format'], 'encoded'>;
|
|
27
26
|
hashFunction?: HashFunction;
|
|
28
27
|
} | {
|