@airgap/bitcoin 0.13.7-beta.21 → 0.13.7-beta.23

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.
Files changed (159) hide show
  1. package/airgap-coinlib-bitcoin.min.js +16559 -4042
  2. package/index.d.ts +1 -14
  3. package/index.js +15 -19
  4. package/index.js.map +1 -1
  5. package/package.json +4 -2
  6. package/v0/index.d.ts +14 -0
  7. package/v0/index.js +34 -0
  8. package/v0/index.js.map +1 -0
  9. package/{protocol → v0/protocol}/BitcoinAddress.d.ts +0 -0
  10. package/{protocol → v0/protocol}/BitcoinAddress.js +0 -0
  11. package/v0/protocol/BitcoinAddress.js.map +1 -0
  12. package/{protocol → v0/protocol}/BitcoinCryptoClient.d.ts +0 -0
  13. package/{protocol → v0/protocol}/BitcoinCryptoClient.js +2 -0
  14. package/v0/protocol/BitcoinCryptoClient.js.map +1 -0
  15. package/{protocol → v0/protocol}/BitcoinProtocol.d.ts +0 -0
  16. package/{protocol → v0/protocol}/BitcoinProtocol.js +29 -21
  17. package/v0/protocol/BitcoinProtocol.js.map +1 -0
  18. package/{protocol → v0/protocol}/BitcoinProtocolOptions.d.ts +0 -0
  19. package/{protocol → v0/protocol}/BitcoinProtocolOptions.js +9 -3
  20. package/v0/protocol/BitcoinProtocolOptions.js.map +1 -0
  21. package/{protocol → v0/protocol}/BitcoinSegwitAddress.d.ts +0 -0
  22. package/{protocol → v0/protocol}/BitcoinSegwitAddress.js +2 -0
  23. package/v0/protocol/BitcoinSegwitAddress.js.map +1 -0
  24. package/{protocol → v0/protocol}/BitcoinSegwitProtocol.d.ts +0 -0
  25. package/{protocol → v0/protocol}/BitcoinSegwitProtocol.js +32 -21
  26. package/v0/protocol/BitcoinSegwitProtocol.js.map +1 -0
  27. package/{protocol → v0/protocol}/BitcoinTestnetProtocol.d.ts +0 -0
  28. package/{protocol → v0/protocol}/BitcoinTestnetProtocol.js +7 -1
  29. package/v0/protocol/BitcoinTestnetProtocol.js.map +1 -0
  30. package/{protocol → v0/protocol}/BitcoinTypes.d.ts +0 -0
  31. package/{protocol → v0/protocol}/BitcoinTypes.js +0 -0
  32. package/v0/protocol/BitcoinTypes.js.map +1 -0
  33. package/v0/serializer/schemas/v2/transaction-sign-request-bitcoin-segwit.json +0 -0
  34. package/v0/serializer/schemas/v2/transaction-sign-request-bitcoin.json +73 -0
  35. package/v0/serializer/schemas/v2/transaction-sign-response-bitcoin-segwit.json +0 -0
  36. package/v0/serializer/schemas/v2/transaction-sign-response-bitcoin.json +37 -0
  37. package/v0/serializer/schemas/v3/transaction-sign-request-bitcoin-segwit.json +32 -0
  38. package/v0/serializer/schemas/v3/transaction-sign-request-bitcoin.json +73 -0
  39. package/v0/serializer/schemas/v3/transaction-sign-response-bitcoin-segwit.json +19 -0
  40. package/v0/serializer/schemas/v3/transaction-sign-response-bitcoin.json +37 -0
  41. package/v0/serializer/validators/transaction-validator.d.ts +15 -0
  42. package/v0/serializer/validators/transaction-validator.js +81 -0
  43. package/v0/serializer/validators/transaction-validator.js.map +1 -0
  44. package/v0/serializer/validators/validators.d.ts +1 -0
  45. package/v0/serializer/validators/validators.js +151 -0
  46. package/v0/serializer/validators/validators.js.map +1 -0
  47. package/v0/types/signed-transaction-bitcoin-segwit.d.ts +5 -0
  48. package/{types → v0/types}/signed-transaction-bitcoin-segwit.js +0 -0
  49. package/v0/types/signed-transaction-bitcoin-segwit.js.map +1 -0
  50. package/v0/types/signed-transaction-bitcoin.d.ts +9 -0
  51. package/{types → v0/types}/signed-transaction-bitcoin.js +0 -0
  52. package/v0/types/signed-transaction-bitcoin.js.map +1 -0
  53. package/{types → v0/types}/transaction-bitcoin.d.ts +0 -0
  54. package/{types → v0/types}/transaction-bitcoin.js +0 -0
  55. package/v0/types/transaction-bitcoin.js.map +1 -0
  56. package/v0/types/unsigned-transaction-bitcoin-segwit.d.ts +7 -0
  57. package/{types → v0/types}/unsigned-transaction-bitcoin-segwit.js +0 -0
  58. package/v0/types/unsigned-transaction-bitcoin-segwit.js.map +1 -0
  59. package/{types → v0/types}/unsigned-transaction-bitcoin.d.ts +2 -2
  60. package/{types → v0/types}/unsigned-transaction-bitcoin.js +0 -0
  61. package/v0/types/unsigned-transaction-bitcoin.js.map +1 -0
  62. package/v1/block-explorer/BlockCypherBlockExplorer.d.ts +9 -0
  63. package/v1/block-explorer/BlockCypherBlockExplorer.js +74 -0
  64. package/v1/block-explorer/BlockCypherBlockExplorer.js.map +1 -0
  65. package/v1/data/BitcoinAddress.d.ts +7 -0
  66. package/v1/data/BitcoinAddress.js +21 -0
  67. package/v1/data/BitcoinAddress.js.map +1 -0
  68. package/v1/data/BitcoinSegwitAddress.d.ts +8 -0
  69. package/v1/data/BitcoinSegwitAddress.js +26 -0
  70. package/v1/data/BitcoinSegwitAddress.js.map +1 -0
  71. package/v1/index.d.ts +20 -0
  72. package/v1/index.js +26 -0
  73. package/v1/index.js.map +1 -0
  74. package/v1/module/BitcoinModule.d.ts +8 -0
  75. package/v1/module/BitcoinModule.js +86 -0
  76. package/v1/module/BitcoinModule.js.map +1 -0
  77. package/v1/module/BitcoinSegwitModule.d.ts +8 -0
  78. package/v1/module/BitcoinSegwitModule.js +87 -0
  79. package/v1/module/BitcoinSegwitModule.js.map +1 -0
  80. package/v1/protocol/BitcoinCryptoClient.d.ts +12 -0
  81. package/v1/protocol/BitcoinCryptoClient.js +96 -0
  82. package/v1/protocol/BitcoinCryptoClient.js.map +1 -0
  83. package/v1/protocol/BitcoinProtocol.d.ts +68 -0
  84. package/v1/protocol/BitcoinProtocol.js +1198 -0
  85. package/v1/protocol/BitcoinProtocol.js.map +1 -0
  86. package/v1/protocol/BitcoinSegwitProtocol.d.ts +51 -0
  87. package/v1/protocol/BitcoinSegwitProtocol.js +734 -0
  88. package/v1/protocol/BitcoinSegwitProtocol.js.map +1 -0
  89. package/v1/protocol/BitcoinTestnetProtocol.d.ts +11 -0
  90. package/v1/protocol/BitcoinTestnetProtocol.js +67 -0
  91. package/v1/protocol/BitcoinTestnetProtocol.js.map +1 -0
  92. package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +13 -0
  93. package/v1/serializer/v3/schemas/converter/transaction-converter.js +54 -0
  94. package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -0
  95. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin-segwit.d.ts +4 -0
  96. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin-segwit.js +3 -0
  97. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin-segwit.js.map +1 -0
  98. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin.d.ts +4 -0
  99. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin.js +3 -0
  100. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin.js.map +1 -0
  101. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin-segwit.d.ts +3 -0
  102. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin-segwit.js +3 -0
  103. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin-segwit.js.map +1 -0
  104. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin.d.ts +7 -0
  105. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin.js +3 -0
  106. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin.js.map +1 -0
  107. package/v1/serializer/v3/schemas/generated/transaction-sign-request-bitcoin-segwit.json +36 -0
  108. package/v1/serializer/v3/schemas/generated/transaction-sign-request-bitcoin.json +86 -0
  109. package/v1/serializer/v3/schemas/generated/transaction-sign-response-bitcoin-segwit.json +19 -0
  110. package/v1/serializer/v3/schemas/generated/transaction-sign-response-bitcoin.json +37 -0
  111. package/v1/serializer/v3/validators/transaction-validators.d.ts +10 -0
  112. package/v1/serializer/v3/validators/transaction-validators.js +65 -0
  113. package/v1/serializer/v3/validators/transaction-validators.js.map +1 -0
  114. package/v1/serializer/v3/validators/validators.d.ts +7 -0
  115. package/v1/serializer/v3/validators/validators.js +254 -0
  116. package/v1/serializer/v3/validators/validators.js.map +1 -0
  117. package/v1/types/bitcoinjs.d.ts +14 -0
  118. package/v1/types/bitcoinjs.js +3 -0
  119. package/v1/types/bitcoinjs.js.map +1 -0
  120. package/v1/types/indexer.d.ts +81 -0
  121. package/v1/types/indexer.js +3 -0
  122. package/v1/types/indexer.js.map +1 -0
  123. package/v1/types/key.d.ts +6 -0
  124. package/v1/types/key.js +3 -0
  125. package/v1/types/key.js.map +1 -0
  126. package/v1/types/protocol.d.ts +17 -0
  127. package/v1/types/protocol.js +3 -0
  128. package/v1/types/protocol.js.map +1 -0
  129. package/v1/types/transaction.d.ts +39 -0
  130. package/v1/types/transaction.js +3 -0
  131. package/v1/types/transaction.js.map +1 -0
  132. package/v1/utils/common.d.ts +2 -0
  133. package/v1/utils/common.js +28 -0
  134. package/v1/utils/common.js.map +1 -0
  135. package/v1/utils/key.d.ts +12 -0
  136. package/v1/utils/key.js +157 -0
  137. package/v1/utils/key.js.map +1 -0
  138. package/v1/utils/network.d.ts +2 -0
  139. package/v1/utils/network.js +22 -0
  140. package/v1/utils/network.js.map +1 -0
  141. package/v1/utils/signature.d.ts +2 -0
  142. package/v1/utils/signature.js +34 -0
  143. package/v1/utils/signature.js.map +1 -0
  144. package/protocol/BitcoinAddress.js.map +0 -1
  145. package/protocol/BitcoinCryptoClient.js.map +0 -1
  146. package/protocol/BitcoinProtocol.js.map +0 -1
  147. package/protocol/BitcoinProtocolOptions.js.map +0 -1
  148. package/protocol/BitcoinSegwitAddress.js.map +0 -1
  149. package/protocol/BitcoinSegwitProtocol.js.map +0 -1
  150. package/protocol/BitcoinTestnetProtocol.js.map +0 -1
  151. package/protocol/BitcoinTypes.js.map +0 -1
  152. package/types/signed-transaction-bitcoin-segwit.d.ts +0 -5
  153. package/types/signed-transaction-bitcoin-segwit.js.map +0 -1
  154. package/types/signed-transaction-bitcoin.d.ts +0 -9
  155. package/types/signed-transaction-bitcoin.js.map +0 -1
  156. package/types/transaction-bitcoin.js.map +0 -1
  157. package/types/unsigned-transaction-bitcoin-segwit.d.ts +0 -7
  158. package/types/unsigned-transaction-bitcoin-segwit.js.map +0 -1
  159. package/types/unsigned-transaction-bitcoin.js.map +0 -1
