@airgap/bitcoin 0.13.45-beta.2 → 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,56 +1,20 @@
|
|
|
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
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.BitcoinV3SerializerCompanion = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
4
|
+
const coinlib_core_1 = require("@airgap/coinlib-core");
|
|
5
|
+
const validate_1 = require("@airgap/coinlib-core/dependencies/src/validate.js-0.13.1/validate");
|
|
6
|
+
const errors_1 = require("@airgap/coinlib-core/errors");
|
|
7
|
+
const serializer_1 = require("@airgap/serializer");
|
|
8
|
+
const transaction_converter_1 = require("./schemas/converter/transaction-converter");
|
|
45
9
|
// import { BitcoinTransactionValidator } from './validators/transaction-validator'
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
10
|
+
const validators_1 = require("./validators/validators");
|
|
11
|
+
const bitcoinSegwitTransactionSignRequest = require('./schemas/generated/transaction-sign-request-bitcoin-segwit.json');
|
|
12
|
+
const bitcoinSegwitTransactionSignResponse = require('./schemas/generated/transaction-sign-response-bitcoin-segwit.json');
|
|
13
|
+
const bitcoinLegacyTransactionSignRequest = require('./schemas/generated/transaction-sign-request-bitcoin-legacy.json');
|
|
14
|
+
const bitcoinLegacyTransactionSignResponse = require('./schemas/generated/transaction-sign-response-bitcoin-legacy.json');
|
|
15
|
+
class BitcoinV3SerializerCompanion {
|
|
52
16
|
// private readonly bitcoinTransactionValidator: BitcoinTransactionValidator = new BitcoinTransactionValidator()
|
|
53
|
-
|
|
17
|
+
constructor() {
|
|
54
18
|
this.schemas = [
|
|
55
19
|
{
|
|
56
20
|
type: serializer_1.IACMessageType.TransactionSignRequest,
|
|
@@ -83,125 +47,94 @@ var BitcoinV3SerializerCompanion = /** @class */ (function () {
|
|
|
83
47
|
protocolIdentifier: coinlib_core_1.MainProtocolSymbols.BTC_TAPROOT
|
|
84
48
|
}
|
|
85
49
|
];
|
|
86
|
-
Object.keys(validators_1.bitcoinValidators).forEach(
|
|
50
|
+
Object.keys(validators_1.bitcoinValidators).forEach((key) => {
|
|
87
51
|
validate_1.validators[key] = validators_1.bitcoinValidators[key];
|
|
88
52
|
});
|
|
89
53
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, "Protocol ".concat(identifier, " not supported"));
|
|
176
|
-
}
|
|
177
|
-
return [2 /*return*/];
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
};
|
|
181
|
-
BitcoinV3SerializerCompanion.prototype.validateTransactionSignResponse = function (identifier, transactionSignResponse) {
|
|
182
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
183
|
-
return __generator(this, function (_a) {
|
|
184
|
-
switch (identifier) {
|
|
185
|
-
case coinlib_core_1.MainProtocolSymbols.BTC:
|
|
186
|
-
// try {
|
|
187
|
-
// await this.bitcoinTransactionValidator.validateSignedTransaction(transactionSignResponse as BitcoinTransactionSignResponse)
|
|
188
|
-
// return true
|
|
189
|
-
// } catch {
|
|
190
|
-
// return false
|
|
191
|
-
// }
|
|
192
|
-
return [2 /*return*/, true];
|
|
193
|
-
case coinlib_core_1.MainProtocolSymbols.BTC_SEGWIT:
|
|
194
|
-
return [2 /*return*/, true];
|
|
195
|
-
case coinlib_core_1.MainProtocolSymbols.BTC_TAPROOT:
|
|
196
|
-
return [2 /*return*/, true];
|
|
197
|
-
default:
|
|
198
|
-
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, "Protocol ".concat(identifier, " not supported"));
|
|
199
|
-
}
|
|
200
|
-
return [2 /*return*/];
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
};
|
|
204
|
-
return BitcoinV3SerializerCompanion;
|
|
205
|
-
}());
|
|
54
|
+
async toTransactionSignRequest(identifier, unsignedTransaction, publicKey, callbackUrl) {
|
|
55
|
+
switch (identifier) {
|
|
56
|
+
case coinlib_core_1.MainProtocolSymbols.BTC:
|
|
57
|
+
return (0, transaction_converter_1.bitcoinLegacyUnsignedTransactionToRequest)(unsignedTransaction, publicKey, callbackUrl);
|
|
58
|
+
case coinlib_core_1.MainProtocolSymbols.BTC_SEGWIT:
|
|
59
|
+
return (0, transaction_converter_1.bitcoinSegwitUnsignedTransactionToRequest)(unsignedTransaction, publicKey, callbackUrl);
|
|
60
|
+
case coinlib_core_1.MainProtocolSymbols.BTC_TAPROOT:
|
|
61
|
+
return (0, transaction_converter_1.bitcoinTaprootUnsignedTransactionToRequest)(unsignedTransaction, publicKey, callbackUrl);
|
|
62
|
+
default:
|
|
63
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, `Protocol ${identifier} not supported`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async fromTransactionSignRequest(identifier, transactionSignRequest) {
|
|
67
|
+
switch (identifier) {
|
|
68
|
+
case coinlib_core_1.MainProtocolSymbols.BTC:
|
|
69
|
+
return (0, transaction_converter_1.bitcoinLegacyTransactionSignRequestToUnsigned)(transactionSignRequest);
|
|
70
|
+
case coinlib_core_1.MainProtocolSymbols.BTC_SEGWIT:
|
|
71
|
+
return (0, transaction_converter_1.bitcoinSegwitTransactionSignRequestToUnsigned)(transactionSignRequest);
|
|
72
|
+
case coinlib_core_1.MainProtocolSymbols.BTC_TAPROOT:
|
|
73
|
+
return (0, transaction_converter_1.bitcoinTaprootTransactionSignRequestToUnsigned)(transactionSignRequest);
|
|
74
|
+
default:
|
|
75
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, `Protocol ${identifier} not supported`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async validateTransactionSignRequest(identifier, transactionSignRequest) {
|
|
79
|
+
switch (identifier) {
|
|
80
|
+
case coinlib_core_1.MainProtocolSymbols.BTC:
|
|
81
|
+
// try {
|
|
82
|
+
// await this.bitcoinTransactionValidator.validateUnsignedTransaction(transactionSignRequest)
|
|
83
|
+
// return true
|
|
84
|
+
// } catch {
|
|
85
|
+
// return false
|
|
86
|
+
// }
|
|
87
|
+
return true;
|
|
88
|
+
case coinlib_core_1.MainProtocolSymbols.BTC_SEGWIT:
|
|
89
|
+
return true;
|
|
90
|
+
case coinlib_core_1.MainProtocolSymbols.BTC_TAPROOT:
|
|
91
|
+
return true;
|
|
92
|
+
default:
|
|
93
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, `Protocol ${identifier} not supported`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async toTransactionSignResponse(identifier, signedTransaction, accountIdentifier) {
|
|
97
|
+
switch (identifier) {
|
|
98
|
+
case coinlib_core_1.MainProtocolSymbols.BTC:
|
|
99
|
+
return (0, transaction_converter_1.bitcoinLegacySignedTransactionToResponse)(signedTransaction, accountIdentifier);
|
|
100
|
+
case coinlib_core_1.MainProtocolSymbols.BTC_SEGWIT:
|
|
101
|
+
return (0, transaction_converter_1.bitcoinSegwitSignedTransactionToResponse)(signedTransaction, accountIdentifier);
|
|
102
|
+
case coinlib_core_1.MainProtocolSymbols.BTC_TAPROOT:
|
|
103
|
+
return (0, transaction_converter_1.bitcoinTaprootSignedTransactionToResponse)(signedTransaction, accountIdentifier);
|
|
104
|
+
default:
|
|
105
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, `Protocol ${identifier} not supported`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async fromTransactionSignResponse(identifier, transactionSignResponse) {
|
|
109
|
+
switch (identifier) {
|
|
110
|
+
case coinlib_core_1.MainProtocolSymbols.BTC:
|
|
111
|
+
return (0, transaction_converter_1.bitcoinLegacyTransactionSignResponseToSigned)(transactionSignResponse);
|
|
112
|
+
case coinlib_core_1.MainProtocolSymbols.BTC_SEGWIT:
|
|
113
|
+
return (0, transaction_converter_1.bitcoinSegwitTransactionSignResponseToSigned)(transactionSignResponse);
|
|
114
|
+
case coinlib_core_1.MainProtocolSymbols.BTC_TAPROOT:
|
|
115
|
+
return (0, transaction_converter_1.bitcoinTaprootTransactionSignResponseToSigned)(transactionSignResponse);
|
|
116
|
+
default:
|
|
117
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, `Protocol ${identifier} not supported`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async validateTransactionSignResponse(identifier, transactionSignResponse) {
|
|
121
|
+
switch (identifier) {
|
|
122
|
+
case coinlib_core_1.MainProtocolSymbols.BTC:
|
|
123
|
+
// try {
|
|
124
|
+
// await this.bitcoinTransactionValidator.validateSignedTransaction(transactionSignResponse as BitcoinTransactionSignResponse)
|
|
125
|
+
// return true
|
|
126
|
+
// } catch {
|
|
127
|
+
// return false
|
|
128
|
+
// }
|
|
129
|
+
return true;
|
|
130
|
+
case coinlib_core_1.MainProtocolSymbols.BTC_SEGWIT:
|
|
131
|
+
return true;
|
|
132
|
+
case coinlib_core_1.MainProtocolSymbols.BTC_TAPROOT:
|
|
133
|
+
return true;
|
|
134
|
+
default:
|
|
135
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, `Protocol ${identifier} not supported`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
206
139
|
exports.BitcoinV3SerializerCompanion = BitcoinV3SerializerCompanion;
|
|
207
140
|
//# sourceMappingURL=serializer-companion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer-companion.js","sourceRoot":"","sources":["../../../../src/v1/serializer/v3/serializer-companion.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serializer-companion.js","sourceRoot":"","sources":["../../../../src/v1/serializer/v3/serializer-companion.ts"],"names":[],"mappings":";;;AAAA,uDAAkE;AAClE,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UAAU;gBACjC,OAAO,IAAA,oEAA4C,EAAC,uBAAyD,CAAC,CAAA;YAChH,KAAK,kCAAmB,CAAC,WAAW;gBAClC,OAAO,IAAA,qEAA6C,EAAC,uBAAgE,CAAC,CAAA;YAExH;gBACE,MAAM,IAAI,yBAAgB,CAAC,qBAAM,CAAC,OAAO,EAAE,YAAY,UAAU,gBAAgB,CAAC,CAAA;QACtF,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,+BAA+B,CAAC,UAAkB,EAAE,uBAAgD;QAC/G,QAAQ,UAAU,EAAE,CAAC;YACnB,KAAK,kCAAmB,CAAC,GAAG;gBAC1B,QAAQ;gBACR,gIAAgI;gBAEhI,gBAAgB;gBAChB,YAAY;gBACZ,iBAAiB;gBACjB,IAAI;gBAEJ,OAAO,IAAI,CAAA;YACb,KAAK,kCAAmB,CAAC,UAAU;gBACjC,OAAO,IAAI,CAAA;YACb,KAAK,kCAAmB,CAAC,WAAW;gBAClC,OAAO,IAAI,CAAA;YACb;gBACE,MAAM,IAAI,yBAAgB,CAAC,qBAAM,CAAC,OAAO,EAAE,YAAY,UAAU,gBAAgB,CAAC,CAAA;QACtF,CAAC;IACH,CAAC;CACF;AAtJD,oEAsJC"}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BitcoinTransactionValidator = void 0;
|
|
4
4
|
// tslint:disable: max-classes-per-file
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const validate_1 = require("@airgap/coinlib-core/dependencies/src/validate.js-0.13.1/validate");
|
|
6
|
+
const serializer_1 = require("@airgap/serializer");
|
|
7
|
+
const unsignedTransactionConstraints = {
|
|
8
8
|
ins: {
|
|
9
9
|
presence: { allowEmpty: false },
|
|
10
10
|
isValidBitcoinInput: true
|
|
@@ -14,7 +14,7 @@ var unsignedTransactionConstraints = {
|
|
|
14
14
|
isValidBitcoinOutput: true
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
const signedTransactionConstraints = {
|
|
18
18
|
from: {
|
|
19
19
|
presence: { allowEmpty: false },
|
|
20
20
|
isValidBitcoinFromArray: true
|
|
@@ -37,20 +37,17 @@ var signedTransactionConstraints = {
|
|
|
37
37
|
presence: { allowEmpty: false }
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
BitcoinTransactionValidator.prototype.validateUnsignedTransaction = function (request) {
|
|
46
|
-
var transaction = request.transaction;
|
|
40
|
+
const success = () => undefined;
|
|
41
|
+
const error = (errors) => errors;
|
|
42
|
+
class BitcoinTransactionValidator {
|
|
43
|
+
validateUnsignedTransaction(request) {
|
|
44
|
+
const transaction = request.transaction;
|
|
47
45
|
(0, serializer_1.validateSyncScheme)({});
|
|
48
46
|
return (0, validate_1.async)(transaction, unsignedTransactionConstraints).then(success, error);
|
|
49
|
-
}
|
|
50
|
-
|
|
47
|
+
}
|
|
48
|
+
validateSignedTransaction(response) {
|
|
51
49
|
return (0, validate_1.async)(response, signedTransactionConstraints).then(success, error);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
}());
|
|
50
|
+
}
|
|
51
|
+
}
|
|
55
52
|
exports.BitcoinTransactionValidator = BitcoinTransactionValidator;
|
|
56
53
|
//# sourceMappingURL=transaction-validator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-validator.js","sourceRoot":"","sources":["../../../../../src/v1/serializer/v3/validators/transaction-validator.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AACvC,
|
|
1
|
+
{"version":3,"file":"transaction-validator.js","sourceRoot":"","sources":["../../../../../src/v1/serializer/v3/validators/transaction-validator.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AACvC,gGAAyF;AACzF,mDAA6E;AAK7E,MAAM,8BAA8B,GAAG;IACrC,GAAG,EAAE;QACH,QAAQ,EAAE,EA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