@airgap/bitcoin 0.13.10 → 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.
Files changed (143) hide show
  1. package/package.json +11 -9
  2. package/airgap-coinlib-bitcoin.min.js +0 -99733
  3. package/index.d.ts +0 -1
  4. package/index.js +0 -18
  5. package/index.js.map +0 -1
  6. package/v0/index.d.ts +0 -14
  7. package/v0/index.js +0 -34
  8. package/v0/index.js.map +0 -1
  9. package/v0/protocol/BitcoinAddress.d.ts +0 -9
  10. package/v0/protocol/BitcoinAddress.js +0 -23
  11. package/v0/protocol/BitcoinAddress.js.map +0 -1
  12. package/v0/protocol/BitcoinCryptoClient.d.ts +0 -11
  13. package/v0/protocol/BitcoinCryptoClient.js +0 -91
  14. package/v0/protocol/BitcoinCryptoClient.js.map +0 -1
  15. package/v0/protocol/BitcoinProtocol.d.ts +0 -167
  16. package/v0/protocol/BitcoinProtocol.js +0 -1063
  17. package/v0/protocol/BitcoinProtocol.js.map +0 -1
  18. package/v0/protocol/BitcoinProtocolOptions.d.ts +0 -26
  19. package/v0/protocol/BitcoinProtocolOptions.js +0 -148
  20. package/v0/protocol/BitcoinProtocolOptions.js.map +0 -1
  21. package/v0/protocol/BitcoinSegwitAddress.d.ts +0 -7
  22. package/v0/protocol/BitcoinSegwitAddress.js +0 -41
  23. package/v0/protocol/BitcoinSegwitAddress.js.map +0 -1
  24. package/v0/protocol/BitcoinSegwitProtocol.d.ts +0 -28
  25. package/v0/protocol/BitcoinSegwitProtocol.js +0 -541
  26. package/v0/protocol/BitcoinSegwitProtocol.js.map +0 -1
  27. package/v0/protocol/BitcoinTestnetProtocol.d.ts +0 -7
  28. package/v0/protocol/BitcoinTestnetProtocol.js +0 -58
  29. package/v0/protocol/BitcoinTestnetProtocol.js.map +0 -1
  30. package/v0/protocol/BitcoinTypes.d.ts +0 -21
  31. package/v0/protocol/BitcoinTypes.js +0 -3
  32. package/v0/protocol/BitcoinTypes.js.map +0 -1
  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 +0 -73
  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 +0 -37
  37. package/v0/serializer/schemas/v3/transaction-sign-request-bitcoin-segwit.json +0 -29
  38. package/v0/serializer/schemas/v3/transaction-sign-request-bitcoin.json +0 -73
  39. package/v0/serializer/schemas/v3/transaction-sign-response-bitcoin-segwit.json +0 -19
  40. package/v0/serializer/schemas/v3/transaction-sign-response-bitcoin.json +0 -37
  41. package/v0/serializer/validators/transaction-validator.d.ts +0 -15
  42. package/v0/serializer/validators/transaction-validator.js +0 -81
  43. package/v0/serializer/validators/transaction-validator.js.map +0 -1
  44. package/v0/serializer/validators/validators.d.ts +0 -1
  45. package/v0/serializer/validators/validators.js +0 -151
  46. package/v0/serializer/validators/validators.js.map +0 -1
  47. package/v0/types/signed-transaction-bitcoin-segwit.d.ts +0 -5
  48. package/v0/types/signed-transaction-bitcoin-segwit.js +0 -3
  49. package/v0/types/signed-transaction-bitcoin-segwit.js.map +0 -1
  50. package/v0/types/signed-transaction-bitcoin.d.ts +0 -9
  51. package/v0/types/signed-transaction-bitcoin.js +0 -3
  52. package/v0/types/signed-transaction-bitcoin.js.map +0 -1
  53. package/v0/types/transaction-bitcoin.d.ts +0 -20
  54. package/v0/types/transaction-bitcoin.js +0 -3
  55. package/v0/types/transaction-bitcoin.js.map +0 -1
  56. package/v0/types/unsigned-transaction-bitcoin-segwit.d.ts +0 -7
  57. package/v0/types/unsigned-transaction-bitcoin-segwit.js +0 -3
  58. package/v0/types/unsigned-transaction-bitcoin-segwit.js.map +0 -1
  59. package/v0/types/unsigned-transaction-bitcoin.d.ts +0 -22
  60. package/v0/types/unsigned-transaction-bitcoin.js +0 -3
  61. package/v0/types/unsigned-transaction-bitcoin.js.map +0 -1
  62. package/v1/block-explorer/BlockCypherBlockExplorer.d.ts +0 -9
  63. package/v1/block-explorer/BlockCypherBlockExplorer.js +0 -74
  64. package/v1/block-explorer/BlockCypherBlockExplorer.js.map +0 -1
  65. package/v1/data/BitcoinAddress.d.ts +0 -7
  66. package/v1/data/BitcoinAddress.js +0 -20
  67. package/v1/data/BitcoinAddress.js.map +0 -1
  68. package/v1/data/BitcoinSegwitAddress.d.ts +0 -8
  69. package/v1/data/BitcoinSegwitAddress.js +0 -25
  70. package/v1/data/BitcoinSegwitAddress.js.map +0 -1
  71. package/v1/index.d.ts +0 -19
  72. package/v1/index.js +0 -24
  73. package/v1/index.js.map +0 -1
  74. package/v1/module/BitcoinModule.d.ts +0 -16
  75. package/v1/module/BitcoinModule.js +0 -112
  76. package/v1/module/BitcoinModule.js.map +0 -1
  77. package/v1/protocol/BitcoinCryptoClient.d.ts +0 -12
  78. package/v1/protocol/BitcoinCryptoClient.js +0 -96
  79. package/v1/protocol/BitcoinCryptoClient.js.map +0 -1
  80. package/v1/protocol/BitcoinProtocol.d.ts +0 -69
  81. package/v1/protocol/BitcoinProtocol.js +0 -1211
  82. package/v1/protocol/BitcoinProtocol.js.map +0 -1
  83. package/v1/protocol/BitcoinSegwitProtocol.d.ts +0 -52
  84. package/v1/protocol/BitcoinSegwitProtocol.js +0 -751
  85. package/v1/protocol/BitcoinSegwitProtocol.js.map +0 -1
  86. package/v1/protocol/BitcoinTestnetProtocol.d.ts +0 -11
  87. package/v1/protocol/BitcoinTestnetProtocol.js +0 -67
  88. package/v1/protocol/BitcoinTestnetProtocol.js.map +0 -1
  89. package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +0 -13
  90. package/v1/serializer/v3/schemas/converter/transaction-converter.js +0 -75
  91. package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +0 -1
  92. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin-segwit.d.ts +0 -4
  93. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin-segwit.js +0 -3
  94. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin-segwit.js.map +0 -1
  95. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin.d.ts +0 -4
  96. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin.js +0 -3
  97. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-bitcoin.js.map +0 -1
  98. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin-segwit.d.ts +0 -3
  99. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin-segwit.js +0 -3
  100. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin-segwit.js.map +0 -1
  101. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin.d.ts +0 -7
  102. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin.js +0 -3
  103. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-bitcoin.js.map +0 -1
  104. package/v1/serializer/v3/schemas/generated/transaction-sign-request-bitcoin-segwit.json +0 -29
  105. package/v1/serializer/v3/schemas/generated/transaction-sign-request-bitcoin.json +0 -79
  106. package/v1/serializer/v3/schemas/generated/transaction-sign-response-bitcoin-segwit.json +0 -19
  107. package/v1/serializer/v3/schemas/generated/transaction-sign-response-bitcoin.json +0 -37
  108. package/v1/serializer/v3/serializer-companion.d.ts +0 -14
  109. package/v1/serializer/v3/serializer-companion.js +0 -197
  110. package/v1/serializer/v3/serializer-companion.js.map +0 -1
  111. package/v1/serializer/v3/validators/transaction-validator.d.ts +0 -7
  112. package/v1/serializer/v3/validators/transaction-validator.js +0 -56
  113. package/v1/serializer/v3/validators/transaction-validator.js.map +0 -1
  114. package/v1/serializer/v3/validators/validators.d.ts +0 -7
  115. package/v1/serializer/v3/validators/validators.js +0 -254
  116. package/v1/serializer/v3/validators/validators.js.map +0 -1
  117. package/v1/types/bitcoinjs.d.ts +0 -14
  118. package/v1/types/bitcoinjs.js +0 -3
  119. package/v1/types/bitcoinjs.js.map +0 -1
  120. package/v1/types/indexer.d.ts +0 -81
  121. package/v1/types/indexer.js +0 -3
  122. package/v1/types/indexer.js.map +0 -1
  123. package/v1/types/key.d.ts +0 -6
  124. package/v1/types/key.js +0 -3
  125. package/v1/types/key.js.map +0 -1
  126. package/v1/types/protocol.d.ts +0 -17
  127. package/v1/types/protocol.js +0 -3
  128. package/v1/types/protocol.js.map +0 -1
  129. package/v1/types/transaction.d.ts +0 -39
  130. package/v1/types/transaction.js +0 -3
  131. package/v1/types/transaction.js.map +0 -1
  132. package/v1/utils/common.d.ts +0 -2
  133. package/v1/utils/common.js +0 -28
  134. package/v1/utils/common.js.map +0 -1
  135. package/v1/utils/key.d.ts +0 -12
  136. package/v1/utils/key.js +0 -158
  137. package/v1/utils/key.js.map +0 -1
  138. package/v1/utils/network.d.ts +0 -2
  139. package/v1/utils/network.js +0 -22
  140. package/v1/utils/network.js.map +0 -1
  141. package/v1/utils/signature.d.ts +0 -2
  142. package/v1/utils/signature.js +0 -34
  143. package/v1/utils/signature.js.map +0 -1
