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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAMkB;AAClB,iDAA+E;AAC/E,6CAA+B;AAC/B,uDAAyC;AACzC,qCAA0E;AAC1E,qCAA2C;AAC3C,sCAA0D;AAC1D,uDAA+D;AAC/D,mCAAwD;AACxD,6DAA+C;AAE/C,0DAAwD;AACxD,MAAM,MAAM,GAAG,IAAA,sBAAa,EAAC,GAAG,CAAC,CAAC;AAO3B,MAAM,0BAA0B,GAAG,CACzC,YAAoB,EACpB,eAAmC,EAC1B,EAAE;IACX,MAAM,OAAO,GAAG,wBAAQ,CAAC,eAAe,CAAC,CAAC;IAC1C,OAAO,OAAO,CAAC,OAAO,CAAC,gBAAgB,CACtC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,EAChC,OAAO,CACP,CAAC;AACH,CAAC,CAAC;AATW,QAAA,0BAA0B,8BASrC;AAOK,MAAM,SAAS,GAAG,CAAC,GAAW,EAAU,EAAE;IAChD,MAAM,MAAM,GAAG,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/dist/utils/wallet.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.getTxFee = exports.getStorageKeyValues = exports.getWalletDataStorageKey = exports.generateWalletId = exports.getSeedHash = exports.getSeed = exports.decodeOpReturnMessage = exports.getDataFallback = exports.shuffleArray = exports.reduceValue = exports.availableNetworks = exports.isValidBech32mEncodedString = exports.getHighestUsedIndexFromTxHashes = exports.formatKeyDerivationPath = exports.objectKeys = exports.getKeyValue = exports.getDefaultWalletDataKeys = exports.getDefaultWalletData = void 0;
|
|
29
|
+
exports.filterAddressesObjForSingleIndex = exports.filterAddressesObjForStartingIndex = exports.filterAddressesObjForGapLimit = exports.filterAddressesForGapLimit = exports.getTxFee = exports.getStorageKeyValues = exports.getWalletDataStorageKey = exports.generateWalletId = exports.getSeedHash = exports.getSeed = exports.decodeOpReturnMessage = exports.getDataFallback = exports.shuffleArray = exports.reduceValue = exports.availableNetworks = exports.isValidBech32mEncodedString = exports.getHighestUsedIndexFromTxHashes = exports.formatKeyDerivationPath = exports.objectKeys = exports.getKeyValue = exports.getDefaultWalletDataKeys = exports.getDefaultWalletData = void 0;
|
|
30
30
|
const shapes_1 = require("../shapes");
|
|
31
31
|
const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
|
|
32
32
|
const types_1 = require("../types");
|
|
@@ -36,6 +36,7 @@ const bech32_1 = require("bech32");
|
|
|
36
36
|
const bip39 = __importStar(require("bip39"));
|
|
37
37
|
const bitcoin = __importStar(require("bitcoinjs-lib"));
|
|
38
38
|
const constants_1 = require("../wallet/constants");
|
|
39
|
+
const helpers_1 = require("./helpers");
|
|
39
40
|
const getDefaultWalletData = () => {
|
|
40
41
|
return (0, lodash_clonedeep_1.default)(shapes_1.defaultWalletData);
|
|
41
42
|
};
|
|
@@ -224,4 +225,50 @@ const getStorageKeyValues = (storageKey) => {
|
|
|
224
225
|
exports.getStorageKeyValues = getStorageKeyValues;
|
|
225
226
|
const getTxFee = ({ satsPerByte, transactionByteCount }) => transactionByteCount * satsPerByte;
|
|
226
227
|
exports.getTxFee = getTxFee;
|
|
228
|
+
const filterAddressesForGapLimit = ({ addresses, index, gapLimitOptions }) => {
|
|
229
|
+
const { lookBehind, lookAhead } = gapLimitOptions;
|
|
230
|
+
return addresses.filter((a) => {
|
|
231
|
+
if (a.index >= index) {
|
|
232
|
+
return (0, helpers_1.getAddressIndexDiff)(index, a.index) <= lookAhead;
|
|
233
|
+
}
|
|
234
|
+
return (0, helpers_1.getAddressIndexDiff)(index, a.index) <= lookBehind;
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
exports.filterAddressesForGapLimit = filterAddressesForGapLimit;
|
|
238
|
+
const filterAddressesObjForGapLimit = ({ addresses, index, gapLimitOptions }) => {
|
|
239
|
+
const { lookBehind, lookAhead } = gapLimitOptions;
|
|
240
|
+
const response = {};
|
|
241
|
+
Object.values(addresses).map((a) => {
|
|
242
|
+
if (a.index >= index) {
|
|
243
|
+
if ((0, helpers_1.getAddressIndexDiff)(a.index, index) <= lookAhead) {
|
|
244
|
+
response[a.scriptHash] = a;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
if ((0, helpers_1.getAddressIndexDiff)(a.index, index) <= lookBehind) {
|
|
249
|
+
response[a.scriptHash] = a;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
return response;
|
|
254
|
+
};
|
|
255
|
+
exports.filterAddressesObjForGapLimit = filterAddressesObjForGapLimit;
|
|
256
|
+
const filterAddressesObjForStartingIndex = ({ addresses, index }) => {
|
|
257
|
+
const response = {};
|
|
258
|
+
Object.values(addresses).map((a) => {
|
|
259
|
+
if (a.index >= index)
|
|
260
|
+
response[a.scriptHash] = a;
|
|
261
|
+
});
|
|
262
|
+
return response;
|
|
263
|
+
};
|
|
264
|
+
exports.filterAddressesObjForStartingIndex = filterAddressesObjForStartingIndex;
|
|
265
|
+
const filterAddressesObjForSingleIndex = ({ addresses, addressIndex }) => {
|
|
266
|
+
const response = {};
|
|
267
|
+
Object.values(addresses).map((a) => {
|
|
268
|
+
if (a.index === addressIndex)
|
|
269
|
+
response[a.scriptHash] = a;
|
|
270
|
+
});
|
|
271
|
+
return response;
|
|
272
|
+
};
|
|
273
|
+
exports.filterAddressesObjForSingleIndex = filterAddressesObjForSingleIndex;
|
|
227
274
|
//# sourceMappingURL=wallet.js.map
|
package/dist/utils/wallet.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/utils/wallet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAA8C;AAC9C,wEAAyC;AACzC,
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/utils/wallet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAA8C;AAC9C,wEAAyC;AACzC,oCAckB;AAClB,qCAA2C;AAC3C,uDAG2B;AAC3B,mCAAiC;AACjC,6CAA+B;AAC/B,uDAAyC;AACzC,mDAG6B;AAC7B,uCAAgD;AAMzC,MAAM,oBAAoB,GAAG,GAAgB,EAAE;IACrD,OAAO,IAAA,0BAAS,EAAC,0BAAiB,CAAC,CAAC;AACrC,CAAC,CAAC;AAFW,QAAA,oBAAoB,wBAE/B;AAMK,MAAM,wBAAwB,GAAG,GAA0B,EAAE;IACnE,OAAO,MAAM,CAAC,IAAI,CAAC,IAAA,4BAAoB,GAAE,CAA0B,CAAC;AACrE,CAAC,CAAC;AAFW,QAAA,wBAAwB,4BAEnC;AAOK,MAAM,WAAW,GAAG,CAAC,GAAW,EAAU,EAAE;IAClD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,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AE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AACjB,CAAC,CAAC;AAZW,QAAA,gCAAgC,oCAY3C"}
|
package/dist/wallet/constants.js
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BLOCKTANK_HOST = exports.TRANSACTION_DEFAULTS = exports.SPENDING_LIMIT_RATIO = exports.
|
|
4
|
-
const types_1 = require("../types");
|
|
3
|
+
exports.BLOCKTANK_HOST = exports.TRANSACTION_DEFAULTS = exports.SPENDING_LIMIT_RATIO = exports.GAP_LIMIT = exports.GENERATE_ADDRESS_AMOUNT = exports.WALLET_ID_PREFIX = exports.BITKIT_WALLET_SEED_HASH_PREFIX = void 0;
|
|
5
4
|
exports.BITKIT_WALLET_SEED_HASH_PREFIX = Buffer.from('@Bitkit/wallet-uuid');
|
|
6
5
|
exports.WALLET_ID_PREFIX = Buffer.from('@Beignet/wallet-id');
|
|
7
6
|
exports.GENERATE_ADDRESS_AMOUNT = 5;
|
|
8
7
|
exports.GAP_LIMIT = 20;
|
|
9
|
-
exports.CHUNK_LIMIT = {
|
|
10
|
-
[types_1.EAvailableNetworks.bitcoin]: 10,
|
|
11
|
-
[types_1.EAvailableNetworks.bitcoinTestnet]: 15,
|
|
12
|
-
[types_1.EAvailableNetworks.bitcoinRegtest]: 4
|
|
13
|
-
};
|
|
14
8
|
exports.SPENDING_LIMIT_RATIO = 0.8;
|
|
15
9
|
exports.TRANSACTION_DEFAULTS = {
|
|
16
10
|
recommendedBaseFee: 256,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/wallet/constants.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/wallet/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,8BAA8B,GAAG,MAAM,CAAC,IAAI,CACxD,qBAAqB,CACrB,CAAC;AAEW,QAAA,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;AAGrD,QAAA,uBAAuB,GAAG,CAAC,CAAC;AAG5B,QAAA,SAAS,GAAG,EAAE,CAAC;AAGf,QAAA,oBAAoB,GAAG,GAAG,CAAC;AAE3B,QAAA,oBAAoB,GAAG;IACnC,kBAAkB,EAAE,GAAG;IACvB,SAAS,EAAE,GAAG;CACd,CAAC;AAEW,QAAA,cAAc,GAAG,+BAA+B,CAAC"}
|
package/dist/wallet/index.js
CHANGED
|
@@ -42,7 +42,10 @@ const conversion_1 = require("../utils/conversion");
|
|
|
42
42
|
const bip39 = __importStar(require("bip39"));
|
|
43
43
|
const bip32 = (0, bip32_1.default)(ecc);
|
|
44
44
|
class Wallet {
|
|
45
|
-
constructor({ mnemonic, passphrase, name, network = types_1.EAvailableNetworks.mainnet, addressType = types_1.EAddressType.p2wpkh, storage, electrumOptions, onMessage = () => null, customGetAddress, customGetScriptHash, rbf = false, selectedFeeId = types_1.EFeeId.normal, disableMessages = false, disableMessagesOnCreate = false, addressTypesToMonitor = Object.values(types_1.EAddressType)
|
|
45
|
+
constructor({ mnemonic, passphrase, name, network = types_1.EAvailableNetworks.mainnet, addressType = types_1.EAddressType.p2wpkh, storage, electrumOptions = {}, onMessage = () => null, customGetAddress, customGetScriptHash, rbf = false, selectedFeeId = types_1.EFeeId.normal, disableMessages = false, disableMessagesOnCreate = false, addressTypesToMonitor = Object.values(types_1.EAddressType), gapLimitOptions = {
|
|
46
|
+
lookBehind: constants_1.GAP_LIMIT,
|
|
47
|
+
lookAhead: constants_1.GAP_LIMIT
|
|
48
|
+
} }) {
|
|
46
49
|
var _a;
|
|
47
50
|
this._pendingRefreshPromises = [];
|
|
48
51
|
this.savingOperations = {};
|
|
@@ -134,13 +137,7 @@ class Wallet {
|
|
|
134
137
|
onMessage(key, data);
|
|
135
138
|
};
|
|
136
139
|
this.electrumOptions = electrumOptions;
|
|
137
|
-
this.electrum = new electrum_1.Electrum({
|
|
138
|
-
wallet: this,
|
|
139
|
-
network: this.network,
|
|
140
|
-
servers: electrumOptions === null || electrumOptions === void 0 ? void 0 : electrumOptions.servers,
|
|
141
|
-
tls: electrumOptions === null || electrumOptions === void 0 ? void 0 : electrumOptions.tls,
|
|
142
|
-
net: electrumOptions === null || electrumOptions === void 0 ? void 0 : electrumOptions.net
|
|
143
|
-
});
|
|
140
|
+
this.electrum = new electrum_1.Electrum(Object.assign({ wallet: this, network: this.network }, electrumOptions));
|
|
144
141
|
this.rbf = rbf;
|
|
145
142
|
this.selectedFeeId = selectedFeeId;
|
|
146
143
|
this.isRefreshing = false;
|
|
@@ -150,6 +147,14 @@ class Wallet {
|
|
|
150
147
|
this.addressTypesToMonitor.push(this.addressType);
|
|
151
148
|
}
|
|
152
149
|
this.addressTypesToMonitor = [...new Set(this.addressTypesToMonitor)];
|
|
150
|
+
this.gapLimitOptions = {
|
|
151
|
+
lookBehind: (0, utils_1.isPositive)(gapLimitOptions.lookBehind)
|
|
152
|
+
? gapLimitOptions.lookBehind
|
|
153
|
+
: 1,
|
|
154
|
+
lookAhead: (0, utils_1.isPositive)(gapLimitOptions.lookAhead)
|
|
155
|
+
? gapLimitOptions.lookAhead
|
|
156
|
+
: 1
|
|
157
|
+
};
|
|
153
158
|
}
|
|
154
159
|
get data() {
|
|
155
160
|
return this._data;
|
|
@@ -219,7 +224,9 @@ class Wallet {
|
|
|
219
224
|
if (r1.isErr()) {
|
|
220
225
|
return this._handleRefreshError(r1.error.message);
|
|
221
226
|
}
|
|
222
|
-
const r2 = await this.getUtxos({
|
|
227
|
+
const r2 = await this.getUtxos({
|
|
228
|
+
scanningStrategy: scanAllAddresses ? types_1.EScanningStrategy.all : undefined
|
|
229
|
+
});
|
|
223
230
|
if (r2.isErr()) {
|
|
224
231
|
return this._handleRefreshError(r2.error.message);
|
|
225
232
|
}
|
|
@@ -597,6 +604,7 @@ class Wallet {
|
|
|
597
604
|
return (0, utils_1.err)('Failed Electrum connection check.');
|
|
598
605
|
}
|
|
599
606
|
async getNextAvailableAddress(addressType) {
|
|
607
|
+
var _a, _b;
|
|
600
608
|
const checkRes = await this.checkElectrumConnection();
|
|
601
609
|
if (checkRes.isErr())
|
|
602
610
|
return (0, utils_1.err)(checkRes.error.message);
|
|
@@ -614,70 +622,72 @@ class Wallet {
|
|
|
614
622
|
let lastUsedAddressIndex = currentWallet.lastUsedAddressIndex[addressType];
|
|
615
623
|
let changeAddressIndex = currentWallet.changeAddressIndex[addressType];
|
|
616
624
|
let lastUsedChangeAddressIndex = currentWallet.lastUsedChangeAddressIndex[addressType];
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
625
|
+
const startingAddressIndex = (_a = addressIndex === null || addressIndex === void 0 ? void 0 : addressIndex.index) !== null && _a !== void 0 ? _a : 0;
|
|
626
|
+
const startingChangeAddressIndex = (_b = changeAddressIndex === null || changeAddressIndex === void 0 ? void 0 : changeAddressIndex.index) !== null && _b !== void 0 ? _b : 0;
|
|
627
|
+
const addressIndexDiff = (0, utils_1.getAddressIndexDiff)(startingAddressIndex, lastUsedAddressIndex.index);
|
|
628
|
+
const addressesToGenerate = this.gapLimitOptions.lookAhead - addressIndexDiff;
|
|
629
|
+
let shouldSaveAddresses = false;
|
|
630
|
+
let shouldSaveChangeAddresses = false;
|
|
631
|
+
if (addressesToGenerate > 0) {
|
|
632
|
+
const generatedAddresses = await this.addAddresses({
|
|
633
|
+
addressAmount: addressesToGenerate,
|
|
620
634
|
addressIndex: 0,
|
|
621
635
|
changeAddressAmount: 0,
|
|
622
636
|
keyDerivationPath,
|
|
623
|
-
addressType
|
|
637
|
+
addressType,
|
|
638
|
+
saveAddresses: false
|
|
624
639
|
});
|
|
625
640
|
if (generatedAddresses.isErr()) {
|
|
626
641
|
return (0, utils_1.err)(generatedAddresses.error);
|
|
627
642
|
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
643
|
+
shouldSaveAddresses = true;
|
|
644
|
+
if (addressIndex.index < 0) {
|
|
645
|
+
const addresses = generatedAddresses.value.addresses;
|
|
646
|
+
const sorted = Object.values(addresses).sort((a, b) => a.index - b.index);
|
|
647
|
+
if (sorted.length >= 1 && sorted[0].index >= 0)
|
|
648
|
+
addressIndex = sorted[0];
|
|
649
|
+
}
|
|
631
650
|
}
|
|
632
|
-
|
|
633
|
-
|
|
651
|
+
const changeAddressIndexDiff = (0, utils_1.getAddressIndexDiff)(startingChangeAddressIndex, lastUsedChangeAddressIndex.index);
|
|
652
|
+
const changeAddressesToGenerate = this.gapLimitOptions.lookAhead - changeAddressIndexDiff;
|
|
653
|
+
if (changeAddressesToGenerate > 0) {
|
|
654
|
+
const generatedAddresses = await this.addAddresses({
|
|
634
655
|
addressAmount: 0,
|
|
635
|
-
changeAddressAmount:
|
|
656
|
+
changeAddressAmount: changeAddressesToGenerate,
|
|
636
657
|
changeAddressIndex: 0,
|
|
637
658
|
keyDerivationPath,
|
|
638
|
-
addressType
|
|
659
|
+
addressType,
|
|
660
|
+
saveAddresses: false
|
|
639
661
|
});
|
|
640
662
|
if (generatedAddresses.isErr()) {
|
|
641
663
|
return (0, utils_1.err)(generatedAddresses.error);
|
|
642
664
|
}
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
const addressCount = Object.values(addresses).length;
|
|
650
|
-
const changeAddressCount = Object.values(changeAddresses).length;
|
|
651
|
-
if (addressCount < constants_1.GENERATE_ADDRESS_AMOUNT ||
|
|
652
|
-
addressIndex.index === addressCount) {
|
|
653
|
-
const newAddresses = await this.addAddresses({
|
|
654
|
-
addressAmount: constants_1.GENERATE_ADDRESS_AMOUNT,
|
|
655
|
-
changeAddressAmount: 0,
|
|
656
|
-
addressIndex: addressIndex.index,
|
|
657
|
-
changeAddressIndex: 0,
|
|
658
|
-
keyDerivationPath,
|
|
659
|
-
addressType,
|
|
660
|
-
saveAddresses: false
|
|
661
|
-
});
|
|
662
|
-
if (newAddresses.isOk()) {
|
|
663
|
-
addresses = newAddresses.value.addresses;
|
|
665
|
+
shouldSaveChangeAddresses = true;
|
|
666
|
+
if (changeAddressIndex.index < 0) {
|
|
667
|
+
const changeAddresses = generatedAddresses.value.changeAddresses;
|
|
668
|
+
const sorted = Object.values(changeAddresses).sort((a, b) => a.index - b.index);
|
|
669
|
+
if (sorted.length >= 1 && sorted[0].index >= 0)
|
|
670
|
+
changeAddressIndex = sorted[0];
|
|
664
671
|
}
|
|
665
672
|
}
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
changeAddressIndex: changeAddressIndex.index,
|
|
673
|
-
keyDerivationPath,
|
|
674
|
-
addressType,
|
|
675
|
-
saveAddresses: false
|
|
676
|
-
});
|
|
677
|
-
if (newChangeAddresses.isOk()) {
|
|
678
|
-
changeAddresses = newChangeAddresses.value.changeAddresses;
|
|
679
|
-
}
|
|
673
|
+
const promises = [];
|
|
674
|
+
if (shouldSaveAddresses) {
|
|
675
|
+
promises.push(this.saveWalletData('addresses', this._data.addresses));
|
|
676
|
+
}
|
|
677
|
+
if (shouldSaveChangeAddresses) {
|
|
678
|
+
promises.push(this.saveWalletData('changeAddresses', this._data.changeAddresses));
|
|
680
679
|
}
|
|
680
|
+
await Promise.all(promises);
|
|
681
|
+
let addresses = (0, utils_1.filterAddressesObjForGapLimit)({
|
|
682
|
+
addresses: this._data.addresses[addressType],
|
|
683
|
+
index: addressIndex.index,
|
|
684
|
+
gapLimitOptions: this.gapLimitOptions
|
|
685
|
+
});
|
|
686
|
+
let changeAddresses = (0, utils_1.filterAddressesObjForGapLimit)({
|
|
687
|
+
addresses: this._data.changeAddresses[addressType],
|
|
688
|
+
index: changeAddressIndex.index,
|
|
689
|
+
gapLimitOptions: this.gapLimitOptions
|
|
690
|
+
});
|
|
681
691
|
let allAddresses = Object.values(addresses).filter(({ index }) => index >= addressIndex.index);
|
|
682
692
|
let addressesToScan = allAddresses;
|
|
683
693
|
let allChangeAddresses = Object.values(changeAddresses).filter(({ index }) => index >= changeAddressIndex.index);
|
|
@@ -709,19 +719,22 @@ class Wallet {
|
|
|
709
719
|
txHashes,
|
|
710
720
|
addresses,
|
|
711
721
|
changeAddresses,
|
|
712
|
-
addressIndex,
|
|
713
|
-
changeAddressIndex
|
|
722
|
+
addressIndex: lastUsedAddressIndex,
|
|
723
|
+
changeAddressIndex: lastUsedChangeAddressIndex
|
|
714
724
|
});
|
|
715
725
|
if (highestUsedIndex.isErr()) {
|
|
716
726
|
console.log(highestUsedIndex.error.message);
|
|
717
727
|
return lastKnownIndexes;
|
|
718
728
|
}
|
|
719
|
-
addressIndex = highestUsedIndex.value.addressIndex;
|
|
720
|
-
changeAddressIndex = highestUsedIndex.value.changeAddressIndex;
|
|
721
729
|
if (highestUsedIndex.value.foundAddressIndex) {
|
|
730
|
+
lastUsedAddressIndex = highestUsedIndex.value.addressIndex;
|
|
731
|
+
addressIndex = highestUsedIndex.value.addressIndex;
|
|
722
732
|
addressHasBeenUsed = true;
|
|
723
733
|
}
|
|
724
734
|
if (highestUsedIndex.value.foundChangeAddressIndex) {
|
|
735
|
+
lastUsedChangeAddressIndex =
|
|
736
|
+
highestUsedIndex.value.changeAddressIndex;
|
|
737
|
+
changeAddressIndex = highestUsedIndex.value.changeAddressIndex;
|
|
725
738
|
changeAddressHasBeenUsed = true;
|
|
726
739
|
}
|
|
727
740
|
const highestStoredIndex = this.getHighestStoredAddressIndex({
|
|
@@ -733,11 +746,10 @@ class Wallet {
|
|
|
733
746
|
}
|
|
734
747
|
const { addressIndex: highestUsedAddressIndex, changeAddressIndex: highestUsedChangeAddressIndex } = highestUsedIndex.value;
|
|
735
748
|
const { addressIndex: highestStoredAddressIndex, changeAddressIndex: highestStoredChangeAddressIndex } = highestStoredIndex.value;
|
|
736
|
-
if (highestUsedAddressIndex.index
|
|
749
|
+
if ((0, utils_1.getAddressIndexDiff)(highestUsedAddressIndex.index, highestStoredAddressIndex.index) >= this.gapLimitOptions.lookAhead) {
|
|
737
750
|
foundLastUsedAddress = true;
|
|
738
751
|
}
|
|
739
|
-
if (highestUsedChangeAddressIndex.index
|
|
740
|
-
highestStoredChangeAddressIndex.index) {
|
|
752
|
+
if ((0, utils_1.getAddressIndexDiff)(highestUsedChangeAddressIndex.index, highestStoredChangeAddressIndex.index) >= this.gapLimitOptions.lookAhead) {
|
|
741
753
|
foundLastUsedChangeAddress = true;
|
|
742
754
|
}
|
|
743
755
|
if (foundLastUsedAddress && foundLastUsedChangeAddress) {
|
|
@@ -764,6 +776,10 @@ class Wallet {
|
|
|
764
776
|
if (!nextAvailableAddress || !nextAvailableChangeAddress) {
|
|
765
777
|
return lastKnownIndexes;
|
|
766
778
|
}
|
|
779
|
+
await Promise.all([
|
|
780
|
+
this.saveWalletData('addresses', this._data.addresses),
|
|
781
|
+
this.saveWalletData('changeAddresses', this._data.changeAddresses)
|
|
782
|
+
]);
|
|
767
783
|
return (0, utils_1.ok)({
|
|
768
784
|
addressIndex: nextAvailableAddress,
|
|
769
785
|
lastUsedAddressIndex,
|
|
@@ -772,10 +788,12 @@ class Wallet {
|
|
|
772
788
|
});
|
|
773
789
|
}
|
|
774
790
|
if (!foundLastUsedAddress) {
|
|
791
|
+
const addressAmount = this.gapLimitOptions.lookAhead -
|
|
792
|
+
(0, utils_1.getAddressIndexDiff)(highestUsedAddressIndex.index, highestStoredAddressIndex.index);
|
|
775
793
|
const newAddresses = await this.addAddresses({
|
|
776
|
-
addressAmount
|
|
794
|
+
addressAmount,
|
|
777
795
|
changeAddressAmount: 0,
|
|
778
|
-
addressIndex: highestStoredIndex.value.addressIndex.index,
|
|
796
|
+
addressIndex: highestStoredIndex.value.addressIndex.index + 1,
|
|
779
797
|
changeAddressIndex: 0,
|
|
780
798
|
keyDerivationPath,
|
|
781
799
|
addressType,
|
|
@@ -786,11 +804,13 @@ class Wallet {
|
|
|
786
804
|
}
|
|
787
805
|
}
|
|
788
806
|
if (!foundLastUsedChangeAddress) {
|
|
807
|
+
const changeAddressAmount = this.gapLimitOptions.lookAhead -
|
|
808
|
+
(0, utils_1.getAddressIndexDiff)(highestUsedChangeAddressIndex.index, highestStoredChangeAddressIndex.index);
|
|
789
809
|
const newChangeAddresses = await this.addAddresses({
|
|
790
810
|
addressAmount: 0,
|
|
791
|
-
changeAddressAmount
|
|
811
|
+
changeAddressAmount,
|
|
792
812
|
addressIndex: 0,
|
|
793
|
-
changeAddressIndex: highestStoredIndex.value.changeAddressIndex.index,
|
|
813
|
+
changeAddressIndex: highestStoredIndex.value.changeAddressIndex.index + 1,
|
|
794
814
|
keyDerivationPath,
|
|
795
815
|
addressType,
|
|
796
816
|
saveAddresses: false
|
|
@@ -807,6 +827,11 @@ class Wallet {
|
|
|
807
827
|
];
|
|
808
828
|
allAddresses = [...allAddresses, ...addressesToScan];
|
|
809
829
|
allChangeAddresses = [...allChangeAddresses, ...changeAddressesToScan];
|
|
830
|
+
await this.getUtxos({
|
|
831
|
+
addressIndex: addressIndex.index,
|
|
832
|
+
changeAddressIndex: changeAddressIndex.index,
|
|
833
|
+
addressTypesToCheck: [addressType]
|
|
834
|
+
});
|
|
810
835
|
}
|
|
811
836
|
await Promise.all([
|
|
812
837
|
this.saveWalletData('addresses', this._data.addresses),
|
|
@@ -942,8 +967,8 @@ class Wallet {
|
|
|
942
967
|
}
|
|
943
968
|
const lastUsedIndex = lastUsedAddressIndex.index > 0 ? lastUsedAddressIndex.index : 0;
|
|
944
969
|
const currentGap = Math.abs(addressIndex.index - lastUsedIndex);
|
|
945
|
-
if (currentGap >
|
|
946
|
-
const excessAmount = currentGap -
|
|
970
|
+
if (currentGap > this.gapLimitOptions.lookBehind) {
|
|
971
|
+
const excessAmount = currentGap - this.gapLimitOptions.lookBehind;
|
|
947
972
|
const newIndex = addressIndex.index - excessAmount;
|
|
948
973
|
const _addressIndex = await this.generateAddresses({
|
|
949
974
|
addressType: addressTypeKey,
|
|
@@ -960,8 +985,8 @@ class Wallet {
|
|
|
960
985
|
? lastUsedChangeAddressIndex.index
|
|
961
986
|
: 0;
|
|
962
987
|
const currentChangeAddressGap = Math.abs(changeAddressIndex.index - lastUsedChangeIndex);
|
|
963
|
-
if (currentChangeAddressGap >
|
|
964
|
-
const excessAmount = currentGap -
|
|
988
|
+
if (currentChangeAddressGap > this.gapLimitOptions.lookBehind) {
|
|
989
|
+
const excessAmount = currentGap - this.gapLimitOptions.lookBehind;
|
|
965
990
|
const newIndex = addressIndex.index - excessAmount;
|
|
966
991
|
const _changeAddressIndex = await this.generateAddresses({
|
|
967
992
|
addressType: addressTypeKey,
|
|
@@ -1023,7 +1048,7 @@ class Wallet {
|
|
|
1023
1048
|
return (0, utils_1.err)(getGapLimitResponse.error.message);
|
|
1024
1049
|
}
|
|
1025
1050
|
const { addressDelta } = getGapLimitResponse.value;
|
|
1026
|
-
if (addressDelta >=
|
|
1051
|
+
if (addressDelta >= this.gapLimitOptions.lookBehind) {
|
|
1027
1052
|
const addressIndex = currentWallet.addressIndex;
|
|
1028
1053
|
const receiveAddress = addressIndex[addressType];
|
|
1029
1054
|
return (0, utils_1.ok)(receiveAddress);
|
|
@@ -1088,13 +1113,16 @@ class Wallet {
|
|
|
1088
1113
|
return (0, utils_1.err)(e);
|
|
1089
1114
|
}
|
|
1090
1115
|
}
|
|
1091
|
-
async getUtxos({
|
|
1116
|
+
async getUtxos({ scanningStrategy = types_1.EScanningStrategy.gapLimit, addressIndex, changeAddressIndex, addressTypesToCheck }) {
|
|
1092
1117
|
var _a, _b, _c, _d;
|
|
1093
1118
|
const checkRes = await this.checkElectrumConnection();
|
|
1094
1119
|
if (checkRes.isErr())
|
|
1095
1120
|
return (0, utils_1.err)(checkRes.error.message);
|
|
1096
1121
|
const getUtxosRes = await this.electrum.getUtxos({
|
|
1097
|
-
|
|
1122
|
+
scanningStrategy,
|
|
1123
|
+
addressIndex,
|
|
1124
|
+
changeAddressIndex,
|
|
1125
|
+
addressTypesToCheck
|
|
1098
1126
|
});
|
|
1099
1127
|
if (getUtxosRes.isErr()) {
|
|
1100
1128
|
return (0, utils_1.err)(getUtxosRes.error.message);
|
|
@@ -1142,6 +1170,7 @@ class Wallet {
|
|
|
1142
1170
|
}
|
|
1143
1171
|
}
|
|
1144
1172
|
async updateTransactions({ scanAllAddresses = false, replaceStoredTransactions = false }) {
|
|
1173
|
+
var _a;
|
|
1145
1174
|
await this.checkUnconfirmedTransactions();
|
|
1146
1175
|
const history = await this.electrum.getAddressHistory({
|
|
1147
1176
|
scanAllAddresses: scanAllAddresses || replaceStoredTransactions
|
|
@@ -1202,15 +1231,51 @@ class Wallet {
|
|
|
1202
1231
|
}
|
|
1203
1232
|
this._data.transactions = Object.assign(Object.assign({}, this._data.transactions), formattedTransactions);
|
|
1204
1233
|
await this.saveWalletData('transactions', this._data.transactions);
|
|
1234
|
+
confirmedTxs.forEach((tx) => {
|
|
1235
|
+
this.sendMessage('transactionConfirmed', tx);
|
|
1236
|
+
});
|
|
1205
1237
|
sentTxs.forEach((tx) => {
|
|
1206
1238
|
this.sendMessage('transactionSent', tx);
|
|
1207
1239
|
});
|
|
1208
|
-
|
|
1240
|
+
const addresses = this.data.addresses;
|
|
1241
|
+
const utxoScriptHashes = new Set(this.data.utxos.map((utxo) => utxo.scriptHash));
|
|
1242
|
+
const outsideGapLimitAddresses = {};
|
|
1243
|
+
for (const tx of receivedTxs) {
|
|
1209
1244
|
this.sendMessage('transactionReceived', tx);
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1245
|
+
if (utxoScriptHashes.has(tx.transaction.scriptHash))
|
|
1246
|
+
continue;
|
|
1247
|
+
for (const addressType in addresses) {
|
|
1248
|
+
const addressData = addresses[addressType];
|
|
1249
|
+
if (tx.transaction.scriptHash in addressData) {
|
|
1250
|
+
const address = addressData[tx.transaction.scriptHash];
|
|
1251
|
+
const index = address.index;
|
|
1252
|
+
const currentIndex = this.data.addressIndex[addressType].index;
|
|
1253
|
+
const diff = (0, utils_1.getAddressIndexDiff)(index, currentIndex);
|
|
1254
|
+
if (diff > this.gapLimitOptions.lookBehind) {
|
|
1255
|
+
outsideGapLimitAddresses[addressType] = [
|
|
1256
|
+
...((_a = outsideGapLimitAddresses[addressType]) !== null && _a !== void 0 ? _a : []),
|
|
1257
|
+
index
|
|
1258
|
+
];
|
|
1259
|
+
}
|
|
1260
|
+
break;
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
if (receivedTxs.length > 0) {
|
|
1265
|
+
for (const type of Object.keys(outsideGapLimitAddresses)) {
|
|
1266
|
+
const indexes = outsideGapLimitAddresses[type];
|
|
1267
|
+
if (indexes.length <= 0)
|
|
1268
|
+
continue;
|
|
1269
|
+
const lowestIndex = Math.min(...indexes);
|
|
1270
|
+
const addressType = type;
|
|
1271
|
+
await this.getUtxos({
|
|
1272
|
+
scanningStrategy: types_1.EScanningStrategy.startingIndex,
|
|
1273
|
+
addressIndex: lowestIndex - this.gapLimitOptions.lookBehind,
|
|
1274
|
+
changeAddressIndex: lowestIndex - this.gapLimitOptions.lookBehind,
|
|
1275
|
+
addressTypesToCheck: [addressType]
|
|
1276
|
+
});
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1214
1279
|
return (0, utils_1.ok)(notificationTxid);
|
|
1215
1280
|
}
|
|
1216
1281
|
async checkUnconfirmedTransactions() {
|
|
@@ -1386,8 +1451,9 @@ class Wallet {
|
|
|
1386
1451
|
try {
|
|
1387
1452
|
const unconfirmedTransactions = {};
|
|
1388
1453
|
Object.keys(transactions).forEach((key) => {
|
|
1454
|
+
var _a, _b;
|
|
1389
1455
|
const confirmations = this.blockHeightToConfirmations({
|
|
1390
|
-
blockHeight: transactions[key].height
|
|
1456
|
+
blockHeight: (_b = (_a = transactions[key]) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 0
|
|
1391
1457
|
});
|
|
1392
1458
|
if (confirmations < 6) {
|
|
1393
1459
|
unconfirmedTransactions[key] = transactions[key];
|
|
@@ -1406,7 +1472,7 @@ class Wallet {
|
|
|
1406
1472
|
}
|
|
1407
1473
|
}
|
|
1408
1474
|
blockHeightToConfirmations({ blockHeight, currentHeight }) {
|
|
1409
|
-
if (!blockHeight) {
|
|
1475
|
+
if (!blockHeight || blockHeight <= 0) {
|
|
1410
1476
|
return 0;
|
|
1411
1477
|
}
|
|
1412
1478
|
if (!currentHeight) {
|
|
@@ -1548,9 +1614,9 @@ class Wallet {
|
|
|
1548
1614
|
var _a, _b, _c;
|
|
1549
1615
|
try {
|
|
1550
1616
|
const inputData = {};
|
|
1551
|
-
const
|
|
1552
|
-
for (let i = 0; i < inputs.length; i +=
|
|
1553
|
-
const chunk = inputs.slice(i, i +
|
|
1617
|
+
const batchLimit = this.electrum.batchLimit;
|
|
1618
|
+
for (let i = 0; i < inputs.length; i += batchLimit) {
|
|
1619
|
+
const chunk = inputs.slice(i, i + batchLimit);
|
|
1554
1620
|
const getTransactionsResponse = await this.electrum.getTransactionsFromInputs({
|
|
1555
1621
|
txHashes: chunk
|
|
1556
1622
|
});
|
|
@@ -1792,9 +1858,11 @@ class Wallet {
|
|
|
1792
1858
|
}
|
|
1793
1859
|
if (!Object.keys(addresses).length) {
|
|
1794
1860
|
await this.addAddresses({
|
|
1795
|
-
addressAmount: indexToUpdate === 'addressIndex' ?
|
|
1861
|
+
addressAmount: indexToUpdate === 'addressIndex' ? this.gapLimitOptions.lookAhead : 0,
|
|
1796
1862
|
addressIndex: index,
|
|
1797
|
-
changeAddressAmount: indexToUpdate === 'changeAddressIndex'
|
|
1863
|
+
changeAddressAmount: indexToUpdate === 'changeAddressIndex'
|
|
1864
|
+
? this.gapLimitOptions.lookAhead
|
|
1865
|
+
: 0,
|
|
1798
1866
|
changeAddressIndex: index,
|
|
1799
1867
|
addressType,
|
|
1800
1868
|
saveAddresses: false
|
|
@@ -1887,6 +1955,7 @@ class Wallet {
|
|
|
1887
1955
|
}
|
|
1888
1956
|
path = allAddresses[scriptHash].path;
|
|
1889
1957
|
value = (0, conversion_1.btcToSats)(txVout.value);
|
|
1958
|
+
const publicKey = allAddresses[scriptHash].publicKey;
|
|
1890
1959
|
inputs.push({
|
|
1891
1960
|
tx_hash: input.txid,
|
|
1892
1961
|
index: input.vout,
|
|
@@ -1895,7 +1964,8 @@ class Wallet {
|
|
|
1895
1964
|
address,
|
|
1896
1965
|
scriptHash,
|
|
1897
1966
|
path,
|
|
1898
|
-
value
|
|
1967
|
+
value,
|
|
1968
|
+
publicKey
|
|
1899
1969
|
});
|
|
1900
1970
|
if (value) {
|
|
1901
1971
|
inputTotal = inputTotal + value;
|
|
@@ -2225,6 +2295,31 @@ class Wallet {
|
|
|
2225
2295
|
response.id = broadcastResponse.value;
|
|
2226
2296
|
return (0, utils_1.ok)(response);
|
|
2227
2297
|
}
|
|
2298
|
+
getAddressInfoFromScriptHash(scriptHash) {
|
|
2299
|
+
const addresses = this.data.addresses;
|
|
2300
|
+
let address;
|
|
2301
|
+
for (const addressType in addresses) {
|
|
2302
|
+
if (scriptHash in addresses[addressType]) {
|
|
2303
|
+
address = {
|
|
2304
|
+
address: addresses[addressType][scriptHash],
|
|
2305
|
+
addressType: addressType
|
|
2306
|
+
};
|
|
2307
|
+
break;
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
return address ? (0, utils_1.ok)(address) : (0, utils_1.err)('Address not found');
|
|
2311
|
+
}
|
|
2312
|
+
updateGapLimit(gapLimitOptions) {
|
|
2313
|
+
if (!gapLimitOptions) {
|
|
2314
|
+
return (0, utils_1.err)('No gap limit options provided.');
|
|
2315
|
+
}
|
|
2316
|
+
if (!(0, utils_1.isPositive)(gapLimitOptions.lookAhead) ||
|
|
2317
|
+
!(0, utils_1.isPositive)(gapLimitOptions.lookBehind)) {
|
|
2318
|
+
return (0, utils_1.err)('Both gap limit options must be positive.');
|
|
2319
|
+
}
|
|
2320
|
+
this.gapLimitOptions = gapLimitOptions;
|
|
2321
|
+
return (0, utils_1.ok)(this.gapLimitOptions);
|
|
2322
|
+
}
|
|
2228
2323
|
}
|
|
2229
2324
|
exports.Wallet = Wallet;
|
|
2230
2325
|
//# sourceMappingURL=index.js.map
|