@airgap/bitcoin 0.13.8-beta.0 → 0.13.8-beta.4
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 +2 -2
- package/v1/data/BitcoinAddress.js +0 -1
- package/v1/data/BitcoinAddress.js.map +1 -1
- package/v1/data/BitcoinSegwitAddress.js +0 -1
- package/v1/data/BitcoinSegwitAddress.js.map +1 -1
- package/v1/index.d.ts +1 -2
- package/v1/index.js +1 -3
- package/v1/index.js.map +1 -1
- package/v1/module/BitcoinModule.d.ts +14 -7
- package/v1/module/BitcoinModule.js +28 -10
- package/v1/module/BitcoinModule.js.map +1 -1
- package/v1/module/BitcoinSegwitModule.d.ts +0 -8
- package/v1/module/BitcoinSegwitModule.js +0 -87
- package/v1/module/BitcoinSegwitModule.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@airgap/bitcoin",
|
|
3
|
-
"version": "0.13.8-beta.
|
|
3
|
+
"version": "0.13.8-beta.4",
|
|
4
4
|
"description": "The @airgap/bitcoin is a Bitcoin implementation of the ICoinProtocol interface from @airgap/coinlib-core.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"airgap",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"lint:prettier": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
25
25
|
"lint-ci": "tslint -t json -o ../../lint-reports/bitcoin.json --project . || true",
|
|
26
26
|
"lint-ci:prettier": "prettier \"src/**/*.ts\" \"test/**/*.ts\" --list-different",
|
|
27
|
-
"test": "nyc mocha --bail --require ts-node/register --require source-map-support/register --full-trace --delay --timeout 40000 ./test/**/**.spec.ts",
|
|
27
|
+
"test": "TS_NODE_PROJECT='./test/tsconfig.json' nyc mocha --bail --require ts-node/register --require source-map-support/register --full-trace --delay --timeout 40000 ./test/**/**.spec.ts",
|
|
28
28
|
"test-ci": "nyc --reporter=lcov npm test",
|
|
29
29
|
"test-legacy": "npm run build && mocha --full-trace --timeout 40000 ./test/**/**.spec.js",
|
|
30
30
|
"browserify": "browserify ./dist/index.js -p realpathify -s airgapCoinLibBitcoin > ./dist/airgap-coinlib-bitcoin.min.js"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitcoinAddress.js","sourceRoot":"","sources":["../../../src/v1/data/BitcoinAddress.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"BitcoinAddress.js","sourceRoot":"","sources":["../../../src/v1/data/BitcoinAddress.ts"],"names":[],"mappings":";;;AAAA;IACE,wBAAuC,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;IAAG,CAAC;IAE1C,yBAAU,GAAxB,UAAyB,IAAS;QAChC,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAA;IAC9C,CAAC;IAEa,yBAAU,GAAxB,UAAyB,OAAY;QACnC,OAAO,IAAI,cAAc,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAA;IACjD,CAAC;IAEM,iCAAQ,GAAf;QACE,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IACH,qBAAC;AAAD,CAAC,AAdD,IAcC;AAdY,wCAAc"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BitcoinSegwitAddress = void 0;
|
|
4
|
-
// tslint:disable: max-classes-per-file
|
|
5
4
|
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
6
5
|
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
7
6
|
var BitcoinSegwitAddress = /** @class */ (function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitcoinSegwitAddress.js","sourceRoot":"","sources":["../../../src/v1/data/BitcoinSegwitAddress.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"BitcoinSegwitAddress.js","sourceRoot":"","sources":["../../../src/v1/data/BitcoinSegwitAddress.ts"],"names":[],"mappings":";;;AAAA,qDAA6C;AAC7C,sDAA8D;AAG9D;IACE,8BAAuC,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;IAAG,CAAC;IAE1C,8BAAS,GAAvB,UAAwB,KAA6B;QACnD,OAAO,IAAI,oBAAoB,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;IACnD,CAAC;IAEa,gCAAW,GAAzB,UAA0B,OAAwB;QAChD,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE;YACjC,MAAM,IAAI,yBAAgB,CAAC,qBAAM,CAAC,OAAO,EAAE,6BAA6B,CAAC,CAAA;SAC1E;QAED,OAAO,IAAI,oBAAoB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAClD,CAAC;IAEM,uCAAQ,GAAf;QACE,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IACH,2BAAC;AAAD,CAAC,AAlBD,IAkBC;AAlBY,oDAAoB"}
|
package/v1/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BlockCypherBlockExplorer } from './block-explorer/BlockCypherBlockExplorer';
|
|
2
2
|
import { BitcoinModule } from './module/BitcoinModule';
|
|
3
|
-
import { BitcoinSegwitModule } from './module/BitcoinSegwitModule';
|
|
4
3
|
import { BitcoinProtocol, createBitcoinProtocol, createBitcoinProtocolOptions } from './protocol/BitcoinProtocol';
|
|
5
4
|
import { BitcoinSegwitProtocol, createBitcoinSegwitProtocol } from './protocol/BitcoinSegwitProtocol';
|
|
6
5
|
import { BitcoinTestnetProtocol, createBitcoinTestnetProtocol } from './protocol/BitcoinTestnetProtocol';
|
|
@@ -13,7 +12,7 @@ import { BitcoinTransactionValidator } from './serializer/v3/validators/transact
|
|
|
13
12
|
import { bitcoinValidators } from './serializer/v3/validators/validators';
|
|
14
13
|
import { BitcoinProtocolNetwork, BitcoinProtocolOptions, BitcoinUnits } from './types/protocol';
|
|
15
14
|
import { BitcoinInTransaction, BitcoinOutTransaction, BitcoinSegwitSignedTransaction, BitcoinSegwitUnsignedTransaction, BitcoinSignedTransaction, BitcoinTransactionCursor, BitcoinUnsignedTransaction } from './types/transaction';
|
|
16
|
-
export { BitcoinModule
|
|
15
|
+
export { BitcoinModule };
|
|
17
16
|
export { BitcoinProtocol, BitcoinTestnetProtocol, BitcoinSegwitProtocol, createBitcoinProtocol, createBitcoinTestnetProtocol, createBitcoinSegwitProtocol, createBitcoinProtocolOptions };
|
|
18
17
|
export { BlockCypherBlockExplorer };
|
|
19
18
|
export { BitcoinUnits, BitcoinProtocolNetwork, BitcoinProtocolOptions, BitcoinUnsignedTransaction, BitcoinSignedTransaction, BitcoinSegwitUnsignedTransaction, BitcoinSegwitSignedTransaction, BitcoinInTransaction, BitcoinOutTransaction, BitcoinTransactionCursor };
|
package/v1/index.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.bitcoinTransactionSignResponseToSigned = exports.bitcoinTransactionSignRequestToUnsigned = exports.bitcoinSignedTransactionToResponse = exports.bitcoinUnsignedTransactionToRequest = exports.bitcoinValidators = exports.BitcoinTransactionValidator = exports.BlockCypherBlockExplorer = exports.createBitcoinProtocolOptions = exports.createBitcoinSegwitProtocol = exports.createBitcoinTestnetProtocol = exports.createBitcoinProtocol = exports.
|
|
3
|
+
exports.bitcoinTransactionSignResponseToSigned = exports.bitcoinTransactionSignRequestToUnsigned = exports.bitcoinSignedTransactionToResponse = exports.bitcoinUnsignedTransactionToRequest = exports.bitcoinValidators = exports.BitcoinTransactionValidator = exports.BlockCypherBlockExplorer = exports.createBitcoinProtocolOptions = exports.createBitcoinSegwitProtocol = exports.createBitcoinTestnetProtocol = exports.createBitcoinProtocol = exports.BitcoinModule = void 0;
|
|
4
4
|
var BlockCypherBlockExplorer_1 = require("./block-explorer/BlockCypherBlockExplorer");
|
|
5
5
|
Object.defineProperty(exports, "BlockCypherBlockExplorer", { enumerable: true, get: function () { return BlockCypherBlockExplorer_1.BlockCypherBlockExplorer; } });
|
|
6
6
|
var BitcoinModule_1 = require("./module/BitcoinModule");
|
|
7
7
|
Object.defineProperty(exports, "BitcoinModule", { enumerable: true, get: function () { return BitcoinModule_1.BitcoinModule; } });
|
|
8
|
-
var BitcoinSegwitModule_1 = require("./module/BitcoinSegwitModule");
|
|
9
|
-
Object.defineProperty(exports, "BitcoinSegwitModule", { enumerable: true, get: function () { return BitcoinSegwitModule_1.BitcoinSegwitModule; } });
|
|
10
8
|
var BitcoinProtocol_1 = require("./protocol/BitcoinProtocol");
|
|
11
9
|
Object.defineProperty(exports, "createBitcoinProtocol", { enumerable: true, get: function () { return BitcoinProtocol_1.createBitcoinProtocol; } });
|
|
12
10
|
Object.defineProperty(exports, "createBitcoinProtocolOptions", { enumerable: true, get: function () { return BitcoinProtocol_1.createBitcoinProtocolOptions; } });
|
package/v1/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v1/index.ts"],"names":[],"mappings":";;;AAAA,sFAAoF;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v1/index.ts"],"names":[],"mappings":";;;AAAA,sFAAoF;AA8C3E,yGA9CA,mDAAwB,OA8CA;AA7CjC,wDAAsD;AA6B7C,8FA7BA,6BAAa,OA6BA;AA5BtB,8DAAiH;AAoC/G,sGApCwB,uCAAqB,OAoCxB;AAGrB,6GAvC+C,8CAA4B,OAuC/C;AAtC9B,0EAAqG;AAqCnG,4GArC8B,mDAA2B,OAqC9B;AApC7B,4EAAwG;AAmCtG,6GAnC+B,qDAA4B,OAmC/B;AAlC9B,iGAKgE;AA+D9D,mHAnEA,0DAAkC,OAmEA;AAClC,wHAnEA,+DAAuC,OAmEA;AACvC,uHAnEA,8DAAsC,OAmEA;AAHtC,oHA/DA,2DAAmC,OA+DA;AAzDrC,4FAA+F;AAuD7F,4GAvDO,oDAA2B,OAuDP;AAtD7B,oEAAyE;AAuDvE,kGAvDO,8BAAiB,OAuDP"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { MainProtocolSymbols } from '@airgap/coinlib-core';
|
|
2
|
+
import { AirGapBlockExplorer, AirGapModule, AirGapOfflineProtocol, AirGapOnlineProtocol, ProtocolConfiguration } from '@airgap/module-kit';
|
|
3
|
+
declare type SupportedProtocols = MainProtocolSymbols.BTC | MainProtocolSymbols.BTC_SEGWIT;
|
|
4
|
+
export declare class BitcoinModule implements AirGapModule<{
|
|
5
|
+
Protocols: SupportedProtocols;
|
|
6
|
+
}> {
|
|
7
|
+
private readonly networkRegistries;
|
|
8
|
+
readonly supportedProtocols: Record<SupportedProtocols, ProtocolConfiguration>;
|
|
9
|
+
constructor();
|
|
10
|
+
createOfflineProtocol(identifier: SupportedProtocols): Promise<AirGapOfflineProtocol | undefined>;
|
|
11
|
+
createOnlineProtocol(identifier: SupportedProtocols, networkId?: string): Promise<AirGapOnlineProtocol | undefined>;
|
|
12
|
+
createBlockExplorer(identifier: SupportedProtocols, networkId?: string): Promise<AirGapBlockExplorer | undefined>;
|
|
13
|
+
private createProtocol;
|
|
8
14
|
}
|
|
15
|
+
export {};
|
|
@@ -42,25 +42,32 @@ var errors_1 = require("@airgap/coinlib-core/errors");
|
|
|
42
42
|
var module_kit_1 = require("@airgap/module-kit");
|
|
43
43
|
var BlockCypherBlockExplorer_1 = require("../block-explorer/BlockCypherBlockExplorer");
|
|
44
44
|
var BitcoinProtocol_1 = require("../protocol/BitcoinProtocol");
|
|
45
|
+
var BitcoinSegwitProtocol_1 = require("../protocol/BitcoinSegwitProtocol");
|
|
45
46
|
var BitcoinModule = /** @class */ (function () {
|
|
46
47
|
function BitcoinModule() {
|
|
47
|
-
|
|
48
|
+
var _a;
|
|
49
|
+
var networkRegistry = new module_kit_1.ModuleNetworkRegistry({
|
|
48
50
|
supportedNetworks: [BitcoinProtocol_1.BITCOIN_MAINNET_PROTOCOL_NETWORK]
|
|
49
51
|
});
|
|
50
|
-
this.
|
|
52
|
+
this.networkRegistries = (_a = {},
|
|
53
|
+
_a[coinlib_core_1.MainProtocolSymbols.BTC] = networkRegistry,
|
|
54
|
+
_a[coinlib_core_1.MainProtocolSymbols.BTC_SEGWIT] = networkRegistry,
|
|
55
|
+
_a);
|
|
56
|
+
this.supportedProtocols = (0, module_kit_1.createSupportedProtocols)(this.networkRegistries);
|
|
51
57
|
}
|
|
52
|
-
BitcoinModule.prototype.createOfflineProtocol = function () {
|
|
58
|
+
BitcoinModule.prototype.createOfflineProtocol = function (identifier) {
|
|
53
59
|
return __awaiter(this, void 0, void 0, function () {
|
|
54
60
|
return __generator(this, function (_a) {
|
|
55
|
-
return [2 /*return*/,
|
|
61
|
+
return [2 /*return*/, this.createProtocol(identifier)];
|
|
56
62
|
});
|
|
57
63
|
});
|
|
58
64
|
};
|
|
59
|
-
BitcoinModule.prototype.createOnlineProtocol = function (networkId) {
|
|
65
|
+
BitcoinModule.prototype.createOnlineProtocol = function (identifier, networkId) {
|
|
66
|
+
var _a;
|
|
60
67
|
return __awaiter(this, void 0, void 0, function () {
|
|
61
68
|
var network;
|
|
62
|
-
return __generator(this, function (
|
|
63
|
-
network = this.
|
|
69
|
+
return __generator(this, function (_b) {
|
|
70
|
+
network = (_a = this.networkRegistries[identifier]) === null || _a === void 0 ? void 0 : _a.findNetwork(networkId);
|
|
64
71
|
if (network === undefined) {
|
|
65
72
|
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.BITCOIN, 'Protocol network not supported.');
|
|
66
73
|
}
|
|
@@ -68,11 +75,12 @@ var BitcoinModule = /** @class */ (function () {
|
|
|
68
75
|
});
|
|
69
76
|
});
|
|
70
77
|
};
|
|
71
|
-
BitcoinModule.prototype.createBlockExplorer = function (networkId) {
|
|
78
|
+
BitcoinModule.prototype.createBlockExplorer = function (identifier, networkId) {
|
|
79
|
+
var _a;
|
|
72
80
|
return __awaiter(this, void 0, void 0, function () {
|
|
73
81
|
var network;
|
|
74
|
-
return __generator(this, function (
|
|
75
|
-
network = this.
|
|
82
|
+
return __generator(this, function (_b) {
|
|
83
|
+
network = (_a = this.networkRegistries[identifier]) === null || _a === void 0 ? void 0 : _a.findNetwork(networkId);
|
|
76
84
|
if ((network === null || network === void 0 ? void 0 : network.type) !== 'mainnet') {
|
|
77
85
|
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.BITCOIN, 'Block Explorer network not supported.');
|
|
78
86
|
}
|
|
@@ -80,6 +88,16 @@ var BitcoinModule = /** @class */ (function () {
|
|
|
80
88
|
});
|
|
81
89
|
});
|
|
82
90
|
};
|
|
91
|
+
BitcoinModule.prototype.createProtocol = function (identifier, network) {
|
|
92
|
+
switch (identifier) {
|
|
93
|
+
case coinlib_core_1.MainProtocolSymbols.BTC:
|
|
94
|
+
return (0, BitcoinProtocol_1.createBitcoinProtocol)();
|
|
95
|
+
case coinlib_core_1.MainProtocolSymbols.BTC_SEGWIT:
|
|
96
|
+
return (0, BitcoinSegwitProtocol_1.createBitcoinSegwitProtocol)();
|
|
97
|
+
default:
|
|
98
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.BITCOIN, "Protocol ".concat(identifier, " not supported."));
|
|
99
|
+
}
|
|
100
|
+
};
|
|
83
101
|
return BitcoinModule;
|
|
84
102
|
}());
|
|
85
103
|
exports.BitcoinModule = BitcoinModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitcoinModule.js","sourceRoot":"","sources":["../../../src/v1/module/BitcoinModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"BitcoinModule.js","sourceRoot":"","s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MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,OAAO,EAAE,uCAAuC,CAAC,CAAA;iBAC3F;gBAED,sBAAO,IAAI,mDAAwB,EAAE,EAAA;;;KACtC;IAEO,sCAAc,GAAtB,UAAuB,UAA8B,EAAE,OAAyB;QAC9E,QAAQ,UAAU,EAAE;YAClB,KAAK,kCAAmB,CAAC,GAAG;gBAC1B,OAAO,IAAA,uCAAqB,GAAE,CAAA;YAChC,KAAK,kCAAmB,CAAC,UAAU;gBACjC,OAAO,IAAA,mDAA2B,GAAE,CAAA;YACtC;gBACE,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,OAAO,EAAE,mBAAY,UAAU,oBAAiB,CAAC,CAAA;SAC7F;IACH,CAAC;IACH,oBAAC;AAAD,CAAC,AA/CD,IA+CC;AA/CY,sCAAa"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { AirGapBlockExplorer, AirGapModule, AirGapOfflineProtocol, AirGapOnlineProtocol, ProtocolNetwork } from '@airgap/module-kit';
|
|
2
|
-
export declare class BitcoinSegwitModule implements AirGapModule {
|
|
3
|
-
private readonly networkRegistry;
|
|
4
|
-
supportedNetworks: Record<string, ProtocolNetwork>;
|
|
5
|
-
createOfflineProtocol(): Promise<AirGapOfflineProtocol | undefined>;
|
|
6
|
-
createOnlineProtocol(networkId?: string): Promise<AirGapOnlineProtocol | undefined>;
|
|
7
|
-
createBlockExplorer(networkId?: string): Promise<AirGapBlockExplorer | undefined>;
|
|
8
|
-
}
|
|
@@ -1,87 +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.BitcoinSegwitModule = void 0;
|
|
40
|
-
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
41
|
-
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
42
|
-
var module_kit_1 = require("@airgap/module-kit");
|
|
43
|
-
var BlockCypherBlockExplorer_1 = require("../block-explorer/BlockCypherBlockExplorer");
|
|
44
|
-
var BitcoinProtocol_1 = require("../protocol/BitcoinProtocol");
|
|
45
|
-
var BitcoinSegwitProtocol_1 = require("../protocol/BitcoinSegwitProtocol");
|
|
46
|
-
var BitcoinSegwitModule = /** @class */ (function () {
|
|
47
|
-
function BitcoinSegwitModule() {
|
|
48
|
-
this.networkRegistry = new module_kit_1.ModuleNetworkRegistry({
|
|
49
|
-
supportedNetworks: [BitcoinProtocol_1.BITCOIN_MAINNET_PROTOCOL_NETWORK]
|
|
50
|
-
});
|
|
51
|
-
this.supportedNetworks = this.networkRegistry.supportedNetworks;
|
|
52
|
-
}
|
|
53
|
-
BitcoinSegwitModule.prototype.createOfflineProtocol = function () {
|
|
54
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
55
|
-
return __generator(this, function (_a) {
|
|
56
|
-
return [2 /*return*/, (0, BitcoinSegwitProtocol_1.createBitcoinSegwitProtocol)()];
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
BitcoinSegwitModule.prototype.createOnlineProtocol = function (networkId) {
|
|
61
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
62
|
-
var network;
|
|
63
|
-
return __generator(this, function (_a) {
|
|
64
|
-
network = this.networkRegistry.findNetwork(networkId);
|
|
65
|
-
if (network === undefined) {
|
|
66
|
-
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.BITCOIN, 'Protocol network not supported.');
|
|
67
|
-
}
|
|
68
|
-
return [2 /*return*/, (0, BitcoinSegwitProtocol_1.createBitcoinSegwitProtocol)({ network: network })];
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
BitcoinSegwitModule.prototype.createBlockExplorer = function (networkId) {
|
|
73
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
74
|
-
var network;
|
|
75
|
-
return __generator(this, function (_a) {
|
|
76
|
-
network = this.networkRegistry.findNetwork(networkId);
|
|
77
|
-
if ((network === null || network === void 0 ? void 0 : network.type) !== 'mainnet') {
|
|
78
|
-
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.BITCOIN, 'Block Explorer network not supported.');
|
|
79
|
-
}
|
|
80
|
-
return [2 /*return*/, new BlockCypherBlockExplorer_1.BlockCypherBlockExplorer()];
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
return BitcoinSegwitModule;
|
|
85
|
-
}());
|
|
86
|
-
exports.BitcoinSegwitModule = BitcoinSegwitModule;
|
|
87
|
-
//# sourceMappingURL=BitcoinSegwitModule.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BitcoinSegwitModule.js","sourceRoot":"","sources":["../../../src/v1/module/BitcoinSegwitModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA6C;AAC7C,sDAAqE;AACrE,iDAO2B;AAE3B,uFAAqF;AACrF,+DAA8E;AAC9E,2EAA+E;AAE/E;IAAA;QACmB,oBAAe,GAA0B,IAAI,kCAAqB,CAAC;YAClF,iBAAiB,EAAE,CAAC,kDAAgC,CAAC;SACtD,CAAC,CAAA;QAEK,sBAAiB,GAAoC,IAAI,CAAC,eAAe,CAAC,iBAAiB,CAAA;IAuBpG,CAAC;IArBc,mDAAqB,GAAlC;;;gBACE,sBAAO,IAAA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