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
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
- [boostedTransactions](IWalletData.md#boostedtransactions)
|
|
15
15
|
- [changeAddressIndex](IWalletData.md#changeaddressindex)
|
|
16
16
|
- [changeAddresses](IWalletData.md#changeaddresses)
|
|
17
|
-
- [exchangeRates](IWalletData.md#exchangerates)
|
|
18
17
|
- [feeEstimates](IWalletData.md#feeestimates)
|
|
19
18
|
- [header](IWalletData.md#header)
|
|
20
19
|
- [id](IWalletData.md#id)
|
|
@@ -34,7 +33,7 @@
|
|
|
34
33
|
|
|
35
34
|
#### Defined in
|
|
36
35
|
|
|
37
|
-
[types/wallet.ts:
|
|
36
|
+
[types/wallet.ts:158](https://github.com/synonymdev/beignet/blob/05d5011/src/types/wallet.ts#L158)
|
|
38
37
|
|
|
39
38
|
___
|
|
40
39
|
|
|
@@ -44,7 +43,7 @@ ___
|
|
|
44
43
|
|
|
45
44
|
#### Defined in
|
|
46
45
|
|
|
47
|
-
[types/wallet.ts:
|
|
46
|
+
[types/wallet.ts:154](https://github.com/synonymdev/beignet/blob/05d5011/src/types/wallet.ts#L154)
|
|
48
47
|
|
|
49
48
|
___
|
|
50
49
|
|
|
@@ -54,7 +53,7 @@ ___
|
|
|
54
53
|
|
|
55
54
|
#### Defined in
|
|
56
55
|
|
|
57
|
-
[types/wallet.ts:
|
|
56
|
+
[types/wallet.ts:156](https://github.com/synonymdev/beignet/blob/05d5011/src/types/wallet.ts#L156)
|
|
58
57
|
|
|
59
58
|
___
|
|
60
59
|
|
|
@@ -64,7 +63,7 @@ ___
|
|
|
64
63
|
|
|
65
64
|
#### Defined in
|
|
66
65
|
|
|
67
|
-
[types/wallet.ts:
|
|
66
|
+
[types/wallet.ts:168](https://github.com/synonymdev/beignet/blob/05d5011/src/types/wallet.ts#L168)
|
|
68
67
|
|
|
69
68
|
___
|
|
70
69
|
|
|
@@ -74,7 +73,7 @@ ___
|
|
|
74
73
|
|
|
75
74
|
#### Defined in
|
|
76
75
|
|
|
77
|
-
[types/wallet.ts:
|
|
76
|
+
[types/wallet.ts:163](https://github.com/synonymdev/beignet/blob/05d5011/src/types/wallet.ts#L163)
|
|
78
77
|
|
|
79
78
|
___
|
|
80
79
|
|
|
@@ -84,7 +83,7 @@ ___
|
|
|
84
83
|
|
|
85
84
|
#### Defined in
|
|
86
85
|
|
|
87
|
-
[types/wallet.ts:
|
|
86
|
+
[types/wallet.ts:166](https://github.com/synonymdev/beignet/blob/05d5011/src/types/wallet.ts#L166)
|
|
88
87
|
|
|
89
88
|
___
|
|
90
89
|
|
|
@@ -94,7 +93,7 @@ ___
|
|
|
94
93
|
|
|
95
94
|
#### Defined in
|
|
96
95
|
|
|
97
|
-
[types/wallet.ts:
|
|
96
|
+
[types/wallet.ts:159](https://github.com/synonymdev/beignet/blob/05d5011/src/types/wallet.ts#L159)
|
|
98
97
|
|
|
99
98
|
___
|
|
100
99
|
|
|
@@ -104,17 +103,7 @@ ___
|
|
|
104
103
|
|
|
105
104
|
#### Defined in
|
|
106
105
|
|
|
107
|
-
[types/wallet.ts:
|
|
108
|
-
|
|
109
|
-
___
|
|
110
|
-
|
|
111
|
-
### exchangeRates
|
|
112
|
-
|
|
113
|
-
• **exchangeRates**: [`IExchangeRates`](IExchangeRates.md)
|
|
114
|
-
|
|
115
|
-
#### Defined in
|
|
116
|
-
|
|
117
|
-
[types/wallet.ts:167](https://github.com/synonymdev/beignet/blob/583604f/src/types/wallet.ts#L167)
|
|
106
|
+
[types/wallet.ts:157](https://github.com/synonymdev/beignet/blob/05d5011/src/types/wallet.ts#L157)
|
|
118
107
|
|
|
119
108
|
___
|
|
120
109
|
|
|
@@ -124,7 +113,7 @@ ___
|
|
|
124
113
|
|
|
125
114
|
#### Defined in
|
|
126
115
|
|
|
127
|
-
[types/wallet.ts:
|
|
116
|
+
[types/wallet.ts:170](https://github.com/synonymdev/beignet/blob/05d5011/src/types/wallet.ts#L170)
|
|
128
117
|
|
|
129
118
|
___
|
|
130
119
|
|
|
@@ -134,7 +123,7 @@ ___
|
|
|
134
123
|
|
|
135
124
|
#### Defined in
|
|
136
125
|
|
|
137
|
-
[types/wallet.ts:
|
|
126
|
+
[types/wallet.ts:155](https://github.com/synonymdev/beignet/blob/05d5011/src/types/wallet.ts#L155)
|
|
138
127
|
|
|
139
128
|
___
|
|
140
129
|
|
|
@@ -144,7 +133,7 @@ ___
|
|
|
144
133
|
|
|
145
134
|
#### Defined in
|
|
146
135
|
|
|
147
|
-
[types/wallet.ts:
|
|
136
|
+
[types/wallet.ts:153](https://github.com/synonymdev/beignet/blob/05d5011/src/types/wallet.ts#L153)
|
|
148
137
|
|
|
149
138
|
___
|
|
150
139
|
|
|
@@ -154,7 +143,7 @@ ___
|
|
|
154
143
|
|
|
155
144
|
#### Defined in
|
|
156
145
|
|
|
157
|
-
[types/wallet.ts:
|
|
146
|
+
[types/wallet.ts:160](https://github.com/synonymdev/beignet/blob/05d5011/src/types/wallet.ts#L160)
|
|
158
147
|
|
|
159
148
|
___
|
|
160
149
|
|
|
@@ -164,7 +153,7 @@ ___
|
|
|
164
153
|
|
|
165
154
|
#### Defined in
|
|
166
155
|
|
|
167
|
-
[types/wallet.ts:
|
|
156
|
+
[types/wallet.ts:161](https://github.com/synonymdev/beignet/blob/05d5011/src/types/wallet.ts#L161)
|
|
168
157
|
|
|
169
158
|
___
|
|
170
159
|
|
|
@@ -174,7 +163,7 @@ ___
|
|
|
174
163
|
|
|
175
164
|
#### Defined in
|
|
176
165
|
|
|
177
|
-
[types/wallet.ts:
|
|
166
|
+
[types/wallet.ts:169](https://github.com/synonymdev/beignet/blob/05d5011/src/types/wallet.ts#L169)
|
|
178
167
|
|
|
179
168
|
___
|
|
180
169
|
|
|
@@ -184,7 +173,7 @@ ___
|
|
|
184
173
|
|
|
185
174
|
#### Defined in
|
|
186
175
|
|
|
187
|
-
[types/wallet.ts:
|
|
176
|
+
[types/wallet.ts:167](https://github.com/synonymdev/beignet/blob/05d5011/src/types/wallet.ts#L167)
|
|
188
177
|
|
|
189
178
|
___
|
|
190
179
|
|
|
@@ -194,7 +183,7 @@ ___
|
|
|
194
183
|
|
|
195
184
|
#### Defined in
|
|
196
185
|
|
|
197
|
-
[types/wallet.ts:
|
|
186
|
+
[types/wallet.ts:165](https://github.com/synonymdev/beignet/blob/05d5011/src/types/wallet.ts#L165)
|
|
198
187
|
|
|
199
188
|
___
|
|
200
189
|
|
|
@@ -204,7 +193,7 @@ ___
|
|
|
204
193
|
|
|
205
194
|
#### Defined in
|
|
206
195
|
|
|
207
|
-
[types/wallet.ts:
|
|
196
|
+
[types/wallet.ts:164](https://github.com/synonymdev/beignet/blob/05d5011/src/types/wallet.ts#L164)
|
|
208
197
|
|
|
209
198
|
___
|
|
210
199
|
|
|
@@ -214,4 +203,4 @@ ___
|
|
|
214
203
|
|
|
215
204
|
#### Defined in
|
|
216
205
|
|
|
217
|
-
[types/wallet.ts:
|
|
206
|
+
[types/wallet.ts:162](https://github.com/synonymdev/beignet/blob/05d5011/src/types/wallet.ts#L162)
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "beignet",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
4
4
|
"description": "A self-custodial, JS Bitcoin wallet management library.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "yarn build && env mocha --exit -r ts-node/register 'tests/**/*.ts'",
|
|
8
8
|
"test:wallet": "yarn build && env mocha --exit -r ts-node/register 'tests/wallet.test.ts'",
|
|
9
9
|
"test:electrum": "yarn build && env mocha --exit -r ts-node/register 'tests/electrum.test.ts'",
|
|
10
|
-
"test:derivation": "
|
|
11
|
-
"test:transaction": "
|
|
10
|
+
"test:derivation": "yarn build && env mocha --exit -r ts-node/register 'tests/derivation.test.ts'",
|
|
11
|
+
"test:transaction": "yarn build && env mocha --exit -r ts-node/register 'tests/transaction.test.ts'",
|
|
12
12
|
"test:storage": "yarn build && env mocha --exit -r ts-node/register 'tests/storage.test.ts'",
|
|
13
13
|
"example": "ts-node example",
|
|
14
14
|
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
|
package/src/electrum/index.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
+
EAddressType,
|
|
2
3
|
EAvailableNetworks,
|
|
4
|
+
EElectrumNetworks,
|
|
5
|
+
EScanningStrategy,
|
|
3
6
|
IAddress,
|
|
4
7
|
IAddresses,
|
|
5
|
-
TAddressTypeContent,
|
|
6
|
-
TConnectToElectrumRes,
|
|
7
8
|
IElectrumGetAddressBalanceRes,
|
|
8
9
|
IGetAddressHistoryResponse,
|
|
10
|
+
IGetAddressScriptHashBalances,
|
|
9
11
|
IGetAddressScriptHashesHistoryResponse,
|
|
10
12
|
IGetHeaderResponse,
|
|
11
13
|
IGetTransactions,
|
|
@@ -13,37 +15,39 @@ import {
|
|
|
13
15
|
IGetUtxosResponse,
|
|
14
16
|
IHeader,
|
|
15
17
|
INewBlock,
|
|
18
|
+
IPeerData,
|
|
16
19
|
ISubscribeToAddress,
|
|
17
20
|
ISubscribeToHeader,
|
|
18
21
|
ITransaction,
|
|
19
22
|
ITxHash,
|
|
20
23
|
IUtxo,
|
|
21
|
-
|
|
24
|
+
TAddressTypeContent,
|
|
25
|
+
TConnectToElectrumRes,
|
|
26
|
+
TGetAddressHistory,
|
|
27
|
+
TOnMessage,
|
|
22
28
|
TServer,
|
|
23
29
|
TSubscribedReceive,
|
|
24
30
|
TTxResponse,
|
|
25
31
|
TTxResult,
|
|
26
|
-
TUnspentAddressScriptHashData
|
|
27
|
-
IPeerData,
|
|
28
|
-
TGetAddressHistory,
|
|
29
|
-
TOnMessage,
|
|
30
|
-
IGetAddressScriptHashBalances
|
|
32
|
+
TUnspentAddressScriptHashData
|
|
31
33
|
} from '../types';
|
|
32
34
|
import * as electrum from 'rn-electrum-client/helpers';
|
|
33
35
|
import {
|
|
34
36
|
err,
|
|
37
|
+
filterAddressesForGapLimit,
|
|
38
|
+
filterAddressesObjForGapLimit,
|
|
39
|
+
filterAddressesObjForSingleIndex,
|
|
40
|
+
filterAddressesObjForStartingIndex,
|
|
35
41
|
getAddressFromScriptPubKey,
|
|
36
42
|
getElectrumNetwork,
|
|
43
|
+
getScriptHash,
|
|
37
44
|
ok,
|
|
38
45
|
Result,
|
|
39
46
|
sleep
|
|
40
47
|
} from '../utils';
|
|
41
48
|
import { Wallet } from '../wallet';
|
|
42
|
-
import {
|
|
43
|
-
import { getScriptHash } from '../utils';
|
|
44
|
-
import { POLLING_INTERVAL } from '../shapes';
|
|
49
|
+
import { onMessageKeys, POLLING_INTERVAL } from '../shapes';
|
|
45
50
|
import { Block } from 'bitcoinjs-lib';
|
|
46
|
-
import { onMessageKeys } from '../shapes';
|
|
47
51
|
import { Server } from 'net';
|
|
48
52
|
import { TLSSocket } from 'tls';
|
|
49
53
|
|
|
@@ -68,13 +72,17 @@ export class Electrum {
|
|
|
68
72
|
public electrumNetwork: EElectrumNetworks;
|
|
69
73
|
public connectedToElectrum: boolean;
|
|
70
74
|
public onReceive?: (data: unknown) => void;
|
|
75
|
+
public batchLimit: number;
|
|
76
|
+
public batchDelay: number;
|
|
71
77
|
constructor({
|
|
72
78
|
wallet,
|
|
73
79
|
servers,
|
|
74
80
|
network,
|
|
75
81
|
onReceive,
|
|
76
82
|
tls: _tls,
|
|
77
|
-
net: _net
|
|
83
|
+
net: _net,
|
|
84
|
+
batchLimit = 20,
|
|
85
|
+
batchDelay = 50
|
|
78
86
|
}: {
|
|
79
87
|
wallet: Wallet;
|
|
80
88
|
servers?: TServer | TServer[];
|
|
@@ -82,6 +90,8 @@ export class Electrum {
|
|
|
82
90
|
onReceive?: (data: unknown) => void;
|
|
83
91
|
tls?: TLSSocket;
|
|
84
92
|
net?: Server;
|
|
93
|
+
batchLimit?: number;
|
|
94
|
+
batchDelay?: number;
|
|
85
95
|
}) {
|
|
86
96
|
this._wallet = wallet;
|
|
87
97
|
this.sendMessage = wallet.sendMessage;
|
|
@@ -92,6 +102,8 @@ export class Electrum {
|
|
|
92
102
|
this.onReceive = onReceive;
|
|
93
103
|
this.tls = _tls ?? tls;
|
|
94
104
|
this.net = _net ?? net;
|
|
105
|
+
this.batchLimit = batchLimit;
|
|
106
|
+
this.batchDelay = batchDelay;
|
|
95
107
|
if (!this.tls || !this.net) {
|
|
96
108
|
throw new Error(
|
|
97
109
|
'TLS and NET modules are not available and were not passed as instances'
|
|
@@ -286,15 +298,21 @@ export class Electrum {
|
|
|
286
298
|
addressIndex >= 0 &&
|
|
287
299
|
changeAddressIndex >= 0
|
|
288
300
|
) {
|
|
289
|
-
addressValues =
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
301
|
+
addressValues = filterAddressesForGapLimit({
|
|
302
|
+
addresses: addressValues,
|
|
303
|
+
index: addressIndex,
|
|
304
|
+
gapLimitOptions: this._wallet.gapLimitOptions
|
|
305
|
+
});
|
|
306
|
+
changeAddressValues = filterAddressesForGapLimit({
|
|
307
|
+
addresses: changeAddressValues,
|
|
308
|
+
index: changeAddressIndex,
|
|
309
|
+
gapLimitOptions: this._wallet.gapLimitOptions
|
|
310
|
+
});
|
|
295
311
|
}
|
|
312
|
+
const utxoScriptHashes: IAddress[] = currentWallet.utxos;
|
|
296
313
|
|
|
297
314
|
scriptHashes = [
|
|
315
|
+
...utxoScriptHashes,
|
|
298
316
|
...scriptHashes,
|
|
299
317
|
...addressValues,
|
|
300
318
|
...changeAddressValues
|
|
@@ -312,10 +330,9 @@ export class Electrum {
|
|
|
312
330
|
const combinedResponse: TTxResponse[] = [];
|
|
313
331
|
const promises: Promise<IGetAddressScriptHashesHistoryResponse>[] = [];
|
|
314
332
|
|
|
315
|
-
const chunkLimit = CHUNK_LIMIT[this.network];
|
|
316
333
|
// split payload in chunks of 10 addresses per-request
|
|
317
|
-
for (let i = 0; i < scriptHashes.length; i +=
|
|
318
|
-
const chunk = scriptHashes.slice(i, i +
|
|
334
|
+
for (let i = 0; i < scriptHashes.length; i += this.batchLimit) {
|
|
335
|
+
const chunk = scriptHashes.slice(i, i + this.batchLimit);
|
|
319
336
|
const payload = {
|
|
320
337
|
key: 'scriptHash',
|
|
321
338
|
data: chunk
|
|
@@ -326,14 +343,14 @@ export class Electrum {
|
|
|
326
343
|
network: this.electrumNetwork
|
|
327
344
|
})
|
|
328
345
|
);
|
|
329
|
-
await sleep(
|
|
346
|
+
await sleep(this.batchDelay);
|
|
330
347
|
promises.push(
|
|
331
348
|
electrum.getAddressScriptHashesMempool({
|
|
332
349
|
scriptHashes: payload,
|
|
333
350
|
network: this.electrumNetwork
|
|
334
351
|
})
|
|
335
352
|
);
|
|
336
|
-
await sleep(
|
|
353
|
+
await sleep(this.batchDelay);
|
|
337
354
|
}
|
|
338
355
|
|
|
339
356
|
const responses = await Promise.all(promises);
|
|
@@ -403,13 +420,22 @@ export class Electrum {
|
|
|
403
420
|
|
|
404
421
|
/**
|
|
405
422
|
* Returns UTXO's for a given wallet and network along with the available balance.
|
|
406
|
-
* @param {
|
|
423
|
+
* @param {EScanningStrategy} [scanningStrategy]
|
|
424
|
+
* @param {number} addressIndex
|
|
425
|
+
* @param {number} changeAddressIndex
|
|
426
|
+
* @param {EAddressType[]} [addressTypesToCheck]
|
|
407
427
|
* @returns {Promise<Result<IGetUtxosResponse>>}
|
|
408
428
|
*/
|
|
409
429
|
async getUtxos({
|
|
410
|
-
|
|
430
|
+
scanningStrategy = EScanningStrategy.gapLimit,
|
|
431
|
+
addressIndex,
|
|
432
|
+
changeAddressIndex,
|
|
433
|
+
addressTypesToCheck = this._wallet.addressTypesToMonitor
|
|
411
434
|
}: {
|
|
412
|
-
|
|
435
|
+
scanningStrategy?: EScanningStrategy;
|
|
436
|
+
addressIndex?: number;
|
|
437
|
+
changeAddressIndex?: number;
|
|
438
|
+
addressTypesToCheck?: EAddressType[];
|
|
413
439
|
}): Promise<Result<IGetUtxosResponse>> {
|
|
414
440
|
try {
|
|
415
441
|
if (!this.connectedToElectrum)
|
|
@@ -419,12 +445,11 @@ export class Electrum {
|
|
|
419
445
|
});
|
|
420
446
|
const currentWallet = this._wallet.data;
|
|
421
447
|
|
|
422
|
-
const addressTypeKeys = this._wallet.addressTypesToMonitor;
|
|
423
448
|
let addresses = {} as IAddresses;
|
|
424
449
|
let changeAddresses = {} as IAddresses;
|
|
425
450
|
const existingUtxos: { [key: string]: IUtxo } = {};
|
|
426
451
|
|
|
427
|
-
for (const addressType of
|
|
452
|
+
for (const addressType of addressTypesToCheck) {
|
|
428
453
|
const addressCount = Object.keys(currentWallet.addresses[addressType])
|
|
429
454
|
?.length;
|
|
430
455
|
|
|
@@ -433,30 +458,66 @@ export class Electrum {
|
|
|
433
458
|
break;
|
|
434
459
|
}
|
|
435
460
|
|
|
436
|
-
// Grab the current index for both addresses and change addresses.
|
|
437
|
-
const addressIndex = currentWallet.addressIndex[addressType].index;
|
|
438
|
-
const changeAddressIndex =
|
|
439
|
-
currentWallet.changeAddressIndex[addressType].index;
|
|
440
|
-
|
|
441
461
|
// Grab all addresses and change addresses.
|
|
442
462
|
const allAddresses = currentWallet.addresses[addressType];
|
|
443
463
|
const allChangeAddresses = currentWallet.changeAddresses[addressType];
|
|
444
464
|
|
|
445
|
-
|
|
446
|
-
if (!scanAllAddresses && addressIndex >= 0 && changeAddressIndex >= 0) {
|
|
447
|
-
Object.values(allAddresses).map((a) => {
|
|
448
|
-
if (Math.abs(a.index - addressIndex) <= GAP_LIMIT) {
|
|
449
|
-
addresses[a.scriptHash] = a;
|
|
450
|
-
}
|
|
451
|
-
});
|
|
452
|
-
Object.values(allChangeAddresses).map((a) => {
|
|
453
|
-
if (Math.abs(a.index - changeAddressIndex) <= GAP_LIMIT) {
|
|
454
|
-
changeAddresses[a.scriptHash] = a;
|
|
455
|
-
}
|
|
456
|
-
});
|
|
457
|
-
} else {
|
|
465
|
+
if (scanningStrategy === EScanningStrategy.all) {
|
|
458
466
|
addresses = { ...addresses, ...allAddresses };
|
|
459
467
|
changeAddresses = { ...changeAddresses, ...allChangeAddresses };
|
|
468
|
+
} else {
|
|
469
|
+
// Grab the current index for address/change addresses if none were provided.
|
|
470
|
+
if (!addressIndex)
|
|
471
|
+
addressIndex = currentWallet.addressIndex[addressType].index;
|
|
472
|
+
if (!changeAddressIndex)
|
|
473
|
+
changeAddressIndex =
|
|
474
|
+
currentWallet.changeAddressIndex[addressType].index;
|
|
475
|
+
|
|
476
|
+
// Use the lowest index to ensure we're not starting above our current index.
|
|
477
|
+
// TODO: Consider removing this entirely or at least updating it to allow up to the max stored address/change address index.
|
|
478
|
+
const lowestAddressIndex = Math.min(
|
|
479
|
+
addressIndex,
|
|
480
|
+
currentWallet.addressIndex[addressType].index
|
|
481
|
+
);
|
|
482
|
+
const lowestChangeAddressIndex = Math.min(
|
|
483
|
+
changeAddressIndex,
|
|
484
|
+
currentWallet.changeAddressIndex[addressType].index
|
|
485
|
+
);
|
|
486
|
+
|
|
487
|
+
switch (scanningStrategy) {
|
|
488
|
+
case EScanningStrategy.gapLimit:
|
|
489
|
+
addresses = filterAddressesObjForGapLimit({
|
|
490
|
+
addresses: allAddresses,
|
|
491
|
+
index: lowestAddressIndex,
|
|
492
|
+
gapLimitOptions: this._wallet.gapLimitOptions
|
|
493
|
+
});
|
|
494
|
+
changeAddresses = filterAddressesObjForGapLimit({
|
|
495
|
+
addresses: allChangeAddresses,
|
|
496
|
+
index: lowestChangeAddressIndex,
|
|
497
|
+
gapLimitOptions: this._wallet.gapLimitOptions
|
|
498
|
+
});
|
|
499
|
+
break;
|
|
500
|
+
case EScanningStrategy.startingIndex:
|
|
501
|
+
addresses = filterAddressesObjForStartingIndex({
|
|
502
|
+
addresses: allAddresses,
|
|
503
|
+
index: lowestAddressIndex
|
|
504
|
+
});
|
|
505
|
+
changeAddresses = filterAddressesObjForStartingIndex({
|
|
506
|
+
addresses: allChangeAddresses,
|
|
507
|
+
index: lowestChangeAddressIndex
|
|
508
|
+
});
|
|
509
|
+
break;
|
|
510
|
+
case EScanningStrategy.singleIndex:
|
|
511
|
+
addresses = filterAddressesObjForSingleIndex({
|
|
512
|
+
addresses: allAddresses,
|
|
513
|
+
addressIndex
|
|
514
|
+
});
|
|
515
|
+
changeAddresses = filterAddressesObjForSingleIndex({
|
|
516
|
+
addresses: allChangeAddresses,
|
|
517
|
+
addressIndex: changeAddressIndex
|
|
518
|
+
});
|
|
519
|
+
break;
|
|
520
|
+
}
|
|
460
521
|
}
|
|
461
522
|
}
|
|
462
523
|
|
|
@@ -501,10 +562,9 @@ export class Electrum {
|
|
|
501
562
|
const result: ITransaction<IUtxo>[] = [];
|
|
502
563
|
const promises: Promise<IGetTransactions>[] = [];
|
|
503
564
|
|
|
504
|
-
const chunkLimit = CHUNK_LIMIT[this.network];
|
|
505
565
|
// split payload in chunks of 10 transactions per-request
|
|
506
|
-
for (let i = 0; i < txHashes.length; i +=
|
|
507
|
-
const chunk = txHashes.slice(i, i +
|
|
566
|
+
for (let i = 0; i < txHashes.length; i += this.batchLimit) {
|
|
567
|
+
const chunk = txHashes.slice(i, i + this.batchLimit);
|
|
508
568
|
|
|
509
569
|
const data = {
|
|
510
570
|
key: 'tx_hash',
|
|
@@ -517,7 +577,7 @@ export class Electrum {
|
|
|
517
577
|
network: this.electrumNetwork
|
|
518
578
|
})
|
|
519
579
|
);
|
|
520
|
-
await sleep(
|
|
580
|
+
await sleep(this.batchDelay);
|
|
521
581
|
}
|
|
522
582
|
const responses = await Promise.all(promises);
|
|
523
583
|
responses.forEach((response) => {
|
|
@@ -704,6 +764,7 @@ export class Electrum {
|
|
|
704
764
|
scriptHashes?: string[];
|
|
705
765
|
onReceive?: (data: TSubscribedReceive) => void;
|
|
706
766
|
} = {}): Promise<Result<string>> {
|
|
767
|
+
const allUtxos: IUtxo[] = [];
|
|
707
768
|
const currentWallet = this._wallet.data;
|
|
708
769
|
const addressTypeKeys = this._wallet.addressTypesToMonitor;
|
|
709
770
|
// Gather the receiving address scripthash for each address type if no scripthashes were provided.
|
|
@@ -718,20 +779,27 @@ export class Electrum {
|
|
|
718
779
|
addressIndex = addressIndex > 0 ? addressIndex : 0;
|
|
719
780
|
|
|
720
781
|
// Only subscribe up to the gap limit.
|
|
721
|
-
const
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
782
|
+
const addressesInRangeToSubscribe = filterAddressesForGapLimit({
|
|
783
|
+
addresses: Object.values(addresses),
|
|
784
|
+
index: addressIndex,
|
|
785
|
+
gapLimitOptions: this._wallet.gapLimitOptions
|
|
786
|
+
});
|
|
787
|
+
const _scriptHashes = addressesInRangeToSubscribe.map(
|
|
788
|
+
(address) => address.scriptHash
|
|
727
789
|
);
|
|
728
|
-
scriptHashes.push(...
|
|
790
|
+
scriptHashes.push(..._scriptHashes);
|
|
729
791
|
}
|
|
730
792
|
}
|
|
793
|
+
// Keep an eye on existing UTXO's regardless of the gap limit.
|
|
794
|
+
currentWallet.utxos.forEach((utxo) => {
|
|
795
|
+
if (!scriptHashes.includes(utxo.scriptHash)) {
|
|
796
|
+
allUtxos.push(utxo);
|
|
797
|
+
}
|
|
798
|
+
});
|
|
731
799
|
}
|
|
732
800
|
|
|
733
801
|
// Subscribe to all provided script hashes.
|
|
734
|
-
const
|
|
802
|
+
const allScriptHashesPromise = scriptHashes.map(async (scriptHash) => {
|
|
735
803
|
const response: ISubscribeToAddress = await electrum.subscribeAddress({
|
|
736
804
|
scriptHash,
|
|
737
805
|
network: this.electrumNetwork,
|
|
@@ -745,8 +813,27 @@ export class Electrum {
|
|
|
745
813
|
}
|
|
746
814
|
});
|
|
747
815
|
|
|
816
|
+
const allUtxosPromise = allUtxos.map(async (utxo) => {
|
|
817
|
+
const response: ISubscribeToAddress = await electrum.subscribeAddress({
|
|
818
|
+
scriptHash: utxo.scriptHash,
|
|
819
|
+
network: this.electrumNetwork,
|
|
820
|
+
onReceive: async (data: TSubscribedReceive): Promise<void> => {
|
|
821
|
+
onReceive?.(data);
|
|
822
|
+
await this.getUtxos({
|
|
823
|
+
scanningStrategy: EScanningStrategy.singleIndex,
|
|
824
|
+
addressIndex: utxo.index,
|
|
825
|
+
changeAddressIndex: utxo.index
|
|
826
|
+
});
|
|
827
|
+
this._wallet.refreshWallet({});
|
|
828
|
+
}
|
|
829
|
+
});
|
|
830
|
+
if (response.error) {
|
|
831
|
+
throw Error('Unable to subscribe to receiving addresses.');
|
|
832
|
+
}
|
|
833
|
+
});
|
|
834
|
+
|
|
748
835
|
try {
|
|
749
|
-
await Promise.all(
|
|
836
|
+
await Promise.all([allScriptHashesPromise, allUtxosPromise]);
|
|
750
837
|
} catch (e) {
|
|
751
838
|
return err(e);
|
|
752
839
|
}
|
package/src/types/electrum.ts
CHANGED
|
@@ -30,6 +30,13 @@ export enum EProtocol {
|
|
|
30
30
|
ssl = 'ssl'
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
export enum EScanningStrategy {
|
|
34
|
+
all = 'all', // Scan all addresses/scripthashes
|
|
35
|
+
gapLimit = 'gapLimit', // Adhere to the gap limit within range of the provided index when scanning addresses/scripthashes. If higher than the current index, it will be ignored
|
|
36
|
+
startingIndex = 'startingIndex', // Scan all addresses/scripthashes starting from the provided index. If higher than the current index, it will be ignored
|
|
37
|
+
singleIndex = 'singleIndex' // Scan the single provided address/scripthash
|
|
38
|
+
}
|
|
39
|
+
|
|
33
40
|
export interface IGetUtxosResponse {
|
|
34
41
|
utxos: IUtxo[];
|
|
35
42
|
balance: number;
|
package/src/types/transaction.ts
CHANGED
|
@@ -58,3 +58,8 @@ export type TGetTotalFeeObj = {
|
|
|
58
58
|
satsPerByte: number;
|
|
59
59
|
maxSatPerByte: number; // Max sats per byte that can be used for a given transaction without exceeding 50% of the balance.
|
|
60
60
|
};
|
|
61
|
+
|
|
62
|
+
export type TGapLimitOptions = {
|
|
63
|
+
lookAhead: number;
|
|
64
|
+
lookBehind: number;
|
|
65
|
+
};
|
package/src/types/wallet.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
TServer,
|
|
7
7
|
TTxResult
|
|
8
8
|
} from './electrum';
|
|
9
|
-
import { EFeeId } from './transaction';
|
|
9
|
+
import { EFeeId, TGapLimitOptions } from './transaction';
|
|
10
10
|
import { TLSSocket } from 'tls';
|
|
11
11
|
import { Server } from 'net';
|
|
12
12
|
import { ECPairInterface } from 'ecpair';
|
|
@@ -67,6 +67,7 @@ export interface IUtxo {
|
|
|
67
67
|
tx_hash: string;
|
|
68
68
|
tx_pos: number;
|
|
69
69
|
value: number;
|
|
70
|
+
publicKey: string;
|
|
70
71
|
keyPair?: BIP32Interface | ECPairInterface;
|
|
71
72
|
}
|
|
72
73
|
|
|
@@ -193,6 +194,8 @@ export interface IWallet {
|
|
|
193
194
|
servers?: TServer | TServer[];
|
|
194
195
|
tls?: TLSSocket;
|
|
195
196
|
net?: Server;
|
|
197
|
+
batchLimit?: number; // Maximum number of requests to be sent in a single batch
|
|
198
|
+
batchDelay?: number; // Delay (in milliseconds) between each batch of requests
|
|
196
199
|
};
|
|
197
200
|
remainOffline?: boolean;
|
|
198
201
|
onMessage?: TOnMessage;
|
|
@@ -205,6 +208,9 @@ export interface IWallet {
|
|
|
205
208
|
disableMessages?: boolean;
|
|
206
209
|
disableMessagesOnCreate?: boolean;
|
|
207
210
|
addressTypesToMonitor?: EAddressType[];
|
|
211
|
+
gapLimitOptions?: TGapLimitOptions;
|
|
212
|
+
addressLookBehind?: number;
|
|
213
|
+
addressLookAhead?: number;
|
|
208
214
|
}
|
|
209
215
|
|
|
210
216
|
export interface IAddressData {
|
package/src/utils/helpers.ts
CHANGED
|
@@ -331,3 +331,17 @@ export const sleep = (ms): Promise<void> => {
|
|
|
331
331
|
setTimeout(resolve, ms);
|
|
332
332
|
});
|
|
333
333
|
};
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Returns the difference between two address indexes.
|
|
337
|
+
* @param addrIndex1
|
|
338
|
+
* @param addrIndex2
|
|
339
|
+
* @returns number
|
|
340
|
+
*/
|
|
341
|
+
export const getAddressIndexDiff = (addrIndex1 = 0, addrIndex2 = 0): number => {
|
|
342
|
+
if (addrIndex1 < 0) addrIndex1 = -1;
|
|
343
|
+
if (addrIndex2 < 0) addrIndex2 = -1;
|
|
344
|
+
return Math.abs(addrIndex1 - addrIndex2);
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
export const isPositive = (num: number): boolean => num > 0;
|