@@ -0,0 +1,254 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.bitcoinValidators = void 0;
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");
46
+ exports.bitcoinValidators = {
47
+ isValidBitcoinInput: function (ins) { return __awaiter(void 0, void 0, void 0, function () {
48
+ var i, value, pattern, protocol, metadata, pattern, protocol, mnemonic, error_1;
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*/, 10];
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
+ if (!!value.hasOwnProperty('derivationPath')) return [3 /*break*/, 5];
106
+ return [2 /*return*/, "doesn't have property derivationPath"];
107
+ case 5:
108
+ protocol = (0, BitcoinProtocol_1.createBitcoinProtocol)();
109
+ _d.label = 6;
110
+ case 6:
111
+ _d.trys.push([6, 8, , 9]);
112
+ mnemonic = 'spell device they juice trial skirt amazing boat badge steak usage february virus art survey';
113
+ return [4 /*yield*/, protocol.getKeyPairFromSecret({ type: 'mnemonic', value: mnemonic }, value.derivationPath)];
114
+ case 7:
115
+ _d.sent();
116
+ return [3 /*break*/, 9];
117
+ case 8:
118
+ error_1 = _d.sent();
119
+ return [2 /*return*/, 'invalid derivation path'];
120
+ case 9:
121
+ i++;
122
+ return [3 /*break*/, 1];
123
+ case 10: return [2 /*return*/, null];
124
+ }
125
+ });
126
+ }); },
127
+ isValidBitcoinOutput: function (outs) { return __awaiter(void 0, void 0, void 0, function () {
128
+ var i, value, protocol, metadata, pattern;
129
+ var _a, _b, _c;
130
+ return __generator(this, function (_d) {
131
+ switch (_d.label) {
132
+ case 0:
133
+ // console.log(outs)
134
+ // if (!Array.isArray(outs)) {
135
+ // outs = [outs]
136
+ // }
137
+ if (!Array.isArray(outs)) {
138
+ return [2 /*return*/, 'not an array'];
139
+ }
140
+ i = 0;
141
+ _d.label = 1;
142
+ case 1:
143
+ if (!(i < outs.length)) return [3 /*break*/, 6];
144
+ value = outs[i];
145
+ if (!!value.hasOwnProperty('recipient')) return [3 /*break*/, 2];
146
+ return [2 /*return*/, "doesn't have property recipient"];
147
+ case 2:
148
+ protocol = (0, BitcoinProtocol_1.createBitcoinProtocol)();
149
+ return [4 /*yield*/, protocol.getMetadata()];
150
+ case 3:
151
+ metadata = _d.sent();
152
+ 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 : '.*');
153
+ if (!pattern.test(value.recipient)) {
154
+ return [2 /*return*/, 'invalid Bitcoin address'];
155
+ }
156
+ _d.label = 4;
157
+ case 4:
158
+ if (!value.hasOwnProperty('isChange')) {
159
+ return [2 /*return*/, "doesn't have property isChange "];
160
+ }
161
+ else {
162
+ if (typeof value.isChange !== 'boolean') {
163
+ return [2 /*return*/, 'change is not a boolean'];
164
+ }
165
+ }
166
+ if (!value.hasOwnProperty('value')) {
167
+ return [2 /*return*/, "doesn't have property value "];
168
+ }
169
+ else {
170
+ if (!bignumber_1.default.isBigNumber(value.value)) {
171
+ return [2 /*return*/, 'value is not BigNumber'];
172
+ }
173
+ }
174
+ _d.label = 5;
175
+ case 5:
176
+ i++;
177
+ return [3 /*break*/, 1];
178
+ case 6: return [2 /*return*/, null];
179
+ }
180
+ });
181
+ }); },
182
+ isValidBitcoinFromArray: function (array) { return __awaiter(void 0, void 0, void 0, function () {
183
+ var i, address, protocol, metadata, pattern;
184
+ var _a, _b, _c;
185
+ return __generator(this, function (_d) {
186
+ switch (_d.label) {
187
+ case 0:
188
+ if (!Array.isArray(array)) {
189
+ return [2 /*return*/, 'not an array of Bitcoin addresses'];
190
+ }
191
+ i = 0;
192
+ _d.label = 1;
193
+ case 1:
194
+ if (!(i < array.length)) return [3 /*break*/, 4];
195
+ address = array[i];
196
+ protocol = (0, BitcoinProtocol_1.createBitcoinProtocol)();
197
+ return [4 /*yield*/, protocol.getMetadata()];
198
+ case 2:
199
+ metadata = _d.sent();
200
+ 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 : '.*');
201
+ if (!pattern.test(address)) {
202
+ return [2 /*return*/, 'not a valid bitcoin address'];
203
+ }
204
+ _d.label = 3;
205
+ case 3:
206
+ i++;
207
+ return [3 /*break*/, 1];
208
+ case 4: return [2 /*return*/, null];
209
+ }
210
+ });
211
+ }); },
212
+ isBitcoinAccount: function (accountIdentifier) { return __awaiter(void 0, void 0, void 0, function () {
213
+ var protocol, derivedKey, error_2;
214
+ return __generator(this, function (_a) {
215
+ switch (_a.label) {
216
+ case 0:
217
+ if (accountIdentifier === null || typeof accountIdentifier === 'undefined') {
218
+ return [2 /*return*/, null];
219
+ }
220
+ _a.label = 1;
221
+ case 1:
222
+ _a.trys.push([1, 4, , 5]);
223
+ protocol = (0, BitcoinProtocol_1.createBitcoinProtocol)();
224
+ return [4 /*yield*/, protocol.deriveFromExtendedPublicKey((0, module_kit_1.newExtendedPublicKey)(accountIdentifier, 'encoded'), 0, 0)];
225
+ case 2:
226
+ derivedKey = _a.sent();
227
+ return [4 /*yield*/, protocol.getAddressFromPublicKey(derivedKey)];
228
+ case 3:
229
+ _a.sent();
230
+ return [2 /*return*/, null];
231
+ case 4:
232
+ error_2 = _a.sent();
233
+ return [2 /*return*/, 'not a valid Bitcoin account'];
234
+ case 5: return [2 /*return*/];
235
+ }
236
+ });
237
+ }); },
238
+ isValidBitcoinTxString: function (transaction) {
239
+ // allow empty values by default (needs to be checked by "presence" check)
240
+ if (transaction === null || typeof transaction === 'undefined') {
241
+ return null;
242
+ }
243
+ try {
244
+ var protocol = new BitcoinProtocol_1.BitcoinProtocolImpl();
245
+ var bitcoinJSLib = protocol.bitcoinJS.lib;
246
+ bitcoinJSLib.Transaction.fromHex(transaction);
247
+ return null;
248
+ }
249
+ catch (error) {
250
+ return 'is not a valid hex encoded Bitcoin transaction';
251
+ }
252
+ }
253
+ };
254
+ //# sourceMappingURL=validators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../../../src/v1/serializer/v3/validators/validators.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iHAA0F;AAC1F,iDAAyD;AAEzD,qEAA8F;AAEjF,QAAA,iBAAiB,GAAG;IAC/B,mBAAmB,EAAE,UAAO,GAAY;;;;;;oBACtC,6BAA6B;oBAC7B,gBAAgB;oBAChB,IAAI;oBACJ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;wBACvB,sBAAO,cAAc,EAAA;qBACtB;oBAEQ,CAAC,GAAW,CAAC;;;yBAAE,CAAA,CAAC,GAAG,GAAG,CAAC,MAAM,CAAA;oBAC9B,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;oBACpB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE;wBACjC,sBAAO,6BAA6B,EAAA;qBACrC;yBAAM;wBACC,OAAO,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAA;wBAC3C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;4BAC7B,sBAAO,kBAAkB,EAAA;yBAC1B;qBACF;oBACD,IAAI,CAAC,KAAK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uB,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"}
@@ -0,0 +1,14 @@
1
+ import type * as bitcoin from 'bitcoinjs-lib';
2
+ export interface BitcoinJS {
3
+ lib: any;
4
+ message: any;
5
+ config: {
6
+ network: any;
7
+ };
8
+ }
9
+ export interface BitcoinSegwitJS {
10
+ lib: typeof bitcoin;
11
+ config: {
12
+ network: bitcoin.Network;
13
+ };
14
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=bitcoinjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bitcoinjs.js","sourceRoot":"","sources":["../../../src/v1/types/bitcoinjs.ts"],"names":[],"mappings":""}
@@ -0,0 +1,81 @@
1
+ export interface UTXOResponse {
2
+ txid: string;
3
+ vout: number;
4
+ value: string;
5
+ height: number;
6
+ confirmations: number;
7
+ address: string;
8
+ path: string;
9
+ }
10
+ export interface Vin {
11
+ txid: string;
12
+ vout: number;
13
+ sequence: any;
14
+ n: number;
15
+ addresses: string[];
16
+ isAddress: boolean;
17
+ isOwn: boolean;
18
+ value: string;
19
+ hex: string;
20
+ }
21
+ export interface Vout {
22
+ value: string;
23
+ n: number;
24
+ hex: string;
25
+ addresses: string[];
26
+ isAddress: boolean;
27
+ isOwn?: boolean;
28
+ spent?: boolean;
29
+ }
30
+ export interface Transaction {
31
+ txid: string;
32
+ version: number;
33
+ vin: Vin[];
34
+ vout: Vout[];
35
+ blockHash: string;
36
+ blockHeight: number;
37
+ confirmations: number;
38
+ blockTime: number;
39
+ value: string;
40
+ valueIn: string;
41
+ fees: string;
42
+ hex: string;
43
+ }
44
+ export interface Token {
45
+ type: string;
46
+ name: string;
47
+ path: string;
48
+ transfers: number;
49
+ decimals: number;
50
+ balance: string;
51
+ totalReceived: string;
52
+ totalSent: string;
53
+ }
54
+ export interface XPubResponse {
55
+ page: number;
56
+ totalPages: number;
57
+ itemsOnPage: number;
58
+ address: string;
59
+ balance: string;
60
+ totalReceived: string;
61
+ totalSent: string;
62
+ unconfirmedBalance: string;
63
+ unconfirmedTxs: number;
64
+ txs: number;
65
+ transactions?: Transaction[];
66
+ totalTokens?: number;
67
+ tokens?: Token[];
68
+ }
69
+ export interface AddressResponse {
70
+ page: number;
71
+ totalPages: number;
72
+ itemsOnPage: number;
73
+ address: string;
74
+ balance: string;
75
+ totalReceived: string;
76
+ totalSent: string;
77
+ unconfirmedBalance: string;
78
+ unconfirmedTxs: number;
79
+ txs: number;
80
+ transactions?: Transaction[];
81
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=indexer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexer.js","sourceRoot":"","sources":["../../../src/v1/types/indexer.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export declare type BitcoinExtendedSecretKeyEncoding = 'xpriv';
2
+ export declare type BitcoinTestnetExtendedSecretKeyEncoding = 'tpriv';
3
+ export declare type BitcoinSegwitSecretKeyEncoding = BitcoinExtendedSecretKeyEncoding | 'ypriv' | 'zpriv';
4
+ export declare type BitcoinExtendedPublicKeyEncoding = 'xpub';
5
+ export declare type BitcoinTestnetExtendedPublicKeyEncoding = 'tpub';
6
+ export declare type BitcoinSegwitExtendedPublicKeyEncoding = BitcoinExtendedPublicKeyEncoding | 'ypub' | 'zpub';
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key.js","sourceRoot":"","sources":["../../../src/v1/types/key.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ import { ProtocolNetwork } from '@airgap/module-kit';
2
+ export declare type BitcoinUnits = 'BTC' | 'mBTC' | 'Satoshi';
3
+ interface BitcoinBaseProtocolNetwork extends ProtocolNetwork {
4
+ indexerApi: string;
5
+ }
6
+ export interface BitcoinStandardProtocolNetwork extends BitcoinBaseProtocolNetwork {
7
+ type: 'mainnet' | 'testnet';
8
+ }
9
+ export interface BitcoinCustomProtocolNetwork extends BitcoinBaseProtocolNetwork {
10
+ type: 'custom';
11
+ bitcoinjsNetworkName: string;
12
+ }
13
+ export declare type BitcoinProtocolNetwork = BitcoinStandardProtocolNetwork | BitcoinCustomProtocolNetwork;
14
+ export interface BitcoinProtocolOptions {
15
+ network: BitcoinProtocolNetwork;
16
+ }
17
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../src/v1/types/protocol.ts"],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
1
+ import { HexString, SignedTransaction, TransactionConfiguration, TransactionCursor, UnsignedTransaction } from '@airgap/module-kit';
2
+ import { BitcoinUnits } from './protocol';
3
+ export interface BitcoinInTransaction {
4
+ txId: string;
5
+ value: string;
6
+ vout: number;
7
+ address: string;
8
+ derivationPath?: string;
9
+ }
10
+ export interface BitcoinOutTransaction {
11
+ recipient: string;
12
+ isChange: boolean;
13
+ value: string;
14
+ derivationPath?: string;
15
+ }
16
+ export interface BitcoinUnsignedTransaction extends UnsignedTransaction {
17
+ ins: BitcoinInTransaction[];
18
+ outs: BitcoinOutTransaction[];
19
+ }
20
+ export interface BitcoinSignedTransaction extends SignedTransaction {
21
+ from: string[];
22
+ to: string[];
23
+ amount: string;
24
+ fee: string;
25
+ transaction: string;
26
+ }
27
+ export interface BitcoinSegwitUnsignedTransaction extends UnsignedTransaction {
28
+ psbt: string;
29
+ }
30
+ export interface BitcoinSegwitSignedTransaction extends SignedTransaction {
31
+ psbt: string;
32
+ }
33
+ export interface BitcoinTransactionCursor extends TransactionCursor {
34
+ page?: number;
35
+ }
36
+ export declare type SegwitTransactionConfiguration<_Units extends BitcoinUnits> = TransactionConfiguration<_Units> & {
37
+ masterFingerprint: HexString;
38
+ replaceByFee?: boolean;
39
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../src/v1/types/transaction.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export declare function containsSome<T>(needles: T[], haystack: T[]): boolean;
2
+ export declare function eachRecursive(obj: Object | Object[]): Object | Object[];
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.eachRecursive = exports.containsSome = void 0;
4
+ function containsSome(needles, haystack) {
5
+ for (var _i = 0, needles_1 = needles; _i < needles_1.length; _i++) {
6
+ var needle = needles_1[_i];
7
+ if (haystack.indexOf(needle) > -1) {
8
+ return true;
9
+ }
10
+ }
11
+ return false;
12
+ }
13
+ exports.containsSome = containsSome;
14
+ // This function handles arrays and objects
15
+ function eachRecursive(obj) {
16
+ // tslint:disable-next-line: forin
17
+ for (var k in obj) {
18
+ if (Buffer.isBuffer(obj[k])) {
19
+ obj[k] = obj[k].toString('hex');
20
+ }
21
+ if (typeof obj[k] === 'object' && obj[k] !== null) {
22
+ obj[k] = eachRecursive(obj[k]);
23
+ }
24
+ }
25
+ return obj;
26
+ }
27
+ exports.eachRecursive = eachRecursive;
28
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,12 @@
1
+ import { ExtendedPublicKey, ExtendedSecretKey, PublicKey, SecretKey } from '@airgap/module-kit';
2
+ export declare function convertSecretKey(secretKey: SecretKey, targetFormat: SecretKey['format']): SecretKey;
3
+ export declare function convertExtendedSecretKey(extendedSecretKey: ExtendedSecretKey, targetFormat: ExtendedSecretKey['format']): ExtendedSecretKey;
4
+ export declare function convertPublicKey(publicKey: PublicKey, targetFormat: PublicKey['format']): PublicKey;
5
+ declare type ConvertExtendedPublicKeyTarget<Encoding extends string> = {
6
+ format: Exclude<ExtendedPublicKey['format'], 'encoded'>;
7
+ } | {
8
+ format: Extract<ExtendedPublicKey['format'], 'encoded'>;
9
+ type: Encoding;
10
+ };
11
+ export declare function convertExtendedPublicKey<Encoding extends string>(extendedPublicKey: ExtendedPublicKey, target: ConvertExtendedPublicKeyTarget<Encoding>): ExtendedPublicKey;
12
+ export {};