beignet 0.0.21 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/electrum/index.js +105 -42
- package/dist/electrum/index.js.map +1 -1
- package/dist/types/electrum/index.d.ts +11 -4
- package/dist/types/electrum.js +8 -1
- package/dist/types/electrum.js.map +1 -1
- package/dist/types/types/electrum.d.ts +6 -0
- package/dist/types/types/transaction.d.ts +4 -0
- package/dist/types/types/wallet.d.ts +7 -1
- package/dist/types/utils/helpers.d.ts +2 -0
- package/dist/types/utils/wallet.d.ts +19 -1
- package/dist/types/wallet/constants.d.ts +0 -5
- package/dist/types/wallet/index.d.ts +14 -3
- package/dist/types/wallet.js.map +1 -1
- package/dist/utils/helpers.js +11 -1
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/wallet.js +48 -1
- package/dist/utils/wallet.js.map +1 -1
- package/dist/wallet/constants.js +1 -7
- package/dist/wallet/constants.js.map +1 -1
- package/dist/wallet/index.js +181 -86
- package/dist/wallet/index.js.map +1 -1
- package/docs/html/assets/search.js +1 -1
- package/docs/html/classes/Electrum.html +79 -70
- package/docs/html/classes/Transaction.html +59 -28
- package/docs/html/classes/Wallet.html +224 -174
- package/docs/html/enums/EAddressType.html +22 -7
- package/docs/html/enums/EAvailableNetworks.html +19 -11
- package/docs/html/enums/EBoostType.html +14 -6
- package/docs/html/enums/EElectrumNetworks.html +15 -7
- package/docs/html/enums/EFeeId.html +17 -9
- package/docs/html/enums/EPaymentType.html +14 -6
- package/docs/html/enums/EProtocol.html +14 -6
- package/docs/html/enums/EUnit.html +15 -7
- package/docs/html/functions/availableNetworks.html +12 -4
- package/docs/html/functions/constructByteCountParam.html +12 -4
- package/docs/html/functions/decodeOpReturnMessage.html +12 -4
- package/docs/html/functions/decodeRawTransaction.html +12 -4
- package/docs/html/functions/err.html +12 -4
- package/docs/html/functions/formatKeyDerivationPath.html +12 -4
- package/docs/html/functions/formatPeerData.html +12 -4
- package/docs/html/functions/generateMnemonic.html +12 -4
- package/docs/html/functions/generateWalletId.html +12 -4
- package/docs/html/functions/getAddressFromKeyPair.html +222 -0
- package/docs/html/functions/getAddressFromScriptPubKey.html +12 -4
- package/docs/html/functions/getAddressTypeFromPath.html +12 -4
- package/docs/html/functions/getAddressesFromPrivateKey.html +222 -0
- package/docs/html/functions/getByteCount.html +12 -4
- package/docs/html/functions/getDataFallback.html +12 -4
- package/docs/html/functions/getDefaultPort.html +12 -4
- package/docs/html/functions/getDefaultWalletData.html +12 -4
- package/docs/html/functions/getDefaultWalletDataKeys.html +12 -4
- package/docs/html/functions/getElectrumNetwork.html +216 -0
- package/docs/html/functions/getHighestUsedIndexFromTxHashes.html +12 -4
- package/docs/html/functions/getKeyDerivationPath.html +12 -4
- package/docs/html/functions/getKeyDerivationPathObject.html +12 -4
- package/docs/html/functions/getKeyDerivationPathString.html +12 -4
- package/docs/html/functions/getKeyValue.html +12 -4
- package/docs/html/functions/getPeers.html +12 -4
- package/docs/html/functions/getProtocolForPort.html +12 -4
- package/docs/html/functions/getScriptHash.html +12 -4
- package/docs/html/functions/getSeed.html +12 -4
- package/docs/html/functions/getSeedHash.html +12 -4
- package/docs/html/functions/getSha256.html +12 -4
- package/docs/html/functions/getStorageKeyValues.html +12 -4
- package/docs/html/{variables/mostUsedExchangeTickers.html → functions/getTapRootAddressFromPublicKey.html} +74 -97
- package/docs/html/functions/getTxFee.html +12 -4
- package/docs/html/functions/getWalletDataStorageKey.html +12 -4
- package/docs/html/functions/isP2trPrefix.html +217 -0
- package/docs/html/functions/isValidBech32mEncodedString.html +12 -4
- package/docs/html/functions/objectKeys-1.html +12 -4
- package/docs/html/functions/objectsMatch.html +12 -4
- package/docs/html/functions/ok.html +12 -4
- package/docs/html/functions/parseOnChainPaymentRequest.html +12 -4
- package/docs/html/functions/reduceValue.html +12 -4
- package/docs/html/functions/removeDustOutputs.html +12 -4
- package/docs/html/functions/setReplaceByFee.html +12 -4
- package/docs/html/functions/shuffleArray.html +12 -4
- package/docs/html/functions/{getExchangeRates.html → sleep.html} +22 -12
- package/docs/html/functions/validateAddress.html +12 -4
- package/docs/html/functions/validateMnemonic.html +12 -4
- package/docs/html/functions/validateTransaction.html +12 -4
- package/docs/html/index.html +22 -6
- package/docs/html/interfaces/IAddInput.html +16 -8
- package/docs/html/interfaces/IAddress.html +17 -9
- package/docs/html/interfaces/IAddressData.html +15 -7
- package/docs/html/interfaces/IAddressType.html +12 -4
- package/docs/html/interfaces/IAddressTypeData.html +18 -10
- package/docs/html/interfaces/IAddresses.html +12 -4
- package/docs/html/interfaces/IBoostedTransaction.html +16 -8
- package/docs/html/interfaces/IBoostedTransactions.html +12 -4
- package/docs/html/interfaces/ICreateTransaction.html +14 -6
- package/docs/html/interfaces/ICustomGetAddress.html +15 -7
- package/docs/html/interfaces/ICustomGetScriptHash.html +14 -6
- package/docs/html/interfaces/IElectrumGetAddressBalanceRes.html +15 -7
- package/docs/html/interfaces/IFormattedPeerData.html +17 -9
- package/docs/html/interfaces/IFormattedTransaction.html +31 -23
- package/docs/html/interfaces/IFormattedTransactions.html +12 -4
- package/docs/html/interfaces/IGenerateAddresses.html +19 -11
- package/docs/html/interfaces/IGenerateAddressesResponse.html +14 -6
- package/docs/html/interfaces/IGetAddress.html +15 -7
- package/docs/html/interfaces/IGetAddressBalanceRes.html +14 -6
- package/docs/html/interfaces/IGetAddressByPath.html +14 -6
- package/docs/html/interfaces/IGetAddressHistoryResponse.html +19 -11
- package/docs/html/interfaces/IGetAddressResponse.html +15 -7
- package/docs/html/interfaces/IGetAddressScriptHashBalances.html +17 -9
- package/docs/html/interfaces/IGetAddressScriptHashesHistoryResponse.html +17 -9
- package/docs/html/interfaces/{IExchangeRates.html → IGetAddressesFromKeyPair.html} +45 -23
- package/docs/html/interfaces/IGetAddressesFromPrivateKey.html +234 -0
- package/docs/html/interfaces/IGetDerivationPath.html +18 -10
- package/docs/html/interfaces/IGetFeeEstimatesResponse.html +16 -8
- package/docs/html/interfaces/IGetHeaderResponse.html +17 -9
- package/docs/html/interfaces/IGetNextAvailableAddressResponse.html +16 -8
- package/docs/html/interfaces/IGetTransactions.html +17 -9
- package/docs/html/interfaces/IGetTransactionsFromInputs.html +17 -9
- package/docs/html/interfaces/IGetUtxosResponse.html +14 -6
- package/docs/html/interfaces/IHeader.html +15 -7
- package/docs/html/interfaces/IIndexes.html +16 -8
- package/docs/html/interfaces/IKeyDerivationPath.html +17 -9
- package/docs/html/interfaces/IKeyDerivationPathData.html +14 -6
- package/docs/html/interfaces/INewBlock.html +14 -6
- package/docs/html/interfaces/IOnchainFees.html +17 -9
- package/docs/html/interfaces/IOutput.html +15 -7
- package/docs/html/interfaces/IPeerData.html +15 -7
- package/docs/html/interfaces/IPrivateKeyInfo.html +248 -0
- package/docs/html/interfaces/IRbfData.html +18 -10
- package/docs/html/interfaces/ISend.html +14 -6
- package/docs/html/interfaces/ISendTransaction.html +28 -20
- package/docs/html/interfaces/ISendTx.html +15 -7
- package/docs/html/interfaces/ISetupTransaction.html +17 -9
- package/docs/html/interfaces/ISubscribeToAddress.html +16 -8
- package/docs/html/interfaces/ISubscribeToHeader.html +16 -8
- package/docs/html/interfaces/ISweepPrivateKey.html +255 -0
- package/docs/html/interfaces/ISweepPrivateKeyRes.html +241 -0
- package/docs/html/interfaces/ITargets.html +16 -8
- package/docs/html/interfaces/ITransaction.html +17 -9
- package/docs/html/interfaces/ITxHash.html +13 -5
- package/docs/html/interfaces/ITxHashes.html +15 -7
- package/docs/html/interfaces/IUtxo.html +27 -21
- package/docs/html/interfaces/IVin.html +17 -9
- package/docs/html/interfaces/IVout.html +15 -7
- package/docs/html/interfaces/IWallet.html +53 -20
- package/docs/html/interfaces/IWalletData.html +30 -29
- package/docs/html/types/ElectrumConnectionPubSub.html +12 -4
- package/docs/html/types/ElectrumConnectionSubscription.html +13 -5
- package/docs/html/types/InputData.html +12 -4
- package/docs/html/types/ObjectKeys.html +12 -4
- package/docs/html/types/Result.html +12 -4
- package/docs/html/types/TAddressIndexInfo.html +12 -4
- package/docs/html/types/TAddressLabel.html +12 -4
- package/docs/html/types/TAddressType.html +12 -4
- package/docs/html/types/TAddressTypeContent.html +12 -4
- package/docs/html/types/TAddressTypes.html +12 -4
- package/docs/html/types/TAvailableNetworks.html +12 -4
- package/docs/html/types/TConnectToElectrumRes.html +12 -4
- package/docs/html/types/TDecodeRawTx.html +12 -4
- package/docs/html/types/TElectrumNetworks.html +12 -4
- package/docs/html/types/TGetAddressHistory.html +12 -4
- package/docs/html/types/TGetByteCountInput.html +12 -4
- package/docs/html/types/TGetByteCountInputs.html +12 -4
- package/docs/html/types/TGetByteCountOutput.html +12 -4
- package/docs/html/types/TGetByteCountOutputs.html +12 -4
- package/docs/html/types/TGetData.html +12 -4
- package/docs/html/types/TGetTotalFeeObj.html +12 -4
- package/docs/html/types/TKeyDerivationAccount.html +12 -4
- package/docs/html/types/TKeyDerivationChange.html +12 -4
- package/docs/html/types/TKeyDerivationCoinType.html +12 -4
- package/docs/html/types/TKeyDerivationIndex.html +12 -4
- package/docs/html/types/TKeyDerivationPurpose.html +12 -4
- package/docs/html/types/TMessageDataMap.html +12 -4
- package/docs/html/types/TMessageKeys.html +12 -4
- package/docs/html/types/TOnMessage.html +12 -4
- package/docs/html/types/TProcessUnconfirmedTransactions.html +12 -4
- package/docs/html/types/TProtocol.html +12 -4
- package/docs/html/types/TServer.html +12 -4
- package/docs/html/types/TSetData.html +12 -4
- package/docs/html/types/TSetupTransactionResponse.html +12 -4
- package/docs/html/types/TStorage.html +12 -4
- package/docs/html/types/TSubscribedReceive.html +12 -4
- package/docs/html/types/TTransactionMessage.html +12 -4
- package/docs/html/types/TTxResponse.html +12 -4
- package/docs/html/types/TTxResult.html +12 -4
- package/docs/html/types/TUnspentAddressScriptHashData.html +12 -4
- package/docs/html/types/TWalletDataKeys.html +12 -4
- package/docs/html/variables/defaultElectrumPorts.html +12 -4
- package/docs/html/variables/electrumConnection.html +12 -4
- package/docs/markdown/README.md +224 -128
- package/docs/markdown/classes/Electrum.md +74 -72
- package/docs/markdown/classes/Transaction.md +48 -23
- package/docs/markdown/classes/Wallet.md +240 -181
- package/docs/markdown/enums/EAddressType.md +14 -3
- package/docs/markdown/enums/EAvailableNetworks.md +7 -7
- package/docs/markdown/enums/EBoostType.md +2 -2
- package/docs/markdown/enums/EElectrumNetworks.md +3 -3
- package/docs/markdown/enums/EFeeId.md +5 -5
- package/docs/markdown/enums/EPaymentType.md +2 -2
- package/docs/markdown/enums/EProtocol.md +2 -2
- package/docs/markdown/enums/EUnit.md +3 -3
- package/docs/markdown/interfaces/IAddInput.md +4 -4
- package/docs/markdown/interfaces/IAddress.md +5 -5
- package/docs/markdown/interfaces/IAddressData.md +3 -3
- package/docs/markdown/interfaces/IAddressTypeData.md +6 -6
- package/docs/markdown/interfaces/IBoostedTransaction.md +4 -4
- package/docs/markdown/interfaces/ICreateTransaction.md +2 -2
- package/docs/markdown/interfaces/ICustomGetAddress.md +3 -3
- package/docs/markdown/interfaces/ICustomGetScriptHash.md +2 -2
- package/docs/markdown/interfaces/IElectrumGetAddressBalanceRes.md +3 -3
- package/docs/markdown/interfaces/IFormattedPeerData.md +5 -5
- package/docs/markdown/interfaces/IFormattedTransaction.md +19 -19
- package/docs/markdown/interfaces/IGenerateAddresses.md +7 -7
- package/docs/markdown/interfaces/IGenerateAddressesResponse.md +2 -2
- package/docs/markdown/interfaces/IGetAddress.md +3 -3
- package/docs/markdown/interfaces/IGetAddressBalanceRes.md +2 -2
- package/docs/markdown/interfaces/IGetAddressByPath.md +2 -2
- package/docs/markdown/interfaces/IGetAddressHistoryResponse.md +7 -7
- package/docs/markdown/interfaces/IGetAddressResponse.md +3 -3
- package/docs/markdown/interfaces/IGetAddressScriptHashBalances.md +5 -5
- package/docs/markdown/interfaces/IGetAddressScriptHashesHistoryResponse.md +5 -5
- package/docs/markdown/interfaces/IGetAddressesFromKeyPair.md +30 -0
- package/docs/markdown/interfaces/IGetAddressesFromPrivateKey.md +30 -0
- package/docs/markdown/interfaces/IGetDerivationPath.md +6 -6
- package/docs/markdown/interfaces/IGetFeeEstimatesResponse.md +4 -4
- package/docs/markdown/interfaces/IGetHeaderResponse.md +5 -5
- package/docs/markdown/interfaces/IGetNextAvailableAddressResponse.md +4 -4
- package/docs/markdown/interfaces/IGetTransactions.md +5 -5
- package/docs/markdown/interfaces/IGetTransactionsFromInputs.md +5 -5
- package/docs/markdown/interfaces/IGetUtxosResponse.md +2 -2
- package/docs/markdown/interfaces/IHeader.md +3 -3
- package/docs/markdown/interfaces/IIndexes.md +4 -4
- package/docs/markdown/interfaces/IKeyDerivationPath.md +5 -5
- package/docs/markdown/interfaces/IKeyDerivationPathData.md +2 -2
- package/docs/markdown/interfaces/INewBlock.md +2 -2
- package/docs/markdown/interfaces/IOnchainFees.md +5 -5
- package/docs/markdown/interfaces/IOutput.md +3 -3
- package/docs/markdown/interfaces/IPeerData.md +3 -3
- package/docs/markdown/interfaces/IPrivateKeyInfo.md +52 -0
- package/docs/markdown/interfaces/IRbfData.md +6 -6
- package/docs/markdown/interfaces/ISend.md +2 -2
- package/docs/markdown/interfaces/ISendTransaction.md +16 -16
- package/docs/markdown/interfaces/ISendTx.md +3 -3
- package/docs/markdown/interfaces/ISetupTransaction.md +5 -5
- package/docs/markdown/interfaces/ISubscribeToAddress.md +4 -4
- package/docs/markdown/interfaces/ISubscribeToHeader.md +4 -4
- package/docs/markdown/interfaces/ISweepPrivateKey.md +63 -0
- package/docs/markdown/interfaces/ISweepPrivateKeyRes.md +41 -0
- package/docs/markdown/interfaces/ITargets.md +4 -4
- package/docs/markdown/interfaces/ITransaction.md +5 -5
- package/docs/markdown/interfaces/ITxHash.md +1 -1
- package/docs/markdown/interfaces/ITxHashes.md +3 -3
- package/docs/markdown/interfaces/IUtxo.md +18 -23
- package/docs/markdown/interfaces/IVin.md +5 -5
- package/docs/markdown/interfaces/IVout.md +3 -3
- package/docs/markdown/interfaces/IWallet.md +50 -15
- package/docs/markdown/interfaces/IWalletData.md +18 -29
- package/package.json +3 -3
- package/src/electrum/index.ts +147 -60
- package/src/types/electrum.ts +7 -0
- package/src/types/transaction.ts +5 -0
- package/src/types/wallet.ts +7 -1
- package/src/utils/helpers.ts +14 -0
- package/src/utils/wallet.ts +73 -0
- package/src/wallet/constants.ts +0 -8
- package/src/wallet/index.ts +262 -118
- package/tests/wallet.test.ts +71 -1
- package/dist/mempool/index.js +0 -28
- package/dist/mempool/index.js.map +0 -1
- package/dist/types/mempool/index.d.ts +0 -15
- package/dist/types/mempool.js +0 -3
- package/dist/types/mempool.js.map +0 -1
- package/dist/types/types/mempool.d.ts +0 -16
- package/dist/types/utils/exchange-rate.d.ts +0 -30
- package/dist/utils/exchange-rate.js +0 -49
- package/dist/utils/exchange-rate.js.map +0 -1
- package/docs/markdown/interfaces/IExchangeRates.md +0 -7
package/tests/wallet.test.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import * as chai from 'chai';
|
|
2
2
|
import { validateMnemonic } from 'bip39';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
filterAddressesObjForGapLimit,
|
|
5
|
+
IAddress,
|
|
6
|
+
IAddresses,
|
|
7
|
+
Wallet
|
|
8
|
+
} from '../';
|
|
4
9
|
import {
|
|
5
10
|
EAddressType,
|
|
6
11
|
EAvailableNetworks,
|
|
12
|
+
filterAddressesForGapLimit,
|
|
13
|
+
filterAddressesObjForSingleIndex,
|
|
14
|
+
filterAddressesObjForStartingIndex,
|
|
7
15
|
generateMnemonic,
|
|
8
16
|
IGetUtxosResponse,
|
|
9
17
|
Result
|
|
@@ -219,6 +227,68 @@ describe('Wallet Library', async function () {
|
|
|
219
227
|
expect(getUtxosRes.value).to.deep.equal(expectedResult);
|
|
220
228
|
});
|
|
221
229
|
|
|
230
|
+
it('Should return addresses in range of the provided gap limit', async () => {
|
|
231
|
+
const gapLimitOptions = {
|
|
232
|
+
lookAhead: 2,
|
|
233
|
+
lookBehind: 2
|
|
234
|
+
};
|
|
235
|
+
const addressesObj = wallet.data.addresses[EAddressType.p2wpkh];
|
|
236
|
+
const addresses: IAddress[] = Object.values(addressesObj);
|
|
237
|
+
const index: number = wallet.data.addressIndex[EAddressType.p2wpkh].index;
|
|
238
|
+
expect(addresses.length).to.equal(25);
|
|
239
|
+
expect(index).to.equal(5);
|
|
240
|
+
expect(Math.min(...addresses.map((a) => a.index))).to.equal(0);
|
|
241
|
+
expect(Math.max(...addresses.map((a) => a.index))).to.equal(24);
|
|
242
|
+
|
|
243
|
+
const filteredAddresses = filterAddressesForGapLimit({
|
|
244
|
+
addresses,
|
|
245
|
+
index,
|
|
246
|
+
gapLimitOptions
|
|
247
|
+
});
|
|
248
|
+
let indexes = filteredAddresses.map((a) => a.index);
|
|
249
|
+
let minIndex = Math.min(...indexes);
|
|
250
|
+
let maxIndex = Math.max(...indexes);
|
|
251
|
+
expect(filteredAddresses.length).to.equal(5);
|
|
252
|
+
expect(minIndex).to.equal(3);
|
|
253
|
+
expect(maxIndex).to.equal(7);
|
|
254
|
+
|
|
255
|
+
const filteredAddressesObj = filterAddressesObjForGapLimit({
|
|
256
|
+
addresses: addressesObj,
|
|
257
|
+
index,
|
|
258
|
+
gapLimitOptions
|
|
259
|
+
});
|
|
260
|
+
indexes = Object.values(filteredAddressesObj).map((a: IAddress) => a.index);
|
|
261
|
+
minIndex = Math.min(...indexes);
|
|
262
|
+
maxIndex = Math.max(...indexes);
|
|
263
|
+
expect(indexes.length).to.equal(5);
|
|
264
|
+
expect(minIndex).to.equal(3);
|
|
265
|
+
expect(maxIndex).to.equal(7);
|
|
266
|
+
|
|
267
|
+
const filteredStartingAddresses = filterAddressesObjForStartingIndex({
|
|
268
|
+
addresses: addressesObj,
|
|
269
|
+
index
|
|
270
|
+
});
|
|
271
|
+
indexes = Object.values(filteredStartingAddresses).map(
|
|
272
|
+
(a: IAddress) => a.index
|
|
273
|
+
);
|
|
274
|
+
minIndex = Math.min(...indexes);
|
|
275
|
+
maxIndex = Math.max(...indexes);
|
|
276
|
+
expect(indexes.length).to.equal(20);
|
|
277
|
+
expect(minIndex).to.equal(5);
|
|
278
|
+
expect(maxIndex).to.equal(24);
|
|
279
|
+
|
|
280
|
+
const filteredSingleAddress = filterAddressesObjForSingleIndex({
|
|
281
|
+
addresses: addressesObj,
|
|
282
|
+
addressIndex: index
|
|
283
|
+
});
|
|
284
|
+
const singleAddress = Object.values(filteredSingleAddress);
|
|
285
|
+
minIndex = Math.min(...singleAddress.map((a: IAddress) => a.index));
|
|
286
|
+
maxIndex = Math.max(...singleAddress.map((a: IAddress) => a.index));
|
|
287
|
+
expect(singleAddress.length).to.equal(1);
|
|
288
|
+
expect(minIndex).to.equal(5);
|
|
289
|
+
expect(maxIndex).to.equal(5);
|
|
290
|
+
});
|
|
291
|
+
|
|
222
292
|
it('Should successfully return the private testnet key for a given path', async () => {
|
|
223
293
|
const addresses: IAddresses = wallet.data.addresses['p2wpkh'];
|
|
224
294
|
|
package/dist/mempool/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Mempool = void 0;
|
|
7
|
-
const mempool_js_1 = __importDefault(require("@mempool/mempool.js"));
|
|
8
|
-
class Mempool {
|
|
9
|
-
constructor({ wallet, hostname = 'mempool.space', network }) {
|
|
10
|
-
this.mempoolNetwork = network === 'bitcoin' ? 'mainnet' : network;
|
|
11
|
-
this.mempool = (0, mempool_js_1.default)({
|
|
12
|
-
hostname,
|
|
13
|
-
network: this.mempoolNetwork
|
|
14
|
-
}).bitcoin;
|
|
15
|
-
this._wallet = wallet;
|
|
16
|
-
const ws = this.mempool.websocket.initClient({
|
|
17
|
-
options: ['blocks', 'mempool-blocks']
|
|
18
|
-
});
|
|
19
|
-
ws.addEventListener('message', function incoming({ data }) {
|
|
20
|
-
console.log('Data!!!!', data);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
get wallet() {
|
|
24
|
-
return this._wallet;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.Mempool = Mempool;
|
|
28
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mempool/index.ts"],"names":[],"mappings":";;;;;;AAEA,qEAA4C;AAG5C,MAAa,OAAO;IAQnB,YAAY,EACX,MAAM,EACN,QAAQ,GAAG,eAAe,EAC1B,OAAO,EAKP;QACA,IAAI,CAAC,cAAc,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;QAClE,IAAI,CAAC,OAAO,GAAG,IAAA,oBAAS,EAAC;YACxB,QAAQ;YACR,OAAO,EAAE,IAAI,CAAC,cAAc;SAC5B,CAAC,CAAC,OAAO,CAAC;QACX,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QAGtB,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC;YAC5C,OAAO,EAAE,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SACrC,CAAC,CAAC;QAEH,EAAE,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,QAAQ,CAAC,EAAE,IAAI,EAAE;YACxD,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAc/B,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;CACD;AAlDD,0BAkDC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Wallet } from '../wallet';
|
|
2
|
-
import { EAvailableNetworks, TServer } from '../types';
|
|
3
|
-
export declare class Mempool {
|
|
4
|
-
private readonly _wallet;
|
|
5
|
-
private mempool;
|
|
6
|
-
servers?: TServer | TServer[];
|
|
7
|
-
readonly mempoolNetwork: 'mainnet' | 'testnet' | 'regtest';
|
|
8
|
-
onReceive?: (data: unknown) => void;
|
|
9
|
-
constructor({ wallet, hostname, network }: {
|
|
10
|
-
wallet: Wallet;
|
|
11
|
-
hostname: string;
|
|
12
|
-
network: EAvailableNetworks;
|
|
13
|
-
});
|
|
14
|
-
get wallet(): Wallet;
|
|
15
|
-
}
|
package/dist/types/mempool.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mempool.js","sourceRoot":"","sources":["../../src/types/mempool.ts"],"names":[],"mappings":""}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { AddressInstance } from '@mempool/mempool.js/lib/interfaces/bitcoin/addresses';
|
|
2
|
-
import { BlockInstance } from '@mempool/mempool.js/lib/interfaces/bitcoin/blocks';
|
|
3
|
-
import { DifficultyInstance } from '@mempool/mempool.js/lib/interfaces/bitcoin/difficulty';
|
|
4
|
-
import { FeeInstance } from '@mempool/mempool.js/lib/interfaces/bitcoin/fees';
|
|
5
|
-
import { MempoolInstance } from '@mempool/mempool.js/lib/interfaces/bitcoin/mempool';
|
|
6
|
-
import { TxInstance } from '@mempool/mempool.js/lib/interfaces/bitcoin/transactions';
|
|
7
|
-
import { WsInstance } from '@mempool/mempool.js/lib/interfaces/bitcoin/websockets';
|
|
8
|
-
export interface IMempoolBitcoin {
|
|
9
|
-
addresses: AddressInstance;
|
|
10
|
-
blocks: BlockInstance;
|
|
11
|
-
difficulty: DifficultyInstance;
|
|
12
|
-
fees: FeeInstance;
|
|
13
|
-
mempool: MempoolInstance;
|
|
14
|
-
transactions: TxInstance;
|
|
15
|
-
websocket: WsInstance;
|
|
16
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Result } from './result';
|
|
2
|
-
import { IExchangeRates } from '../types';
|
|
3
|
-
export declare const mostUsedExchangeTickers: {
|
|
4
|
-
USD: {
|
|
5
|
-
currencySymbol: string;
|
|
6
|
-
quote: string;
|
|
7
|
-
quoteName: string;
|
|
8
|
-
};
|
|
9
|
-
GBP: {
|
|
10
|
-
currencySymbol: string;
|
|
11
|
-
quote: string;
|
|
12
|
-
quoteName: string;
|
|
13
|
-
};
|
|
14
|
-
CAD: {
|
|
15
|
-
currencySymbol: string;
|
|
16
|
-
quote: string;
|
|
17
|
-
quoteName: string;
|
|
18
|
-
};
|
|
19
|
-
CNY: {
|
|
20
|
-
currencySymbol: string;
|
|
21
|
-
quote: string;
|
|
22
|
-
quoteName: string;
|
|
23
|
-
};
|
|
24
|
-
EUR: {
|
|
25
|
-
currencySymbol: string;
|
|
26
|
-
quote: string;
|
|
27
|
-
quoteName: string;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
export declare const getExchangeRates: () => Promise<Result<IExchangeRates>>;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getExchangeRates = exports.mostUsedExchangeTickers = void 0;
|
|
4
|
-
const result_1 = require("./result");
|
|
5
|
-
const constants_1 = require("../wallet/constants");
|
|
6
|
-
exports.mostUsedExchangeTickers = {
|
|
7
|
-
USD: {
|
|
8
|
-
currencySymbol: '$',
|
|
9
|
-
quote: 'USD',
|
|
10
|
-
quoteName: 'US Dollar'
|
|
11
|
-
},
|
|
12
|
-
GBP: {
|
|
13
|
-
currencySymbol: '£',
|
|
14
|
-
quote: 'GBP',
|
|
15
|
-
quoteName: 'Great British Pound'
|
|
16
|
-
},
|
|
17
|
-
CAD: {
|
|
18
|
-
currencySymbol: '$',
|
|
19
|
-
quote: 'CAD',
|
|
20
|
-
quoteName: 'Canadian Dollar'
|
|
21
|
-
},
|
|
22
|
-
CNY: {
|
|
23
|
-
currencySymbol: '¥',
|
|
24
|
-
quote: 'CNY',
|
|
25
|
-
quoteName: 'Chinese Yuan Renminbi'
|
|
26
|
-
},
|
|
27
|
-
EUR: { currencySymbol: '€', quote: 'EUR', quoteName: 'Euro' }
|
|
28
|
-
};
|
|
29
|
-
const getExchangeRates = async () => {
|
|
30
|
-
try {
|
|
31
|
-
const response = await fetch(`${constants_1.BLOCKTANK_HOST}/fx/rates/btc`);
|
|
32
|
-
const { tickers } = await response.json();
|
|
33
|
-
const rates = tickers.reduce((acc, ticker) => {
|
|
34
|
-
return Object.assign(Object.assign({}, acc), { [ticker.quote]: {
|
|
35
|
-
currencySymbol: ticker.currencySymbol,
|
|
36
|
-
quote: ticker.quote,
|
|
37
|
-
quoteName: ticker.quoteName,
|
|
38
|
-
rate: Math.round(Number(ticker.lastPrice) * 100) / 100,
|
|
39
|
-
lastUpdatedAt: ticker.lastUpdatedAt
|
|
40
|
-
} });
|
|
41
|
-
}, {});
|
|
42
|
-
return (0, result_1.ok)(rates);
|
|
43
|
-
}
|
|
44
|
-
catch (e) {
|
|
45
|
-
return (0, result_1.err)(e);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
exports.getExchangeRates = getExchangeRates;
|
|
49
|
-
//# sourceMappingURL=exchange-rate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exchange-rate.js","sourceRoot":"","sources":["../../src/utils/exchange-rate.ts"],"names":[],"mappings":";;;AAAA,qCAA2C;AAC3C,mDAAqD;AAGxC,QAAA,uBAAuB,GAAG;IACtC,GAAG,EAAE;QACJ,cAAc,EAAE,GAAG;QACnB,KAAK,EAAE,KAAK;QACZ,SAAS,EAAE,WAAW;KACtB;IACD,GAAG,EAAE;QACJ,cAAc,EAAE,GAAG;QACnB,KAAK,EAAE,KAAK;QACZ,SAAS,EAAE,qBAAqB;KAChC;IACD,GAAG,EAAE;QACJ,cAAc,EAAE,GAAG;QACnB,KAAK,EAAE,KAAK;QACZ,SAAS,EAAE,iBAAiB;KAC5B;IACD,GAAG,EAAE;QACJ,cAAc,EAAE,GAAG;QACnB,KAAK,EAAE,KAAK;QACZ,SAAS,EAAE,uBAAuB;KAClC;IACD,GAAG,EAAE,EAAE,cAAc,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE;CAC7D,CAAC;AAkBK,MAAM,gBAAgB,GAAG,KAAK,IAAqC,EAAE;IAC3E,IAAI;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,0BAAc,eAAe,CAAC,CAAC;QAC/D,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAE1C,MAAM,KAAK,GAAmB,OAAO,CAAC,MAAM,CAC3C,CAAC,GAAmB,EAAE,MAAe,EAAE,EAAE;YACxC,uCACI,GAAG,KACN,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;oBACf,cAAc,EAAE,MAAM,CAAC,cAAc;oBACrC,KAAK,EAAE,MAAM,CAAC,KAAK;oBACnB,SAAS,EAAE,MAAM,CAAC,SAAS;oBAC3B,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG;oBACtD,aAAa,EAAE,MAAM,CAAC,aAAa;iBACnC,IACA;QACH,CAAC,EACD,EAAE,CACF,CAAC;QAEF,OAAO,IAAA,WAAE,EAAC,KAAK,CAAC,CAAC;KACjB;IAAC,OAAO,CAAC,EAAE;QACX,OAAO,IAAA,YAAG,EAAC,CAAC,CAAC,CAAC;KACd;AACF,CAAC,CAAC;AAzBW,QAAA,gBAAgB,oBAyB3B"}
|