@airgap/bitcoin 0.13.11-beta.0 → 0.13.11-beta.1
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 +11 -9
- package/airgap-coinlib-bitcoin.min.js +0 -99733
- package/index.d.ts +0 -1
- package/index.js +0 -18
- package/index.js.map +0 -1
- package/v0/index.d.ts +0 -14
- package/v0/index.js +0 -34
- package/v0/index.js.map +0 -1
- package/v0/protocol/BitcoinAddress.d.ts +0 -9
- package/v0/protocol/BitcoinAddress.js +0 -23
- package/v0/protocol/BitcoinAddress.js.map +0 -1
- package/v0/protocol/BitcoinCryptoClient.d.ts +0 -11
- package/v0/protocol/BitcoinCryptoClient.js +0 -91
- package/v0/protocol/BitcoinCryptoClient.js.map +0 -1
- package/v0/protocol/BitcoinProtocol.d.ts +0 -167
- package/v0/protocol/BitcoinProtocol.js +0 -1063
- package/v0/protocol/BitcoinProtocol.js.map +0 -1
- package/v0/protocol/BitcoinProtocolOptions.d.ts +0 -26
- package/v0/protocol/BitcoinProtocolOptions.js +0 -148
- package/v0/protocol/BitcoinProtocolOptions.js.map +0 -1
- package/v0/protocol/BitcoinSegwitAddress.d.ts +0 -7
- package/v0/protocol/BitcoinSegwitAddress.js +0 -41
- package/v0/protocol/BitcoinSegwitAddress.js.map +0 -1
- package/v0/protocol/BitcoinSegwitProtocol.d.ts +0 -28
- package/v0/protocol/BitcoinSegwitProtocol.js +0 -541
- package/v0/protocol/BitcoinSegwitProtocol.js.map +0 -1
- package/v0/protocol/BitcoinTestnetProtocol.d.ts +0 -7
- package/v0/protocol/BitcoinTestnetProtocol.js +0 -58
- package/v0/protocol/BitcoinTestnetProtocol.js.map +0 -1
- package/v0/protocol/BitcoinTypes.d.ts +0 -21
- package/v0/protocol/BitcoinTypes.js +0 -3
- package/v0/protocol/BitcoinTypes.js.map +0 -1
- package/v0/serializer/schemas/v2/transaction-sign-request-bitcoin-segwit.json +0 -0
- package/v0/serializer/schemas/v2/transaction-sign-request-bitcoin.json +0 -73
- package/v0/serializer/schemas/v2/transaction-sign-response-bitcoin-segwit.json +0 -0
- package/v0/serializer/schemas/v2/transaction-sign-response-bitcoin.json +0 -37
- package/v0/serializer/schemas/v3/transaction-sign-request-bitcoin-segwit.json +0 -29
- package/v0/serializer/schemas/v3/transaction-sign-request-bitcoin.json +0 -73
- package/v0/serializer/schemas/v3/transaction-sign-response-bitcoin-segwit.json +0 -19
- package/v0/serializer/schemas/v3/transaction-sign-response-bitcoin.json +0 -37
- package/v0/serializer/validators/transaction-validator.d.ts +0 -15
- package/v0/serializer/validators/transaction-validator.js +0 -81
- package/v0/serializer/validators/transaction-validator.js.map +0 -1
- package/v0/serializer/validators/validators.d.ts +0 -1
- package/v0/serializer/validators/validators.js +0 -151
- package/v0/serializer/validators/validators.js.map +0 -1
- package/v0/types/signed-transaction-bitcoin-segwit.d.ts +0 -5
- package/v0/types/signed-transaction-bitcoin-segwit.js +0 -3
- package/v0/types/signed-transaction-bitcoin-segwit.js.map +0 -1
- package/v0/types/signed-transaction-bitcoin.d.ts +0 -9
- package/v0/types/signed-transaction-bitcoin.js +0 -3
- package/v0/types/signed-transaction-bitcoin.js.map +0 -1
- package/v0/types/transaction-bitcoin.d.ts +0 -20
- package/v0/types/transaction-bitcoin.js +0 -3
- package/v0/types/transaction-bitcoin.js.map +0 -1
- package/v0/types/unsigned-transaction-bitcoin-segwit.d.ts +0 -7
- package/v0/types/unsigned-transaction-bitcoin-segwit.js +0 -3
- package/v0/types/unsigned-transaction-bitcoin-segwit.js.map +0 -1
- package/v0/types/unsigned-transaction-bitcoin.d.ts +0 -22
- package/v0/types/unsigned-transaction-bitcoin.js +0 -3
- package/v0/types/unsigned-transaction-bitcoin.js.map +0 -1
- package/v1/block-explorer/BlockCypherBlockExplorer.d.ts +0 -9
- package/v1/block-explorer/BlockCypherBlockExplorer.js +0 -74
- package/v1/block-explorer/BlockCypherBlockExplorer.js.map +0 -1
- package/v1/data/BitcoinAddress.d.ts +0 -7
- package/v1/data/BitcoinAddress.js +0 -20
- package/v1/data/BitcoinAddress.js.map +0 -1
- package/v1/data/BitcoinSegwitAddress.d.ts +0 -8
- package/v1/data/BitcoinSegwitAddress.js +0 -25
- package/v1/data/BitcoinSegwitAddress.js.map +0 -1
- package/v1/index.d.ts +0 -19
- package/v1/index.js +0 -24
- package/v1/index.js.map +0 -1
- package/v1/module/BitcoinModule.d.ts +0 -16
- package/v1/module/BitcoinModule.js +0 -112
- package/v1/module/BitcoinModule.js.map +0 -1
- package/v1/module.d.ts +0 -3
- package/v1/module.js +0 -24
- package/v1/module.js.map +0 -1
- package/v1/protocol/BitcoinCryptoClient.d.ts +0 -12
- package/v1/protocol/BitcoinCryptoClient.js +0 -96
- package/v1/protocol/BitcoinCryptoClient.js.map +0 -1
- package/v1/protocol/BitcoinProtocol.d.ts +0 -69
- package/v1/protocol/BitcoinProtocol.js +0 -1211
- package/v1/protocol/BitcoinProtocol.js.map +0 -1
- package/v1/protocol/BitcoinSegwitProtocol.d.ts +0 -52
- package/v1/protocol/BitcoinSegwitProtocol.js +0 -751
- package/v1/protocol/BitcoinSegwitProtocol.js.map +0 -1
- package/v1/protocol/BitcoinTestnetProtocol.d.ts +0 -11
- package/v1/protocol/BitcoinTestnetProtocol.js +0 -67
- package/v1/protocol/BitcoinTestnetProtocol.js.map +0 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +0 -13
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +0 -75
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +0 -1
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin-segwit.d.ts +0 -4
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin-segwit.js +0 -3
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin-segwit.js.map +0 -1
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin.d.ts +0 -4
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin.js +0 -3
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin.js.map +0 -1
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin-segwit.d.ts +0 -3
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin-segwit.js +0 -3
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin-segwit.js.map +0 -1
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin.d.ts +0 -7
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin.js +0 -3
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin.js.map +0 -1
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-bitcoin-segwit.json +0 -29
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-bitcoin.json +0 -79
- package/v1/serializer/v3/schemas/generated/transaction-sign-response-bitcoin-segwit.json +0 -19
- package/v1/serializer/v3/schemas/generated/transaction-sign-response-bitcoin.json +0 -37
- package/v1/serializer/v3/serializer-companion.d.ts +0 -14
- package/v1/serializer/v3/serializer-companion.js +0 -197
- package/v1/serializer/v3/serializer-companion.js.map +0 -1
- package/v1/serializer/v3/validators/transaction-validator.d.ts +0 -7
- package/v1/serializer/v3/validators/transaction-validator.js +0 -56
- package/v1/serializer/v3/validators/transaction-validator.js.map +0 -1
- package/v1/serializer/v3/validators/validators.d.ts +0 -7
- package/v1/serializer/v3/validators/validators.js +0 -254
- package/v1/serializer/v3/validators/validators.js.map +0 -1
- package/v1/types/bitcoinjs.d.ts +0 -14
- package/v1/types/bitcoinjs.js +0 -3
- package/v1/types/bitcoinjs.js.map +0 -1
- package/v1/types/indexer.d.ts +0 -81
- package/v1/types/indexer.js +0 -3
- package/v1/types/indexer.js.map +0 -1
- package/v1/types/key.d.ts +0 -6
- package/v1/types/key.js +0 -3
- package/v1/types/key.js.map +0 -1
- package/v1/types/protocol.d.ts +0 -17
- package/v1/types/protocol.js +0 -3
- package/v1/types/protocol.js.map +0 -1
- package/v1/types/transaction.d.ts +0 -39
- package/v1/types/transaction.js +0 -3
- package/v1/types/transaction.js.map +0 -1
- package/v1/utils/common.d.ts +0 -2
- package/v1/utils/common.js +0 -28
- package/v1/utils/common.js.map +0 -1
- package/v1/utils/key.d.ts +0 -12
- package/v1/utils/key.js +0 -158
- package/v1/utils/key.js.map +0 -1
- package/v1/utils/network.d.ts +0 -2
- package/v1/utils/network.js +0 -22
- package/v1/utils/network.js.map +0 -1
- package/v1/utils/signature.d.ts +0 -2
- package/v1/utils/signature.js +0 -34
- package/v1/utils/signature.js.map +0 -1
|
@@ -1,197 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.BitcoinV3SerializerCompanion = void 0;
|
|
40
|
-
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
41
|
-
var validate_1 = require("@airgap/coinlib-core/dependencies/src/validate.js-0.13.1/validate");
|
|
42
|
-
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
43
|
-
var serializer_1 = require("@airgap/serializer");
|
|
44
|
-
var transaction_converter_1 = require("./schemas/converter/transaction-converter");
|
|
45
|
-
var transaction_validator_1 = require("./validators/transaction-validator");
|
|
46
|
-
var validators_1 = require("./validators/validators");
|
|
47
|
-
var bitcoinTransactionSignRequest = require('./schemas/generated/transaction-sign-request-bitcoin.json');
|
|
48
|
-
var bitcoinTransactionSignResponse = require('./schemas/generated/transaction-sign-response-bitcoin.json');
|
|
49
|
-
var bitcoinSegwitTransactionSignRequest = require('./schemas/generated/transaction-sign-request-bitcoin-segwit.json');
|
|
50
|
-
var bitcoinSegwitTransactionSignResponse = require('./schemas/generated/transaction-sign-response-bitcoin-segwit.json');
|
|
51
|
-
var BitcoinV3SerializerCompanion = /** @class */ (function () {
|
|
52
|
-
function BitcoinV3SerializerCompanion() {
|
|
53
|
-
this.schemas = [
|
|
54
|
-
{
|
|
55
|
-
type: serializer_1.IACMessageType.TransactionSignRequest,
|
|
56
|
-
schema: { schema: bitcoinTransactionSignRequest },
|
|
57
|
-
protocolIdentifier: coinlib_core_1.MainProtocolSymbols.BTC
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
type: serializer_1.IACMessageType.TransactionSignResponse,
|
|
61
|
-
schema: { schema: bitcoinTransactionSignResponse },
|
|
62
|
-
protocolIdentifier: coinlib_core_1.MainProtocolSymbols.BTC
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
type: serializer_1.IACMessageType.TransactionSignRequest,
|
|
66
|
-
schema: { schema: bitcoinSegwitTransactionSignRequest },
|
|
67
|
-
protocolIdentifier: coinlib_core_1.MainProtocolSymbols.BTC_SEGWIT
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
type: serializer_1.IACMessageType.TransactionSignResponse,
|
|
71
|
-
schema: { schema: bitcoinSegwitTransactionSignResponse },
|
|
72
|
-
protocolIdentifier: coinlib_core_1.MainProtocolSymbols.BTC_SEGWIT
|
|
73
|
-
}
|
|
74
|
-
];
|
|
75
|
-
this.bitcoinTransactionValidator = new transaction_validator_1.BitcoinTransactionValidator();
|
|
76
|
-
Object.keys(validators_1.bitcoinValidators).forEach(function (key) {
|
|
77
|
-
validate_1.validators[key] = validators_1.bitcoinValidators[key];
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
BitcoinV3SerializerCompanion.prototype.toTransactionSignRequest = function (identifier, unsignedTransaction, publicKey, callbackUrl) {
|
|
81
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
82
|
-
return __generator(this, function (_a) {
|
|
83
|
-
switch (identifier) {
|
|
84
|
-
case coinlib_core_1.MainProtocolSymbols.BTC:
|
|
85
|
-
return [2 /*return*/, (0, transaction_converter_1.bitcoinUnsignedTransactionToRequest)(unsignedTransaction, publicKey, callbackUrl)];
|
|
86
|
-
case coinlib_core_1.MainProtocolSymbols.BTC_SEGWIT:
|
|
87
|
-
return [2 /*return*/, (0, transaction_converter_1.bitcoinSegwitUnsignedTransactionToRequest)(unsignedTransaction, publicKey, callbackUrl)];
|
|
88
|
-
default:
|
|
89
|
-
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, "Protocol ".concat(identifier, " not supported"));
|
|
90
|
-
}
|
|
91
|
-
return [2 /*return*/];
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
BitcoinV3SerializerCompanion.prototype.fromTransactionSignRequest = function (identifier, transactionSignRequest) {
|
|
96
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
97
|
-
return __generator(this, function (_a) {
|
|
98
|
-
switch (identifier) {
|
|
99
|
-
case coinlib_core_1.MainProtocolSymbols.BTC:
|
|
100
|
-
return [2 /*return*/, (0, transaction_converter_1.bitcoinTransactionSignRequestToUnsigned)(transactionSignRequest)];
|
|
101
|
-
case coinlib_core_1.MainProtocolSymbols.BTC_SEGWIT:
|
|
102
|
-
return [2 /*return*/, (0, transaction_converter_1.bitcoinSegwitTransactionSignRequestToUnsigned)(transactionSignRequest)];
|
|
103
|
-
default:
|
|
104
|
-
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, "Protocol ".concat(identifier, " not supported"));
|
|
105
|
-
}
|
|
106
|
-
return [2 /*return*/];
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
};
|
|
110
|
-
BitcoinV3SerializerCompanion.prototype.validateTransactionSignRequest = function (identifier, transactionSignRequest) {
|
|
111
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
112
|
-
var _a, _b;
|
|
113
|
-
return __generator(this, function (_c) {
|
|
114
|
-
switch (_c.label) {
|
|
115
|
-
case 0:
|
|
116
|
-
_a = identifier;
|
|
117
|
-
switch (_a) {
|
|
118
|
-
case coinlib_core_1.MainProtocolSymbols.BTC: return [3 /*break*/, 1];
|
|
119
|
-
case coinlib_core_1.MainProtocolSymbols.BTC_SEGWIT: return [3 /*break*/, 4];
|
|
120
|
-
}
|
|
121
|
-
return [3 /*break*/, 5];
|
|
122
|
-
case 1:
|
|
123
|
-
_c.trys.push([1, 3, , 4]);
|
|
124
|
-
return [4 /*yield*/, this.bitcoinTransactionValidator.validateUnsignedTransaction(transactionSignRequest)];
|
|
125
|
-
case 2:
|
|
126
|
-
_c.sent();
|
|
127
|
-
return [2 /*return*/, true];
|
|
128
|
-
case 3:
|
|
129
|
-
_b = _c.sent();
|
|
130
|
-
return [2 /*return*/, false];
|
|
131
|
-
case 4: return [2 /*return*/, true];
|
|
132
|
-
case 5: throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, "Protocol ".concat(identifier, " not supported"));
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
};
|
|
137
|
-
BitcoinV3SerializerCompanion.prototype.toTransactionSignResponse = function (identifier, signedTransaction, accountIdentifier) {
|
|
138
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
139
|
-
return __generator(this, function (_a) {
|
|
140
|
-
switch (identifier) {
|
|
141
|
-
case coinlib_core_1.MainProtocolSymbols.BTC:
|
|
142
|
-
return [2 /*return*/, (0, transaction_converter_1.bitcoinSignedTransactionToResponse)(signedTransaction, accountIdentifier)];
|
|
143
|
-
case coinlib_core_1.MainProtocolSymbols.BTC_SEGWIT:
|
|
144
|
-
return [2 /*return*/, (0, transaction_converter_1.bitcoinSegwitSignedTransactionToResponse)(signedTransaction, accountIdentifier)];
|
|
145
|
-
default:
|
|
146
|
-
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, "Protocol ".concat(identifier, " not supported"));
|
|
147
|
-
}
|
|
148
|
-
return [2 /*return*/];
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
};
|
|
152
|
-
BitcoinV3SerializerCompanion.prototype.fromTransactionSignResponse = function (identifier, transactionSignResponse) {
|
|
153
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
154
|
-
return __generator(this, function (_a) {
|
|
155
|
-
switch (identifier) {
|
|
156
|
-
case coinlib_core_1.MainProtocolSymbols.BTC:
|
|
157
|
-
return [2 /*return*/, (0, transaction_converter_1.bitcoinTransactionSignResponseToSigned)(transactionSignResponse)];
|
|
158
|
-
case coinlib_core_1.MainProtocolSymbols.BTC_SEGWIT:
|
|
159
|
-
return [2 /*return*/, (0, transaction_converter_1.bitcoinSegwitTransactionSignResponseToSigned)(transactionSignResponse)];
|
|
160
|
-
default:
|
|
161
|
-
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, "Protocol ".concat(identifier, " not supported"));
|
|
162
|
-
}
|
|
163
|
-
return [2 /*return*/];
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
};
|
|
167
|
-
BitcoinV3SerializerCompanion.prototype.validateTransactionSignResponse = function (identifier, transactionSignResponse) {
|
|
168
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
169
|
-
var _a, _b;
|
|
170
|
-
return __generator(this, function (_c) {
|
|
171
|
-
switch (_c.label) {
|
|
172
|
-
case 0:
|
|
173
|
-
_a = identifier;
|
|
174
|
-
switch (_a) {
|
|
175
|
-
case coinlib_core_1.MainProtocolSymbols.BTC: return [3 /*break*/, 1];
|
|
176
|
-
case coinlib_core_1.MainProtocolSymbols.BTC_SEGWIT: return [3 /*break*/, 4];
|
|
177
|
-
}
|
|
178
|
-
return [3 /*break*/, 5];
|
|
179
|
-
case 1:
|
|
180
|
-
_c.trys.push([1, 3, , 4]);
|
|
181
|
-
return [4 /*yield*/, this.bitcoinTransactionValidator.validateSignedTransaction(transactionSignResponse)];
|
|
182
|
-
case 2:
|
|
183
|
-
_c.sent();
|
|
184
|
-
return [2 /*return*/, true];
|
|
185
|
-
case 3:
|
|
186
|
-
_b = _c.sent();
|
|
187
|
-
return [2 /*return*/, false];
|
|
188
|
-
case 4: return [2 /*return*/, true];
|
|
189
|
-
case 5: throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, "Protocol ".concat(identifier, " not supported"));
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
};
|
|
194
|
-
return BitcoinV3SerializerCompanion;
|
|
195
|
-
}());
|
|
196
|
-
exports.BitcoinV3SerializerCompanion = BitcoinV3SerializerCompanion;
|
|
197
|
-
//# sourceMappingURL=serializer-companion.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serializer-companion.js","sourceRoot":"","sources":["../../../../src/v1/serializer/v3/serializer-companion.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAkE;AAClE,8FAA8F;AAC9F,sDAA8D;AAG9D,iDAAgH;AAShH,mFASkD;AAElD,4EAAgF;AAChF,sDAA2D;AAE3D,IAAM,6BAA6B,GAAe,OAAO,CAAC,2DAA2D,CAAC,CAAA;AACtH,IAAM,8BAA8B,GAAe,OAAO,CAAC,4DAA4D,CAAC,CAAA;AAExH,IAAM,mCAAmC,GAAe,OAAO,CAAC,kEAAkE,CAAC,CAAA;AACnI,IAAM,oCAAoC,GAAe,OAAO,CAAC,mEAAmE,CAAC,CAAA;AAErI;IA0BE;QAzBgB,YAAO,GAA4B;YACjD;gBACE,IAAI,EAAE,2BAAc,CAAC,sBAAsB;gBAC3C,MAAM,EAAE,EAAE,MAAM,EAAE,6BAA6B,EAAE;gBACjD,kBAAkB,EAAE,kCAAmB,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D,QAAQ,UAAU,EAAE;oBAClB,KAAK,kCAAmB,CAAC,GAAG;wBAC1B,sBAAO,IAAA,8DAAsC,EAAC,uBAAyD,CAAC,EAAA;oBAC1G,KAAK,kCAAmB,CAAC,UAAU;wBACjC,sBAAO,IAAA,oEAA4C,EAAC,uBAAyD,CAAC,EAAA;oBAChH;wBACE,MAAM,IAAI,yBAAgB,CAAC,qBAAM,CAAC,OAAO,EAAE,mBAAY,UAAU,mBAAgB,CAAC,CAAA;iBACrF;;;;KACF;IAEY,sEAA+B,GAA5C,UAA6C,UAAkB,EAAE,uBAAgD;;;;;;wBACvG,KAAA,UAAU,CAAA;;iCACX,kCAAmB,CAAC,GAAG,CAAC,CAAxB,wBAAuB;iCAQvB,kCAAmB,CAAC,UAAU,CAAC,CAA/B,wBAA8B;;;;;wBAN/B,qBAAM,IAAI,CAAC,2BAA2B,CAAC,yBAAyB,CAAC,uBAAyD,CAAC,EAAA;;wBAA3H,SAA2H,CAAA;wBAE3H,sBAAO,IAAI,EAAA;;;wBAEX,sBAAO,KAAK,EAAA;4BAGd,sBAAO,IAAI,EAAA;4BAEX,MAAM,IAAI,yBAAgB,CAAC,qBAAM,CAAC,OAAO,EAAE,mBAAY,UAAU,mBAAgB,CAAC,CAAA;;;;KAEvF;IACH,mCAAC;AAAD,CAAC,AA5HD,IA4HC;AA5HY,oEAA4B"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { TransactionValidator } from '@airgap/serializer';
|
|
2
|
-
import { BitcoinTransactionSignRequest } from '../schemas/definitions/transaction-sign-request-bitcoin';
|
|
3
|
-
import { BitcoinTransactionSignResponse } from '../schemas/definitions/transaction-sign-response-bitcoin';
|
|
4
|
-
export declare class BitcoinTransactionValidator implements TransactionValidator {
|
|
5
|
-
validateUnsignedTransaction(request: BitcoinTransactionSignRequest): Promise<any>;
|
|
6
|
-
validateSignedTransaction(response: BitcoinTransactionSignResponse): Promise<any>;
|
|
7
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BitcoinTransactionValidator = void 0;
|
|
4
|
-
// tslint:disable: max-classes-per-file
|
|
5
|
-
var validate_1 = require("@airgap/coinlib-core/dependencies/src/validate.js-0.13.1/validate");
|
|
6
|
-
var serializer_1 = require("@airgap/serializer");
|
|
7
|
-
var unsignedTransactionConstraints = {
|
|
8
|
-
ins: {
|
|
9
|
-
presence: { allowEmpty: false },
|
|
10
|
-
isValidBitcoinInput: true
|
|
11
|
-
},
|
|
12
|
-
outs: {
|
|
13
|
-
presence: { allowEmpty: false },
|
|
14
|
-
isValidBitcoinOutput: true
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var signedTransactionConstraints = {
|
|
18
|
-
from: {
|
|
19
|
-
presence: { allowEmpty: false },
|
|
20
|
-
isValidBitcoinFromArray: true
|
|
21
|
-
},
|
|
22
|
-
amount: {
|
|
23
|
-
type: 'BigNumber',
|
|
24
|
-
presence: { allowEmpty: false }
|
|
25
|
-
},
|
|
26
|
-
fee: {
|
|
27
|
-
type: 'BigNumber',
|
|
28
|
-
presence: { allowEmpty: false }
|
|
29
|
-
},
|
|
30
|
-
accountIdentifier: {
|
|
31
|
-
type: 'String',
|
|
32
|
-
presence: { allowEmpty: false }
|
|
33
|
-
},
|
|
34
|
-
transaction: {
|
|
35
|
-
isValidBitcoinTxString: true,
|
|
36
|
-
type: 'String',
|
|
37
|
-
presence: { allowEmpty: false }
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
var success = function () { return undefined; };
|
|
41
|
-
var error = function (errors) { return errors; };
|
|
42
|
-
var BitcoinTransactionValidator = /** @class */ (function () {
|
|
43
|
-
function BitcoinTransactionValidator() {
|
|
44
|
-
}
|
|
45
|
-
BitcoinTransactionValidator.prototype.validateUnsignedTransaction = function (request) {
|
|
46
|
-
var transaction = request.transaction;
|
|
47
|
-
(0, serializer_1.validateSyncScheme)({});
|
|
48
|
-
return (0, validate_1.async)(transaction, unsignedTransactionConstraints).then(success, error);
|
|
49
|
-
};
|
|
50
|
-
BitcoinTransactionValidator.prototype.validateSignedTransaction = function (response) {
|
|
51
|
-
return (0, validate_1.async)(response, signedTransactionConstraints).then(success, error);
|
|
52
|
-
};
|
|
53
|
-
return BitcoinTransactionValidator;
|
|
54
|
-
}());
|
|
55
|
-
exports.BitcoinTransactionValidator = BitcoinTransactionValidator;
|
|
56
|
-
//# sourceMappingURL=transaction-validator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-validator.js","sourceRoot":"","sources":["../../../../../src/v1/serializer/v3/validators/transaction-validator.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AACvC,8FAAyF;AACzF,iDAA6E;AAK7E,IAAM,8BAA8B,GAAG;IACrC,GAAG,EAAE;QACH,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,mBAAmB,EAAE,IAAI;KAC1B;IACD,IAAI,EAAE;QACJ,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,oBAAoB,EAAE,IAAI;KAC3B;CACF,CAAA;AAED,IAAM,4BAA4B,GAAG;IACnC,IAAI,EAAE;QACJ,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,uBAAuB,EAAE,IAAI;KAC9B;IACD,MAAM,EAAE;QACN,IAAI,EAAE,WAAW;QACjB,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;KAChC;IACD,GAAG,EAAE;QACH,IAAI,EAAE,WAAW;QACjB,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;KAChC;IACD,iBAAiB,EAAE;QACjB,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;KAChC;IACD,WAAW,EAAE;QACX,sBAAsB,EAAE,IAAI;QAC5B,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;KAChC;CACF,CAAA;AACD,IAAM,OAAO,GAAG,cAAM,OAAA,SAAS,EAAT,CAAS,CAAA;AAC/B,IAAM,KAAK,GAAG,UAAC,MAAM,IAAK,OAAA,MAAM,EAAN,CAAM,CAAA;AAEhC;IAAA;IAUA,CAAC;IATQ,iEAA2B,GAAlC,UAAmC,OAAsC;QACvE,IAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAA;QACvC,IAAA,+BAAkB,EAAC,EAAE,CAAC,CAAA;QAEtB,OAAO,IAAA,gBAAK,EAAC,WAAW,EAAE,8BAA8B,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAChF,CAAC;IACM,+DAAyB,GAAhC,UAAiC,QAAwC;QACvE,OAAO,IAAA,gBAAK,EAAC,QAAQ,EAAE,4BAA4B,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC3E,CAAC;IACH,kCAAC;AAAD,CAAC,AAVD,IAUC;AAVY,kEAA2B"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const bitcoinValidators: {
|
|
2
|
-
isValidBitcoinInput: (ins: unknown) => Promise<"not an array" | "doesn't have property txId " | "not a valid txId" | "doesn't have property value " | "value not a valid BigNumber" | "doesn't have property vout" | "vout is not a number" | "vout is not a positive value" | "doesn't have property address " | "not a valid bitcoin address" | "doesn't have property derivationPath" | "invalid derivation path" | null>;
|
|
3
|
-
isValidBitcoinOutput: (outs: unknown) => Promise<"not an array" | "doesn't have property value " | "doesn't have property recipient" | "invalid Bitcoin address" | "doesn't have property isChange " | "change is not a boolean" | "value is not BigNumber" | null>;
|
|
4
|
-
isValidBitcoinFromArray: (array: unknown) => Promise<"not a valid bitcoin address" | "not an array of Bitcoin addresses" | null>;
|
|
5
|
-
isBitcoinAccount: (accountIdentifier: string) => Promise<"not a valid Bitcoin account" | null>;
|
|
6
|
-
isValidBitcoinTxString: (transaction: string) => "is not a valid hex encoded Bitcoin transaction" | null;
|
|
7
|
-
};
|
|
@@ -1,254 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,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|
6
|
-
network: any;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
export interface BitcoinSegwitJS {
|
|
10
|
-
lib: typeof bitcoin;
|
|
11
|
-
config: {
|
|
12
|
-
network: bitcoin.Network;
|
|
13
|
-
};
|
|
14
|
-
}
|
package/v1/types/bitcoinjs.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bitcoinjs.js","sourceRoot":"","sources":["../../../src/v1/types/bitcoinjs.ts"],"names":[],"mappings":""}
|
package/v1/types/indexer.d.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
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
|
-
}
|