@@ -1,1211 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- var desc = Object.getOwnPropertyDescriptor(m, k);
16
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
- desc = { enumerable: true, get: function() { return m[k]; } };
18
- }
19
- Object.defineProperty(o, k2, desc);
20
- }) : (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- o[k2] = m[k];
23
- }));
24
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
- Object.defineProperty(o, "default", { enumerable: true, value: v });
26
- }) : function(o, v) {
27
- o["default"] = v;
28
- });
29
- var __importStar = (this && this.__importStar) || function (mod) {
30
- if (mod && mod.__esModule) return mod;
31
- var result = {};
32
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
- __setModuleDefault(result, mod);
34
- return result;
35
- };
36
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
- return new (P || (P = Promise))(function (resolve, reject) {
39
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
- step((generator = generator.apply(thisArg, _arguments || [])).next());
43
- });
44
- };
45
- var __generator = (this && this.__generator) || function (thisArg, body) {
46
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
47
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
48
- function verb(n) { return function (v) { return step([n, v]); }; }
49
- function step(op) {
50
- if (f) throw new TypeError("Generator is already executing.");
51
- while (_) try {
52
- 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;
53
- if (y = 0, t) op = [op[0] & 2, t.value];
54
- switch (op[0]) {
55
- case 0: case 1: t = op; break;
56
- case 4: _.label++; return { value: op[1], done: false };
57
- case 5: _.label++; y = op[1]; op = [0]; continue;
58
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
59
- default:
60
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
61
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
62
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
63
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
64
- if (t[2]) _.ops.pop();
65
- _.trys.pop(); continue;
66
- }
67
- op = body.call(thisArg, _);
68
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
69
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
70
- }
71
- };
72
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
73
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
74
- if (ar || !(i in from)) {
75
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
76
- ar[i] = from[i];
77
- }
78
- }
79
- return to.concat(ar || Array.prototype.slice.call(from));
80
- };
81
- var __importDefault = (this && this.__importDefault) || function (mod) {
82
- return (mod && mod.__esModule) ? mod : { "default": mod };
83
- };
84
- Object.defineProperty(exports, "__esModule", { value: true });
85
- exports.createBitcoinProtocolOptions = exports.BITCOIN_MAINNET_PROTOCOL_NETWORK = exports.createBitcoinProtocol = exports.BitcoinProtocolImpl = void 0;
86
- var coinlib_core_1 = require("@airgap/coinlib-core");
87
- var index_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/axios-0.19.0/index"));
88
- var BigInteger = __importStar(require("@airgap/coinlib-core/dependencies/src/bigi-1.4.2"));
89
- var bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
90
- var index_2 = require("@airgap/coinlib-core/dependencies/src/bip39-2.5.0/index");
91
- var bitcoinMessage = __importStar(require("@airgap/coinlib-core/dependencies/src/bitcoinjs-message-2.1.1/index"));
92
- var BitGo = __importStar(require("@airgap/coinlib-core/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src/index"));
93
- var errors_1 = require("@airgap/coinlib-core/errors");
94
- var module_kit_1 = require("@airgap/module-kit");
95
- var BitcoinAddress_1 = require("../data/BitcoinAddress");
96
- var common_1 = require("../utils/common");
97
- var key_1 = require("../utils/key");
98
- var network_1 = require("../utils/network");
99
- var signature_1 = require("../utils/signature");
100
- var BitcoinCryptoClient_1 = require("./BitcoinCryptoClient");
101
- // Implementation
102
- var DUST_AMOUNT = 50;
103
- var BitcoinProtocolImpl = /** @class */ (function () {
104
- function BitcoinProtocolImpl(options, bitcoinJS, bitcoinJSMessage) {
105
- if (options === void 0) { options = {}; }
106
- if (bitcoinJS === void 0) { bitcoinJS = BitGo; }
107
- if (bitcoinJSMessage === void 0) { bitcoinJSMessage = bitcoinMessage; }
108
- // Common
109
- this.units = {
110
- BTC: {
111
- symbol: { value: 'BTC', market: 'btc' },
112
- decimals: 8
113
- },
114
- mBTC: {
115
- symbol: { value: 'mBTC' },
116
- decimals: 4
117
- },
118
- Satoshi: {
119
- symbol: { value: 'Satoshi' },
120
- decimals: 0
121
- }
122
- };
123
- this.feeDefaults = {
124
- low: (0, module_kit_1.newAmount)(0.00002, 'BTC').blockchain(this.units),
125
- medium: (0, module_kit_1.newAmount)(0.00004, 'BTC').blockchain(this.units),
126
- high: (0, module_kit_1.newAmount)(0.00005, 'BTC').blockchain(this.units)
127
- };
128
- this.metadata = {
129
- identifier: coinlib_core_1.MainProtocolSymbols.BTC,
130
- name: 'Bitcoin (Legacy)',
131
- units: this.units,
132
- mainUnit: 'BTC',
133
- fee: {
134
- defaults: this.feeDefaults
135
- },
136
- account: {
137
- standardDerivationPath: "m/44'/0'/0'",
138
- address: {
139
- isCaseSensitive: true,
140
- placeholder: '1ABC...',
141
- regex: '^(?:[13]{1}[a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[a-z0-9]{39,59})$'
142
- }
143
- }
144
- };
145
- this.options = createBitcoinProtocolOptions(options.network);
146
- this.bitcoinJS = {
147
- lib: bitcoinJS,
148
- message: bitcoinJSMessage,
149
- config: {
150
- network: (0, network_1.getBitcoinJSNetwork)(this.options.network, bitcoinJS)
151
- }
152
- };
153
- this.cryptoClient = new BitcoinCryptoClient_1.BitcoinCryptoClient(this, this.bitcoinJS);
154
- }
155
- BitcoinProtocolImpl.prototype.getMetadata = function () {
156
- return __awaiter(this, void 0, void 0, function () {
157
- return __generator(this, function (_a) {
158
- return [2 /*return*/, this.metadata];
159
- });
160
- });
161
- };
162
- BitcoinProtocolImpl.prototype.getAddressFromPublicKey = function (publicKey) {
163
- return __awaiter(this, void 0, void 0, function () {
164
- return __generator(this, function (_a) {
165
- switch (publicKey.type) {
166
- case 'pub':
167
- return [2 /*return*/, this.getAddressFromNonExtendedPublicKey(publicKey)];
168
- case 'xpub':
169
- return [2 /*return*/, this.getAddressFromExtendedPublicKey(publicKey)];
170
- default:
171
- (0, coinlib_core_1.assertNever)(publicKey);
172
- throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Public key type is not supported.');
173
- }
174
- return [2 /*return*/];
175
- });
176
- });
177
- };
178
- BitcoinProtocolImpl.prototype.getAddressFromNonExtendedPublicKey = function (publicKey) {
179
- return __awaiter(this, void 0, void 0, function () {
180
- var hexPublicKey, keyPair;
181
- return __generator(this, function (_a) {
182
- hexPublicKey = (0, key_1.convertPublicKey)(publicKey, 'hex');
183
- keyPair = this.bitcoinJS.lib.ECPair.fromPublicKeyBuffer(Buffer.from(hexPublicKey.value, 'hex'), this.bitcoinJS.config.network);
184
- return [2 /*return*/, BitcoinAddress_1.BitcoinAddress.fromECPair(keyPair).asString()];
185
- });
186
- });
187
- };
188
- BitcoinProtocolImpl.prototype.getAddressFromExtendedPublicKey = function (extendedPublicKey) {
189
- return __awaiter(this, void 0, void 0, function () {
190
- var encodedExtendedPublicKey, node;
191
- return __generator(this, function (_a) {
192
- encodedExtendedPublicKey = this.convertExtendedPublicKey(extendedPublicKey, 'encoded');
193
- node = this.bitcoinJS.lib.HDNode.fromBase58(encodedExtendedPublicKey.value, this.bitcoinJS.config.network);
194
- return [2 /*return*/, BitcoinAddress_1.BitcoinAddress.fromHDNode(node).asString()];
195
- });
196
- });
197
- };
198
- BitcoinProtocolImpl.prototype.deriveFromExtendedPublicKey = function (extendedPublicKey, visibilityIndex, addressIndex) {
199
- return __awaiter(this, void 0, void 0, function () {
200
- var encodedExtendedPublicKey, childPublicKey;
201
- return __generator(this, function (_a) {
202
- encodedExtendedPublicKey = this.convertExtendedPublicKey(extendedPublicKey, 'encoded');
203
- childPublicKey = this.bitcoinJS.lib.HDNode.fromBase58(encodedExtendedPublicKey.value, this.bitcoinJS.config.network)
204
- .derive(visibilityIndex)
205
- .derive(addressIndex)
206
- .getPublicKeyBuffer();
207
- return [2 /*return*/, (0, module_kit_1.newPublicKey)(childPublicKey.toString('hex'), 'hex')];
208
- });
209
- });
210
- };
211
- BitcoinProtocolImpl.prototype.getDetailsFromTransaction = function (transaction, _publicKey) {
212
- return __awaiter(this, void 0, void 0, function () {
213
- return __generator(this, function (_a) {
214
- switch (transaction.type) {
215
- case 'signed':
216
- return [2 /*return*/, this.getDetailsFromSignedTransaction(transaction)];
217
- case 'unsigned':
218
- return [2 /*return*/, this.getDetailsFromUnsignedTransaction(transaction)];
219
- default:
220
- (0, coinlib_core_1.assertNever)(transaction);
221
- throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Unsupported transaction type.');
222
- }
223
- return [2 /*return*/];
224
- });
225
- });
226
- };
227
- BitcoinProtocolImpl.prototype.getDetailsFromSignedTransaction = function (transaction) {
228
- return __awaiter(this, void 0, void 0, function () {
229
- var tx, bitcoinTx;
230
- var _this = this;
231
- return __generator(this, function (_a) {
232
- tx = {
233
- from: transaction.from,
234
- to: [],
235
- isInbound: false,
236
- amount: (0, module_kit_1.newAmount)(transaction.amount, 'blockchain'),
237
- fee: (0, module_kit_1.newAmount)(transaction.fee, 'blockchain'),
238
- network: this.options.network
239
- };
240
- bitcoinTx = this.bitcoinJS.lib.Transaction.fromHex(transaction.transaction);
241
- bitcoinTx.outs.forEach(function (output) {
242
- var address = _this.bitcoinJS.lib.address.fromOutputScript(output.script, _this.bitcoinJS.config.network);
243
- // only works if one output is target and rest is change, but this way we can filter out change addresses
244
- if (new bignumber_1.default(output.value).isEqualTo(transaction.amount)) {
245
- tx.to.push(address);
246
- }
247
- });
248
- return [2 /*return*/, [tx]];
249
- });
250
- });
251
- };
252
- BitcoinProtocolImpl.prototype.getDetailsFromUnsignedTransaction = function (transaction) {
253
- return __awaiter(this, void 0, void 0, function () {
254
- var fee, _i, _a, txIn, _b, _c, txOut;
255
- return __generator(this, function (_d) {
256
- fee = new bignumber_1.default(0);
257
- for (_i = 0, _a = transaction.ins; _i < _a.length; _i++) {
258
- txIn = _a[_i];
259
- fee = fee.plus(new bignumber_1.default(txIn.value));
260
- }
261
- for (_b = 0, _c = transaction.outs; _b < _c.length; _b++) {
262
- txOut = _c[_b];
263
- fee = fee.minus(new bignumber_1.default(txOut.value));
264
- }
265
- return [2 /*return*/, [
266
- {
267
- from: transaction.ins.map(function (obj) { return obj.address; }),
268
- to: transaction.outs.filter(function (obj) { return !obj.isChange; }).map(function (obj) { return obj.recipient; }),
269
- isInbound: false,
270
- amount: (0, module_kit_1.newAmount)(transaction.outs
271
- .filter(function (obj) { return !obj.isChange; })
272
- .map(function (obj) { return new bignumber_1.default(obj.value); })
273
- .reduce(function (accumulator, currentValue) { return accumulator.plus(currentValue); }), 'blockchain'),
274
- fee: (0, module_kit_1.newAmount)(fee, 'blockchain'),
275
- network: this.options.network
276
- }
277
- ]];
278
- });
279
- });
280
- };
281
- BitcoinProtocolImpl.prototype.verifyMessageWithPublicKey = function (message, signature, publicKey) {
282
- return __awaiter(this, void 0, void 0, function () {
283
- var encodedSignature;
284
- return __generator(this, function (_a) {
285
- encodedSignature = (0, signature_1.convertSignature)(signature, 'encoded');
286
- return [2 /*return*/, this.cryptoClient.verifyMessage(message, encodedSignature.value, publicKey.value)];
287
- });
288
- });
289
- };
290
- BitcoinProtocolImpl.prototype.encryptAsymmetricWithPublicKey = function (payload, publicKey) {
291
- return __awaiter(this, void 0, void 0, function () {
292
- var nonExtendedPublicKey, _a, hexNonExtendedPublicKey;
293
- return __generator(this, function (_b) {
294
- switch (_b.label) {
295
- case 0:
296
- if (!(publicKey.type === 'pub')) return [3 /*break*/, 1];
297
- _a = publicKey;
298
- return [3 /*break*/, 3];
299
- case 1: return [4 /*yield*/, this.deriveFromExtendedPublicKey(publicKey, 0, 0)];
300
- case 2:
301
- _a = _b.sent();
302
- _b.label = 3;
303
- case 3:
304
- nonExtendedPublicKey = _a;
305
- hexNonExtendedPublicKey = (0, key_1.convertPublicKey)(nonExtendedPublicKey, 'hex');
306
- return [2 /*return*/, this.cryptoClient.encryptAsymmetric(payload, hexNonExtendedPublicKey.value)];
307
- }
308
- });
309
- });
310
- };
311
- // Offline
312
- BitcoinProtocolImpl.prototype.getKeyPairFromSecret = function (secret, derivationPath) {
313
- return __awaiter(this, void 0, void 0, function () {
314
- return __generator(this, function (_a) {
315
- switch (secret.type) {
316
- case 'hex':
317
- return [2 /*return*/, this.getKeyPairFromHexSecret(secret.value, derivationPath)];
318
- case 'mnemonic':
319
- return [2 /*return*/, this.getKeyPairFromMnemonic(secret.value, derivationPath, secret.password)];
320
- default:
321
- (0, coinlib_core_1.assertNever)(secret);
322
- throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Unsupported secret type.');
323
- }
324
- return [2 /*return*/];
325
- });
326
- });
327
- };
328
- BitcoinProtocolImpl.prototype.getKeyPairFromHexSecret = function (secret, derivationPath) {
329
- return __awaiter(this, void 0, void 0, function () {
330
- var node, derivedNode;
331
- return __generator(this, function (_a) {
332
- node = this.bitcoinJS.lib.HDNode.fromSeedHex(secret, this.bitcoinJS.config.network);
333
- derivedNode = derivationPath ? node.derivePath(derivationPath) : node;
334
- return [2 /*return*/, {
335
- secretKey: (0, module_kit_1.newSecretKey)(derivedNode.keyPair.getPrivateKeyBuffer().toString('hex'), 'hex'),
336
- publicKey: (0, module_kit_1.newPublicKey)(derivedNode.keyPair.getPublicKeyBuffer().toString('hex'), 'hex')
337
- }];
338
- });
339
- });
340
- };
341
- BitcoinProtocolImpl.prototype.getKeyPairFromMnemonic = function (mnemonic, derivationPath, password) {
342
- return __awaiter(this, void 0, void 0, function () {
343
- var secret;
344
- return __generator(this, function (_a) {
345
- secret = (0, index_2.mnemonicToSeed)(mnemonic, password);
346
- return [2 /*return*/, this.getKeyPairFromHexSecret(secret.toString('hex'), derivationPath)];
347
- });
348
- });
349
- };
350
- BitcoinProtocolImpl.prototype.getExtendedKeyPairFromSecret = function (secret, derivationPath) {
351
- return __awaiter(this, void 0, void 0, function () {
352
- return __generator(this, function (_a) {
353
- switch (secret.type) {
354
- case 'hex':
355
- return [2 /*return*/, this.getExtendedKeyPairFromHexSecret(secret.value, derivationPath)];
356
- case 'mnemonic':
357
- return [2 /*return*/, this.getExtendedKeyPairFromMnemonic(secret.value, derivationPath, secret.password)];
358
- default:
359
- (0, coinlib_core_1.assertNever)(secret);
360
- throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Unsupported secret type.');
361
- }
362
- return [2 /*return*/];
363
- });
364
- });
365
- };
366
- BitcoinProtocolImpl.prototype.getExtendedKeyPairFromHexSecret = function (secret, derivationPath) {
367
- return __awaiter(this, void 0, void 0, function () {
368
- var node, derivedNode;
369
- return __generator(this, function (_a) {
370
- node = this.bitcoinJS.lib.HDNode.fromSeedHex(secret, this.bitcoinJS.config.network);
371
- derivedNode = derivationPath ? node.derivePath(derivationPath) : undefined;
372
- return [2 /*return*/, {
373
- secretKey: (0, module_kit_1.newExtendedSecretKey)(derivedNode.toBase58(), 'encoded'),
374
- publicKey: (0, module_kit_1.newExtendedPublicKey)(derivedNode.neutered().toBase58(), 'encoded')
375
- }];
376
- });
377
- });
378
- };
379
- BitcoinProtocolImpl.prototype.getExtendedKeyPairFromMnemonic = function (mnemonic, derivationPath, password) {
380
- return __awaiter(this, void 0, void 0, function () {
381
- var secret;
382
- return __generator(this, function (_a) {
383
- secret = (0, index_2.mnemonicToSeed)(mnemonic, password);
384
- return [2 /*return*/, this.getExtendedKeyPairFromHexSecret(secret.toString('hex'), derivationPath)];
385
- });
386
- });
387
- };
388
- BitcoinProtocolImpl.prototype.deriveFromExtendedSecretKey = function (extendedSecretKey, visibilityIndex, addressIndex) {
389
- return __awaiter(this, void 0, void 0, function () {
390
- var encodedExtendedSecretKey, childSecretKey;
391
- return __generator(this, function (_a) {
392
- encodedExtendedSecretKey = (0, key_1.convertExtendedSecretKey)(extendedSecretKey, 'encoded');
393
- childSecretKey = this.bitcoinJS.lib.HDNode.fromBase58(encodedExtendedSecretKey.value, this.bitcoinJS.config.network)
394
- .derive(visibilityIndex)
395
- .derive(addressIndex)
396
- .getPrivateKeyBuffer();
397
- return [2 /*return*/, (0, module_kit_1.newSecretKey)(childSecretKey.toString('hex'), 'hex')];
398
- });
399
- });
400
- };
401
- BitcoinProtocolImpl.prototype.signTransactionWithSecretKey = function (transaction, secretKey) {
402
- return __awaiter(this, void 0, void 0, function () {
403
- return __generator(this, function (_a) {
404
- switch (secretKey.type) {
405
- case 'priv':
406
- return [2 /*return*/, this.signTransactionWithNonExtendedSecretKey(transaction, secretKey)];
407
- case 'xpriv':
408
- return [2 /*return*/, this.signTransactionWithExtendedSecretKey(transaction, secretKey)];
409
- default:
410
- (0, coinlib_core_1.assertNever)(secretKey);
411
- throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Secret key type not supported.');
412
- }
413
- return [2 /*return*/];
414
- });
415
- });
416
- };
417
- BitcoinProtocolImpl.prototype.signTransactionWithNonExtendedSecretKey = function (transaction, secretKey) {
418
- return __awaiter(this, void 0, void 0, function () {
419
- var hexSecretKey, transactionBuilder, _i, _a, input, _b, _c, output, bufferSecretKey, keyPair, publicKey, generatedChangeAddress, i;
420
- return __generator(this, function (_d) {
421
- switch (_d.label) {
422
- case 0:
423
- hexSecretKey = (0, key_1.convertSecretKey)(secretKey, 'hex');
424
- transactionBuilder = new this.bitcoinJS.lib.TransactionBuilder(this.bitcoinJS.config.network);
425
- for (_i = 0, _a = transaction.ins; _i < _a.length; _i++) {
426
- input = _a[_i];
427
- transactionBuilder.addInput(input.txId, input.vout);
428
- }
429
- _b = 0, _c = transaction.outs;
430
- _d.label = 1;
431
- case 1:
432
- if (!(_b < _c.length)) return [3 /*break*/, 5];
433
- output = _c[_b];
434
- if (!output.isChange) return [3 /*break*/, 3];
435
- bufferSecretKey = Buffer.from(secretKey.value, 'hex');
436
- keyPair = this.bitcoinJS.lib.ECPair(BigInteger.fromBuffer(bufferSecretKey), null, {
437
- network: this.bitcoinJS.config.network
438
- });
439
- publicKey = (0, module_kit_1.newPublicKey)(keyPair.getPublicKeyBuffer().toString('hex'), 'hex');
440
- return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
441
- case 2:
442
- generatedChangeAddress = _d.sent();
443
- if (generatedChangeAddress !== output.recipient) {
444
- throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.BITCOIN, 'Change address could not be verified.');
445
- }
446
- _d.label = 3;
447
- case 3:
448
- transactionBuilder.addOutput(output.recipient, new bignumber_1.default(output.value).toNumber());
449
- _d.label = 4;
450
- case 4:
451
- _b++;
452
- return [3 /*break*/, 1];
453
- case 5:
454
- for (i = 0; i < transaction.ins.length; i++) {
455
- transactionBuilder.sign(i, Buffer.from(hexSecretKey.value, 'hex'));
456
- }
457
- return [2 /*return*/, this.createSignedTransaction(transaction, transactionBuilder)];
458
- }
459
- });
460
- });
461
- };
462
- BitcoinProtocolImpl.prototype.signTransactionWithExtendedSecretKey = function (transaction, extendedSecretKey) {
463
- return __awaiter(this, void 0, void 0, function () {
464
- var encodedExtendedSecretKey, transactionBuilder, node, _i, _a, input, changeAddressBatchSize, changeAddressMaxAddresses, _loop_1, this_1, _b, _c, output, i;
465
- var _this = this;
466
- return __generator(this, function (_d) {
467
- switch (_d.label) {
468
- case 0:
469
- encodedExtendedSecretKey = (0, key_1.convertExtendedSecretKey)(extendedSecretKey, 'encoded');
470
- transactionBuilder = new this.bitcoinJS.lib.TransactionBuilder(this.bitcoinJS.config.network);
471
- node = this.bitcoinJS.lib.HDNode.fromBase58(encodedExtendedSecretKey.value, this.bitcoinJS.config.network);
472
- for (_i = 0, _a = transaction.ins; _i < _a.length; _i++) {
473
- input = _a[_i];
474
- transactionBuilder.addInput(input.txId, input.vout);
475
- }
476
- changeAddressBatchSize = 10;
477
- changeAddressMaxAddresses = 500;
478
- _loop_1 = function (output) {
479
- var changeAddressIsValid, extendedPublicKey_1, derivedPublicKey, generatedChangeAddress, _loop_2, out_x_1, x;
480
- return __generator(this, function (_e) {
481
- switch (_e.label) {
482
- case 0:
483
- changeAddressIsValid = false;
484
- if (!output.isChange) return [3 /*break*/, 8];
485
- extendedPublicKey_1 = (0, module_kit_1.newExtendedPublicKey)(node.neutered().toBase58(), 'encoded');
486
- if (!output.derivationPath) return [3 /*break*/, 3];
487
- return [4 /*yield*/, this_1.deriveFromExtendedPublicKey(extendedPublicKey_1, 1, parseInt(output.derivationPath, 10))];
488
- case 1:
489
- derivedPublicKey = _e.sent();
490
- return [4 /*yield*/, this_1.getAddressFromPublicKey(derivedPublicKey)];
491
- case 2:
492
- generatedChangeAddress = _e.sent();
493
- changeAddressIsValid = generatedChangeAddress === output.recipient;
494
- return [3 /*break*/, 7];
495
- case 3:
496
- _loop_2 = function (x) {
497
- var derivedPublicKeys, addresses;
498
- return __generator(this, function (_f) {
499
- switch (_f.label) {
500
- case 0: return [4 /*yield*/, Promise.all(Array.from(new Array(changeAddressBatchSize)).map(function () { return __awaiter(_this, void 0, void 0, function () {
501
- return __generator(this, function (_a) {
502
- return [2 /*return*/, this.deriveFromExtendedPublicKey(extendedPublicKey_1, 1, x)];
503
- });
504
- }); }))];
505
- case 1:
506
- derivedPublicKeys = _f.sent();
507
- return [4 /*yield*/, Promise.all(derivedPublicKeys.map(function (publicKey) {
508
- return _this.getAddressFromPublicKey(publicKey);
509
- }))];
510
- case 2:
511
- addresses = _f.sent();
512
- if (addresses.indexOf(output.recipient) >= 0) {
513
- changeAddressIsValid = true;
514
- x = changeAddressMaxAddresses;
515
- }
516
- out_x_1 = x;
517
- return [2 /*return*/];
518
- }
519
- });
520
- };
521
- x = 0;
522
- _e.label = 4;
523
- case 4:
524
- if (!(x < changeAddressMaxAddresses)) return [3 /*break*/, 7];
525
- return [5 /*yield**/, _loop_2(x)];
526
- case 5:
527
- _e.sent();
528
- x = out_x_1;
529
- _e.label = 6;
530
- case 6:
531
- x += changeAddressBatchSize;
532
- return [3 /*break*/, 4];
533
- case 7:
534
- if (!changeAddressIsValid) {
535
- throw new errors_1.InvalidValueError(coinlib_core_1.Domain.BITCOIN, 'Change address could not be verified.');
536
- }
537
- _e.label = 8;
538
- case 8:
539
- transactionBuilder.addOutput(output.recipient, new bignumber_1.default(output.value).toNumber());
540
- return [2 /*return*/];
541
- }
542
- });
543
- };
544
- this_1 = this;
545
- _b = 0, _c = transaction.outs;
546
- _d.label = 1;
547
- case 1:
548
- if (!(_b < _c.length)) return [3 /*break*/, 4];
549
- output = _c[_b];
550
- return [5 /*yield**/, _loop_1(output)];
551
- case 2:
552
- _d.sent();
553
- _d.label = 3;
554
- case 3:
555
- _b++;
556
- return [3 /*break*/, 1];
557
- case 4:
558
- for (i = 0; i < transaction.ins.length; i++) {
559
- transactionBuilder.sign(i, node.derivePath(transaction.ins[i].derivationPath));
560
- }
561
- return [2 /*return*/, this.createSignedTransaction(transaction, transactionBuilder)];
562
- }
563
- });
564
- });
565
- };
566
- BitcoinProtocolImpl.prototype.createSignedTransaction = function (unsignedTransaction, transactionBuilder) {
567
- var fee = new bignumber_1.default(0);
568
- for (var _i = 0, _a = unsignedTransaction.ins; _i < _a.length; _i++) {
569
- var txIn = _a[_i];
570
- fee = fee.plus(new bignumber_1.default(txIn.value));
571
- }
572
- for (var _b = 0, _c = unsignedTransaction.outs; _b < _c.length; _b++) {
573
- var txOut = _c[_b];
574
- fee = fee.minus(new bignumber_1.default(txOut.value));
575
- }
576
- return (0, module_kit_1.newSignedTransaction)({
577
- from: unsignedTransaction.ins.map(function (obj) { return obj.address; }),
578
- to: unsignedTransaction.outs.filter(function (obj) { return !obj.isChange; }).map(function (obj) { return obj.recipient; }),
579
- amount: unsignedTransaction.outs
580
- .filter(function (obj) { return !obj.isChange; })
581
- .map(function (obj) { return new bignumber_1.default(obj.value); })
582
- .reduce(function (accumulator, currentValue) { return accumulator.plus(currentValue); })
583
- .toString(10),
584
- fee: fee.toString(10),
585
- transaction: transactionBuilder.build().toHex()
586
- });
587
- };
588
- BitcoinProtocolImpl.prototype.signMessageWithKeyPair = function (message, keyPair) {
589
- return __awaiter(this, void 0, void 0, function () {
590
- var hexSecretKey, signature;
591
- return __generator(this, function (_a) {
592
- switch (_a.label) {
593
- case 0:
594
- hexSecretKey = keyPair.secretKey.type === 'priv' ? (0, key_1.convertSecretKey)(keyPair.secretKey, 'hex') : (0, key_1.convertExtendedSecretKey)(keyPair.secretKey, 'hex');
595
- return [4 /*yield*/, this.cryptoClient.signMessage(message, { privateKey: hexSecretKey.value })];
596
- case 1:
597
- signature = _a.sent();
598
- return [2 /*return*/, (0, module_kit_1.newSignature)(signature, 'encoded')];
599
- }
600
- });
601
- });
602
- };
603
- BitcoinProtocolImpl.prototype.decryptAsymmetricWithKeyPair = function (payload, keyPair) {
604
- return __awaiter(this, void 0, void 0, function () {
605
- var hexSecretKey, encodedExtendedSecretKey, node, derivedNode;
606
- return __generator(this, function (_a) {
607
- if (keyPair.secretKey.type === 'priv') {
608
- hexSecretKey = (0, key_1.convertSecretKey)(keyPair.secretKey, 'hex');
609
- }
610
- else {
611
- encodedExtendedSecretKey = (0, key_1.convertExtendedSecretKey)(keyPair.secretKey, 'encoded');
612
- node = this.bitcoinJS.lib.HDNode.fromBase58(encodedExtendedSecretKey.value, this.bitcoinJS.config.network);
613
- derivedNode = node.derive(0).derive(0);
614
- hexSecretKey = (0, module_kit_1.newSecretKey)(derivedNode.keyPair.getPrivateKeyBuffer(), 'hex');
615
- }
616
- return [2 /*return*/, this.cryptoClient.decryptAsymmetric(payload, { publicKey: '', privateKey: hexSecretKey.value })];
617
- });
618
- });
619
- };
620
- BitcoinProtocolImpl.prototype.encryptAESWithSecretKey = function (payload, secretKey) {
621
- return __awaiter(this, void 0, void 0, function () {
622
- return __generator(this, function (_a) {
623
- return [2 /*return*/, this.cryptoClient.encryptAES(payload, secretKey.value)];
624
- });
625
- });
626
- };
627
- BitcoinProtocolImpl.prototype.decryptAESWithSecretKey = function (payload, secretKey) {
628
- return __awaiter(this, void 0, void 0, function () {
629
- return __generator(this, function (_a) {
630
- return [2 /*return*/, this.cryptoClient.decryptAES(payload, secretKey.value)];
631
- });
632
- });
633
- };
634
- // Online
635
- BitcoinProtocolImpl.prototype.getNetwork = function () {
636
- return __awaiter(this, void 0, void 0, function () {
637
- return __generator(this, function (_a) {
638
- return [2 /*return*/, this.options.network];
639
- });
640
- });
641
- };
642
- BitcoinProtocolImpl.prototype.getTransactionsForPublicKey = function (publicKey, limit, cursor) {
643
- return __awaiter(this, void 0, void 0, function () {
644
- return __generator(this, function (_a) {
645
- switch (publicKey.type) {
646
- case 'pub':
647
- return [2 /*return*/, this.getTransactionsForNonExtendedPublicKey(publicKey, limit, cursor)];
648
- case 'xpub':
649
- return [2 /*return*/, this.getTransactionsForExtendedPublicKey(publicKey, limit, cursor)];
650
- default:
651
- (0, coinlib_core_1.assertNever)(publicKey);
652
- throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Public key type not supported');
653
- }
654
- return [2 /*return*/];
655
- });
656
- });
657
- };
658
- BitcoinProtocolImpl.prototype.getTransactionsForNonExtendedPublicKey = function (publicKey, limit, cursor) {
659
- return __awaiter(this, void 0, void 0, function () {
660
- var address;
661
- return __generator(this, function (_a) {
662
- switch (_a.label) {
663
- case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
664
- case 1:
665
- address = _a.sent();
666
- return [2 /*return*/, this.getTransactionsForAddresses([address], limit, cursor)];
667
- }
668
- });
669
- });
670
- };
671
- BitcoinProtocolImpl.prototype.getTransactionsForExtendedPublicKey = function (extendedPublicKey, limit, cursor) {
672
- var _a;
673
- return __awaiter(this, void 0, void 0, function () {
674
- var encodedExtendedPublicKey, page, url, data, ourAddresses, airGapTransactions, _i, _b, transaction, tempAirGapTransactionFrom, tempAirGapTransactionTo, tempAirGapTransactionIsInbound, amount, _c, _d, vin, _e, _f, vout, airGapTransaction, hasNext;
675
- return __generator(this, function (_g) {
676
- switch (_g.label) {
677
- case 0:
678
- encodedExtendedPublicKey = this.convertExtendedPublicKey(extendedPublicKey, 'encoded');
679
- page = (_a = cursor === null || cursor === void 0 ? void 0 : cursor.page) !== null && _a !== void 0 ? _a : 1;
680
- url = "".concat(this.options.network.indexerApi, "/api/v2/xpub/").concat(encodedExtendedPublicKey.value, "?details=txs&tokens=used&pageSize=").concat(limit, "&page=").concat(page);
681
- return [4 /*yield*/, index_1.default.get(url, {
682
- responseType: 'json'
683
- })];
684
- case 1:
685
- data = (_g.sent()).data;
686
- ourAddresses = (data.tokens || []).filter(function (token) { return token.type === 'XPUBAddress'; }).map(function (token) { return token.name; });
687
- airGapTransactions = [];
688
- if (data.page === page) {
689
- for (_i = 0, _b = data.transactions || []; _i < _b.length; _i++) {
690
- transaction = _b[_i];
691
- tempAirGapTransactionFrom = [];
692
- tempAirGapTransactionTo = [];
693
- tempAirGapTransactionIsInbound = true;
694
- amount = new bignumber_1.default(0);
695
- for (_c = 0, _d = transaction.vin; _c < _d.length; _c++) {
696
- vin = _d[_c];
697
- if ((0, common_1.containsSome)(vin.addresses, ourAddresses)) {
698
- tempAirGapTransactionIsInbound = false;
699
- }
700
- tempAirGapTransactionFrom.push.apply(tempAirGapTransactionFrom, vin.addresses);
701
- amount = amount.plus(vin.value);
702
- }
703
- for (_e = 0, _f = transaction.vout; _e < _f.length; _e++) {
704
- vout = _f[_e];
705
- if (vout.addresses) {
706
- tempAirGapTransactionTo.push.apply(tempAirGapTransactionTo, vout.addresses);
707
- // If receiving address is our address, and transaction is outbound => our change
708
- if ((0, common_1.containsSome)(vout.addresses, ourAddresses) && !tempAirGapTransactionIsInbound) {
709
- // remove only if related to this address
710
- amount = amount.minus(vout.value);
711
- }
712
- // If receiving address is not ours, and transaction isbound => senders change
713
- if (!(0, common_1.containsSome)(vout.addresses, ourAddresses) && tempAirGapTransactionIsInbound) {
714
- amount = amount.minus(vout.value);
715
- }
716
- }
717
- }
718
- // deduct fee from amount
719
- amount = amount.minus(transaction.fees);
720
- airGapTransaction = {
721
- from: tempAirGapTransactionFrom,
722
- to: tempAirGapTransactionTo,
723
- isInbound: tempAirGapTransactionIsInbound,
724
- amount: (0, module_kit_1.newAmount)(amount, 'blockchain'),
725
- fee: (0, module_kit_1.newAmount)(transaction.fees, 'blockchain'),
726
- status: {
727
- type: 'applied',
728
- hash: transaction.txid,
729
- block: transaction.blockHeight.toString()
730
- },
731
- network: this.options.network,
732
- timestamp: transaction.blockTime
733
- };
734
- airGapTransactions.push(airGapTransaction);
735
- }
736
- }
737
- hasNext = page < data.totalPages;
738
- return [2 /*return*/, {
739
- transactions: airGapTransactions,
740
- cursor: {
741
- hasNext: hasNext,
742
- page: hasNext ? page + 1 : undefined
743
- }
744
- }];
745
- }
746
- });
747
- });
748
- };
749
- BitcoinProtocolImpl.prototype.getTransactionsForAddress = function (address, limit, cursor) {
750
- return __awaiter(this, void 0, void 0, function () {
751
- return __generator(this, function (_a) {
752
- return [2 /*return*/, this.getTransactionsForAddresses([address], limit, cursor)];
753
- });
754
- });
755
- };
756
- BitcoinProtocolImpl.prototype.getTransactionsForAddresses = function (addresses, limit, cursor) {
757
- var _a;
758
- return __awaiter(this, void 0, void 0, function () {
759
- var airGapTransactions, page, url, data, _i, _b, transaction, tempAirGapTransactionFrom, tempAirGapTransactionTo, tempAirGapTransactionIsInbound, amount, _c, _d, vin, _e, _f, vout, airGapTransaction, hasNext;
760
- return __generator(this, function (_g) {
761
- switch (_g.label) {
762
- case 0:
763
- airGapTransactions = [];
764
- page = (_a = cursor === null || cursor === void 0 ? void 0 : cursor.page) !== null && _a !== void 0 ? _a : 1;
765
- url = "".concat(this.options.network.indexerApi, "/api/v2/address/").concat(addresses[0], "?page=").concat(page, "&pageSize=").concat(limit, "&details=txs");
766
- return [4 /*yield*/, index_1.default.get(url, {
767
- responseType: 'json'
768
- })];
769
- case 1:
770
- data = (_g.sent()).data;
771
- if (data.page == page) {
772
- for (_i = 0, _b = data.transactions || []; _i < _b.length; _i++) {
773
- transaction = _b[_i];
774
- tempAirGapTransactionFrom = [];
775
- tempAirGapTransactionTo = [];
776
- tempAirGapTransactionIsInbound = true;
777
- amount = new bignumber_1.default(0);
778
- for (_c = 0, _d = transaction.vin; _c < _d.length; _c++) {
779
- vin = _d[_c];
780
- if (vin.addresses && (0, common_1.containsSome)(vin.addresses, addresses)) {
781
- tempAirGapTransactionIsInbound = false;
782
- }
783
- tempAirGapTransactionFrom.push.apply(tempAirGapTransactionFrom, vin.addresses);
784
- amount = vin.value ? amount.plus(vin.value) : amount;
785
- }
786
- for (_e = 0, _f = transaction.vout; _e < _f.length; _e++) {
787
- vout = _f[_e];
788
- if (vout.addresses) {
789
- tempAirGapTransactionTo.push.apply(tempAirGapTransactionTo, vout.addresses);
790
- // If receiving address is our address, and transaction is outbound => our change
791
- if ((0, common_1.containsSome)(vout.addresses, addresses) && !tempAirGapTransactionIsInbound) {
792
- // remove only if related to this address
793
- amount = amount.minus(new bignumber_1.default(vout.value));
794
- }
795
- // If receiving address is not ours, and transaction isbound => senders change
796
- if (!(0, common_1.containsSome)(vout.addresses, addresses) && tempAirGapTransactionIsInbound) {
797
- amount = amount.minus(new bignumber_1.default(vout.value));
798
- }
799
- }
800
- }
801
- // deduct fee from amount
802
- amount = amount.minus(new bignumber_1.default(transaction.fees));
803
- airGapTransaction = {
804
- from: tempAirGapTransactionFrom,
805
- to: tempAirGapTransactionTo,
806
- isInbound: tempAirGapTransactionIsInbound,
807
- amount: (0, module_kit_1.newAmount)(amount, 'blockchain'),
808
- fee: (0, module_kit_1.newAmount)(transaction.fees, 'blockchain'),
809
- status: {
810
- type: 'applied',
811
- hash: transaction.txid,
812
- block: transaction.blockHeight.toString()
813
- },
814
- network: this.options.network,
815
- timestamp: transaction.blockTime
816
- };
817
- airGapTransactions.push(airGapTransaction);
818
- }
819
- }
820
- hasNext = page < data.totalPages;
821
- return [2 /*return*/, {
822
- transactions: airGapTransactions,
823
- cursor: {
824
- hasNext: hasNext,
825
- page: hasNext ? page + 1 : undefined
826
- }
827
- }];
828
- }
829
- });
830
- });
831
- };
832
- BitcoinProtocolImpl.prototype.getBalanceOfPublicKey = function (publicKey) {
833
- return __awaiter(this, void 0, void 0, function () {
834
- return __generator(this, function (_a) {
835
- switch (publicKey.type) {
836
- case 'pub':
837
- return [2 /*return*/, this.getBalanceOfNonExtendedPublicKey(publicKey)];
838
- case 'xpub':
839
- return [2 /*return*/, this.getBalanceOfExtendedPublicKey(publicKey)];
840
- default:
841
- (0, coinlib_core_1.assertNever)(publicKey);
842
- throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Unsupported public key type.');
843
- }
844
- return [2 /*return*/];
845
- });
846
- });
847
- };
848
- BitcoinProtocolImpl.prototype.getBalanceOfNonExtendedPublicKey = function (publicKey) {
849
- return __awaiter(this, void 0, void 0, function () {
850
- var address;
851
- return __generator(this, function (_a) {
852
- switch (_a.label) {
853
- case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
854
- case 1:
855
- address = _a.sent();
856
- return [2 /*return*/, this.getBalanceOfAddresses([address])];
857
- }
858
- });
859
- });
860
- };
861
- BitcoinProtocolImpl.prototype.getBalanceOfExtendedPublicKey = function (extendedPublicKey) {
862
- return __awaiter(this, void 0, void 0, function () {
863
- var encodedExtendedPublicKey, data;
864
- return __generator(this, function (_a) {
865
- switch (_a.label) {
866
- case 0:
867
- encodedExtendedPublicKey = this.convertExtendedPublicKey(extendedPublicKey, 'encoded');
868
- return [4 /*yield*/, index_1.default.get("".concat(this.options.network.indexerApi, "/api/v2/xpub/").concat(encodedExtendedPublicKey.value, "?pageSize=1"), {
869
- responseType: 'json'
870
- })];
871
- case 1:
872
- data = (_a.sent()).data;
873
- return [2 /*return*/, {
874
- total: (0, module_kit_1.newAmount)(data.balance, 'blockchain')
875
- }];
876
- }
877
- });
878
- });
879
- };
880
- BitcoinProtocolImpl.prototype.getBalanceOfAddress = function (address) {
881
- return __awaiter(this, void 0, void 0, function () {
882
- return __generator(this, function (_a) {
883
- return [2 /*return*/, this.getBalanceOfAddresses([address])];
884
- });
885
- });
886
- };
887
- BitcoinProtocolImpl.prototype.getBalanceOfAddresses = function (addresses) {
888
- return __awaiter(this, void 0, void 0, function () {
889
- var valueAccumulator, _i, addresses_1, address, data;
890
- return __generator(this, function (_a) {
891
- switch (_a.label) {
892
- case 0:
893
- valueAccumulator = new bignumber_1.default(0);
894
- _i = 0, addresses_1 = addresses;
895
- _a.label = 1;
896
- case 1:
897
- if (!(_i < addresses_1.length)) return [3 /*break*/, 4];
898
- address = addresses_1[_i];
899
- return [4 /*yield*/, index_1.default.get("".concat(this.options.network.indexerApi, "/api/v2/address/").concat(address, "?details=basic"), {
900
- responseType: 'json'
901
- })];
902
- case 2:
903
- data = (_a.sent()).data;
904
- valueAccumulator = valueAccumulator.plus(new bignumber_1.default(data.balance));
905
- _a.label = 3;
906
- case 3:
907
- _i++;
908
- return [3 /*break*/, 1];
909
- case 4: return [2 /*return*/, {
910
- total: (0, module_kit_1.newAmount)(valueAccumulator, 'blockchain')
911
- }];
912
- }
913
- });
914
- });
915
- };
916
- BitcoinProtocolImpl.prototype.getTransactionMaxAmountWithPublicKey = function (publicKey, to, configuration) {
917
- return __awaiter(this, void 0, void 0, function () {
918
- return __generator(this, function (_a) {
919
- switch (_a.label) {
920
- case 0: return [4 /*yield*/, this.getBalanceOfPublicKey(publicKey)];
921
- case 1: return [2 /*return*/, (_a.sent()).total];
922
- }
923
- });
924
- });
925
- };
926
- BitcoinProtocolImpl.prototype.getTransactionFeeWithPublicKey = function (publicKey, details) {
927
- return __awaiter(this, void 0, void 0, function () {
928
- var result, estimatedFee, feeStepFactor, mediumFee, lowFee, highFee;
929
- return __generator(this, function (_a) {
930
- switch (_a.label) {
931
- case 0: return [4 /*yield*/, index_1.default.get("".concat(this.options.network.indexerApi, "/api/v2/estimatefee/5"))];
932
- case 1:
933
- result = (_a.sent()).data.result;
934
- estimatedFee = new bignumber_1.default((0, module_kit_1.newAmount)(result, 'BTC').blockchain(this.units).value);
935
- if (estimatedFee.isZero()) {
936
- return [2 /*return*/, this.feeDefaults];
937
- }
938
- feeStepFactor = new bignumber_1.default(0.5);
939
- mediumFee = estimatedFee;
940
- lowFee = mediumFee.minus(mediumFee.times(feeStepFactor)).integerValue(bignumber_1.default.ROUND_FLOOR);
941
- highFee = mediumFee.plus(mediumFee.times(feeStepFactor)).integerValue(bignumber_1.default.ROUND_FLOOR);
942
- return [2 /*return*/, {
943
- low: (0, module_kit_1.newAmount)(lowFee, 'blockchain'),
944
- medium: (0, module_kit_1.newAmount)(mediumFee, 'blockchain'),
945
- high: (0, module_kit_1.newAmount)(highFee, 'blockchain')
946
- }];
947
- }
948
- });
949
- });
950
- };
951
- BitcoinProtocolImpl.prototype.prepareTransactionWithPublicKey = function (publicKey, details, configuration) {
952
- return __awaiter(this, void 0, void 0, function () {
953
- return __generator(this, function (_a) {
954
- switch (publicKey.type) {
955
- case 'pub':
956
- return [2 /*return*/, this.prepareTransactionWithNonExtendedPublicKey(publicKey, details, configuration)];
957
- case 'xpub':
958
- return [2 /*return*/, this.prepareTransactionWithExtendedPublicKey(publicKey, details, configuration)];
959
- default:
960
- (0, coinlib_core_1.assertNever)(publicKey);
961
- throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Unuspported public key type.');
962
- }
963
- return [2 /*return*/];
964
- });
965
- });
966
- };
967
- BitcoinProtocolImpl.prototype.prepareTransactionWithNonExtendedPublicKey = function (publicKey, details, configuration) {
968
- return __awaiter(this, void 0, void 0, function () {
969
- var fee, estimatedFee, wrappedFee, transaction, address, utxos, totalRequiredBalance, valueAccumulator, _i, utxos_1, utxo, i, value, changeValue;
970
- var _this = this;
971
- return __generator(this, function (_a) {
972
- switch (_a.label) {
973
- case 0:
974
- if (!((configuration === null || configuration === void 0 ? void 0 : configuration.fee) !== undefined)) return [3 /*break*/, 1];
975
- fee = configuration.fee;
976
- return [3 /*break*/, 3];
977
- case 1: return [4 /*yield*/, this.getTransactionFeeWithPublicKey(publicKey, details)];
978
- case 2:
979
- estimatedFee = _a.sent();
980
- fee = estimatedFee.medium;
981
- _a.label = 3;
982
- case 3:
983
- wrappedFee = new bignumber_1.default((0, module_kit_1.newAmount)(fee).blockchain(this.units).value);
984
- transaction = (0, module_kit_1.newUnsignedTransaction)({
985
- ins: [],
986
- outs: []
987
- });
988
- return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
989
- case 4:
990
- address = _a.sent();
991
- return [4 /*yield*/, index_1.default.get("".concat(this.options.network.indexerApi, "/api/v2/utxo/").concat(address), {
992
- responseType: 'json'
993
- })];
994
- case 5:
995
- utxos = (_a.sent()).data;
996
- totalRequiredBalance = details
997
- .map(function (_a) {
998
- var amount = _a.amount;
999
- return new bignumber_1.default((0, module_kit_1.newAmount)(amount).blockchain(_this.units).value);
1000
- })
1001
- .reduce(function (accumulator, currentValue) { return accumulator.plus(currentValue); })
1002
- .plus(wrappedFee);
1003
- valueAccumulator = new bignumber_1.default(0);
1004
- for (_i = 0, utxos_1 = utxos; _i < utxos_1.length; _i++) {
1005
- utxo = utxos_1[_i];
1006
- valueAccumulator = valueAccumulator.plus(new bignumber_1.default(utxo.value));
1007
- transaction.ins.push({
1008
- txId: utxo.txid,
1009
- value: new bignumber_1.default(utxo.value).toString(10),
1010
- vout: utxo.vout,
1011
- address: address
1012
- });
1013
- if (valueAccumulator.isGreaterThanOrEqualTo(totalRequiredBalance)) {
1014
- break;
1015
- }
1016
- }
1017
- if (valueAccumulator.isLessThan(totalRequiredBalance)) {
1018
- throw new errors_1.BalanceError(coinlib_core_1.Domain.BITCOIN, "not enough balance, having ".concat(valueAccumulator.toFixed(), " of ").concat(totalRequiredBalance.toFixed()));
1019
- }
1020
- // tx.addInput(utxo.txid, utxo.vout)
1021
- for (i = 0; i < details.length; i++) {
1022
- value = (0, module_kit_1.newAmount)(details[i].amount).blockchain(this.units).value;
1023
- transaction.outs.push({
1024
- recipient: details[i].to,
1025
- isChange: false,
1026
- value: value
1027
- });
1028
- valueAccumulator = valueAccumulator.minus(value);
1029
- // tx.addOutput(details[i].to, details[i].amount)
1030
- }
1031
- changeValue = valueAccumulator.minus(wrappedFee);
1032
- if (changeValue.isGreaterThan(new bignumber_1.default(DUST_AMOUNT))) {
1033
- transaction.outs.push({
1034
- recipient: address,
1035
- isChange: true,
1036
- value: changeValue.toString(10)
1037
- });
1038
- }
1039
- return [2 /*return*/, transaction];
1040
- }
1041
- });
1042
- });
1043
- };
1044
- BitcoinProtocolImpl.prototype.prepareTransactionWithExtendedPublicKey = function (extendedPublicKey, details, configuration) {
1045
- return __awaiter(this, void 0, void 0, function () {
1046
- var targetFee, estimatedFee, wrappedFee, transaction, utxos, totalRequiredBalance, valueAccumulator, getPathIndexes, _i, utxos_2, utxo, indexes, derivedPublicKey, derivedAddress, i, value, lastUsedInternalAddress, changeValue, changeAddressIndex, derivedPublicKey, derivedAddress;
1047
- var _this = this;
1048
- return __generator(this, function (_a) {
1049
- switch (_a.label) {
1050
- case 0:
1051
- if (!((configuration === null || configuration === void 0 ? void 0 : configuration.fee) !== undefined)) return [3 /*break*/, 1];
1052
- targetFee = configuration.fee;
1053
- return [3 /*break*/, 3];
1054
- case 1: return [4 /*yield*/, this.getTransactionFeeWithPublicKey(extendedPublicKey, details)];
1055
- case 2:
1056
- estimatedFee = _a.sent();
1057
- targetFee = estimatedFee.medium;
1058
- _a.label = 3;
1059
- case 3:
1060
- wrappedFee = new bignumber_1.default((0, module_kit_1.newAmount)(targetFee).blockchain(this.units).value);
1061
- transaction = (0, module_kit_1.newUnsignedTransaction)({
1062
- ins: [],
1063
- outs: []
1064
- });
1065
- return [4 /*yield*/, index_1.default
1066
- .get("".concat(this.options.network.indexerApi, "/api/v2/utxo/").concat(extendedPublicKey.value, "?confirmed=true"), {
1067
- responseType: 'json'
1068
- })
1069
- .catch(function (error) {
1070
- throw new errors_1.NetworkError(coinlib_core_1.Domain.BITCOIN, error);
1071
- })];
1072
- case 4:
1073
- utxos = (_a.sent()).data;
1074
- if (utxos.length <= 0) {
1075
- throw new errors_1.BalanceError(coinlib_core_1.Domain.BITCOIN, 'not enough balance'); // no transactions found on those addresses, probably won't find anything in the next ones
1076
- }
1077
- totalRequiredBalance = details
1078
- .map(function (_a) {
1079
- var amount = _a.amount;
1080
- return new bignumber_1.default((0, module_kit_1.newAmount)(amount).blockchain(_this.units).value);
1081
- })
1082
- .reduce(function (accumulator, currentValue) { return accumulator.plus(currentValue); })
1083
- .plus(wrappedFee);
1084
- valueAccumulator = new bignumber_1.default(0);
1085
- getPathIndexes = function (path) {
1086
- var result = path
1087
- .split('/')
1088
- .slice(-2)
1089
- .map(function (item) { return parseInt(item, 10); })
1090
- .filter(function (item) { return !isNaN(item); });
1091
- if (result.length !== 2) {
1092
- throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.BITCOIN, 'Unexpected path format');
1093
- }
1094
- return [result[0], result[1]];
1095
- };
1096
- _i = 0, utxos_2 = utxos;
1097
- _a.label = 5;
1098
- case 5:
1099
- if (!(_i < utxos_2.length)) return [3 /*break*/, 9];
1100
- utxo = utxos_2[_i];
1101
- valueAccumulator = valueAccumulator.plus(utxo.value);
1102
- indexes = getPathIndexes(utxo.path);
1103
- return [4 /*yield*/, this.deriveFromExtendedPublicKey(extendedPublicKey, indexes[0], indexes[1])];
1104
- case 6:
1105
- derivedPublicKey = _a.sent();
1106
- return [4 /*yield*/, this.getAddressFromPublicKey(derivedPublicKey)];
1107
- case 7:
1108
- derivedAddress = _a.sent();
1109
- if (derivedAddress === utxo.address) {
1110
- transaction.ins.push({
1111
- txId: utxo.txid,
1112
- value: new bignumber_1.default(utxo.value).toString(10),
1113
- vout: utxo.vout,
1114
- address: utxo.address,
1115
- derivationPath: indexes.join('/')
1116
- });
1117
- }
1118
- else {
1119
- throw new errors_1.InvalidValueError(coinlib_core_1.Domain.BITCOIN, "Invalid address ".concat(JSON.stringify(utxo.address), " returned from API"));
1120
- }
1121
- if (valueAccumulator.isGreaterThanOrEqualTo(totalRequiredBalance)) {
1122
- return [3 /*break*/, 9];
1123
- }
1124
- _a.label = 8;
1125
- case 8:
1126
- _i++;
1127
- return [3 /*break*/, 5];
1128
- case 9:
1129
- if (valueAccumulator.isLessThan(totalRequiredBalance)) {
1130
- throw new errors_1.BalanceError(coinlib_core_1.Domain.BITCOIN, 'not enough balance');
1131
- }
1132
- for (i = 0; i < details.length; i++) {
1133
- value = (0, module_kit_1.newAmount)(details[i].amount).blockchain(this.units).value;
1134
- transaction.outs.push({
1135
- recipient: details[i].to,
1136
- isChange: false,
1137
- value: value,
1138
- derivationPath: '' // TODO: Remove this as soon as our serializer supports optional properties
1139
- });
1140
- valueAccumulator = valueAccumulator.minus(value);
1141
- }
1142
- lastUsedInternalAddress = Math.max.apply(Math, __spreadArray([-1], utxos
1143
- .map(function (utxo) { return getPathIndexes(utxo.path); })
1144
- .filter(function (indexes) { return indexes[0] === 1; })
1145
- .map(function (indexes) { return indexes[1]; }), false));
1146
- changeValue = valueAccumulator.minus(wrappedFee);
1147
- if (!changeValue.isGreaterThan(new bignumber_1.default(DUST_AMOUNT))) return [3 /*break*/, 12];
1148
- changeAddressIndex = lastUsedInternalAddress + 1;
1149
- return [4 /*yield*/, this.deriveFromExtendedPublicKey(extendedPublicKey, 1, changeAddressIndex)];
1150
- case 10:
1151
- derivedPublicKey = _a.sent();
1152
- return [4 /*yield*/, this.getAddressFromPublicKey(derivedPublicKey)];
1153
- case 11:
1154
- derivedAddress = _a.sent();
1155
- transaction.outs.push({
1156
- recipient: derivedAddress,
1157
- isChange: true,
1158
- value: changeValue.toString(10),
1159
- derivationPath: changeAddressIndex.toString()
1160
- });
1161
- _a.label = 12;
1162
- case 12: return [2 /*return*/, transaction];
1163
- }
1164
- });
1165
- });
1166
- };
1167
- BitcoinProtocolImpl.prototype.broadcastTransaction = function (transaction) {
1168
- return __awaiter(this, void 0, void 0, function () {
1169
- var data;
1170
- return __generator(this, function (_a) {
1171
- switch (_a.label) {
1172
- case 0: return [4 /*yield*/, index_1.default.post("".concat(this.options.network.indexerApi, "/api/v2/sendtx/"), transaction.transaction)];
1173
- case 1:
1174
- data = (_a.sent()).data;
1175
- return [2 /*return*/, data.result];
1176
- }
1177
- });
1178
- });
1179
- };
1180
- // Custom
1181
- BitcoinProtocolImpl.prototype.convertExtendedPublicKey = function (extendedPublicKey, targetFormat) {
1182
- return (0, key_1.convertExtendedPublicKey)(extendedPublicKey, {
1183
- format: targetFormat,
1184
- type: 'xpub'
1185
- });
1186
- };
1187
- return BitcoinProtocolImpl;
1188
- }());
1189
- exports.BitcoinProtocolImpl = BitcoinProtocolImpl;
1190
- // Factory
1191
- function createBitcoinProtocol(options) {
1192
- if (options === void 0) { options = {}; }
1193
- return new BitcoinProtocolImpl(options);
1194
- }
1195
- exports.createBitcoinProtocol = createBitcoinProtocol;
1196
- exports.BITCOIN_MAINNET_PROTOCOL_NETWORK = {
1197
- name: 'Mainnet',
1198
- type: 'mainnet',
1199
- rpcUrl: '',
1200
- indexerApi: 'https://bitcoin.prod.gke.papers.tech'
1201
- };
1202
- var DEFAULT_BITCOIN_PROTOCOL_NETWORK = exports.BITCOIN_MAINNET_PROTOCOL_NETWORK;
1203
- function createBitcoinProtocolOptions(network) {
1204
- if (network === void 0) { network = {}; }
1205
- return {
1206
- network: network.type === 'custom'
1207
- ? __assign(__assign(__assign({}, DEFAULT_BITCOIN_PROTOCOL_NETWORK), { bitcoinjsNetworkName: 'bitcoin' }), network) : __assign(__assign({}, DEFAULT_BITCOIN_PROTOCOL_NETWORK), network)
1208
- };
1209
- }
1210
- exports.createBitcoinProtocolOptions = createBitcoinProtocolOptions;
1211
- //# sourceMappingURL=BitcoinProtocol.js.map