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/src/utils/wallet.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
ITxHashes,
|
|
12
12
|
IWalletData,
|
|
13
13
|
ObjectKeys,
|
|
14
|
+
TGapLimitOptions,
|
|
14
15
|
TGetData,
|
|
15
16
|
TKeyDerivationPurpose
|
|
16
17
|
} from '../types';
|
|
@@ -26,6 +27,7 @@ import {
|
|
|
26
27
|
WALLET_ID_PREFIX,
|
|
27
28
|
BITKIT_WALLET_SEED_HASH_PREFIX
|
|
28
29
|
} from '../wallet/constants';
|
|
30
|
+
import { getAddressIndexDiff } from './helpers';
|
|
29
31
|
|
|
30
32
|
/**
|
|
31
33
|
* Returns the default wallet data object.
|
|
@@ -349,3 +351,74 @@ export const getTxFee = ({
|
|
|
349
351
|
satsPerByte: number;
|
|
350
352
|
transactionByteCount: number;
|
|
351
353
|
}): number => transactionByteCount * satsPerByte;
|
|
354
|
+
|
|
355
|
+
export const filterAddressesForGapLimit = ({
|
|
356
|
+
addresses,
|
|
357
|
+
index,
|
|
358
|
+
gapLimitOptions
|
|
359
|
+
}: {
|
|
360
|
+
addresses: IAddress[];
|
|
361
|
+
index: number;
|
|
362
|
+
gapLimitOptions: TGapLimitOptions;
|
|
363
|
+
}): IAddress[] => {
|
|
364
|
+
const { lookBehind, lookAhead } = gapLimitOptions;
|
|
365
|
+
return addresses.filter((a) => {
|
|
366
|
+
if (a.index >= index) {
|
|
367
|
+
return getAddressIndexDiff(index, a.index) <= lookAhead;
|
|
368
|
+
}
|
|
369
|
+
return getAddressIndexDiff(index, a.index) <= lookBehind;
|
|
370
|
+
});
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
export const filterAddressesObjForGapLimit = ({
|
|
374
|
+
addresses,
|
|
375
|
+
index,
|
|
376
|
+
gapLimitOptions
|
|
377
|
+
}: {
|
|
378
|
+
addresses: IAddresses;
|
|
379
|
+
index: number;
|
|
380
|
+
gapLimitOptions: TGapLimitOptions;
|
|
381
|
+
}): IAddresses => {
|
|
382
|
+
const { lookBehind, lookAhead } = gapLimitOptions;
|
|
383
|
+
const response: IAddresses = {};
|
|
384
|
+
Object.values(addresses).map((a) => {
|
|
385
|
+
if (a.index >= index) {
|
|
386
|
+
if (getAddressIndexDiff(a.index, index) <= lookAhead) {
|
|
387
|
+
response[a.scriptHash] = a;
|
|
388
|
+
}
|
|
389
|
+
} else {
|
|
390
|
+
if (getAddressIndexDiff(a.index, index) <= lookBehind) {
|
|
391
|
+
response[a.scriptHash] = a;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
return response;
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
export const filterAddressesObjForStartingIndex = ({
|
|
399
|
+
addresses,
|
|
400
|
+
index
|
|
401
|
+
}: {
|
|
402
|
+
addresses: IAddresses;
|
|
403
|
+
index: number;
|
|
404
|
+
}): IAddresses => {
|
|
405
|
+
const response: IAddresses = {};
|
|
406
|
+
Object.values(addresses).map((a) => {
|
|
407
|
+
if (a.index >= index) response[a.scriptHash] = a;
|
|
408
|
+
});
|
|
409
|
+
return response;
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
export const filterAddressesObjForSingleIndex = ({
|
|
413
|
+
addresses,
|
|
414
|
+
addressIndex
|
|
415
|
+
}: {
|
|
416
|
+
addresses: IAddresses;
|
|
417
|
+
addressIndex: number;
|
|
418
|
+
}): IAddresses => {
|
|
419
|
+
const response: IAddresses = {};
|
|
420
|
+
Object.values(addresses).map((a) => {
|
|
421
|
+
if (a.index === addressIndex) response[a.scriptHash] = a;
|
|
422
|
+
});
|
|
423
|
+
return response;
|
|
424
|
+
};
|
package/src/wallet/constants.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { EAvailableNetworks } from '../types';
|
|
2
|
-
|
|
3
1
|
export const BITKIT_WALLET_SEED_HASH_PREFIX = Buffer.from(
|
|
4
2
|
'@Bitkit/wallet-uuid'
|
|
5
3
|
);
|
|
@@ -12,12 +10,6 @@ export const GENERATE_ADDRESS_AMOUNT = 5;
|
|
|
12
10
|
// TODO: Add this as a settings for users to adjust when needed.
|
|
13
11
|
export const GAP_LIMIT = 20;
|
|
14
12
|
|
|
15
|
-
export const CHUNK_LIMIT = {
|
|
16
|
-
[EAvailableNetworks.bitcoin]: 10,
|
|
17
|
-
[EAvailableNetworks.bitcoinTestnet]: 15,
|
|
18
|
-
[EAvailableNetworks.bitcoinRegtest]: 4
|
|
19
|
-
};
|
|
20
|
-
|
|
21
13
|
//How much of the users funds we allow to be used for Lightning.
|
|
22
14
|
export const SPENDING_LIMIT_RATIO = 0.8;
|
|
23
15
|
|