beignet 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +4 -0
- package/.eslintrc +40 -0
- package/.prettierrc +9 -0
- package/LICENSE +21 -0
- package/README.md +166 -0
- package/dist/electrum/constants.js +31 -0
- package/dist/electrum/constants.js.map +1 -0
- package/dist/electrum/index.js +552 -0
- package/dist/electrum/index.js.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/shapes/electrum.js +14 -0
- package/dist/shapes/electrum.js.map +1 -0
- package/dist/shapes/index.js +19 -0
- package/dist/shapes/index.js.map +1 -0
- package/dist/shapes/wallet.js +115 -0
- package/dist/shapes/wallet.js.map +1 -0
- package/dist/transaction/index.js +692 -0
- package/dist/transaction/index.js.map +1 -0
- package/dist/types/electrum/constants.d.ts +7 -0
- package/dist/types/electrum/index.d.ts +85 -0
- package/dist/types/electrum.js +9 -0
- package/dist/types/electrum.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.js +20 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/shapes/electrum.d.ts +5 -0
- package/dist/types/shapes/index.d.ts +2 -0
- package/dist/types/shapes/wallet.d.ts +10 -0
- package/dist/types/transaction/index.d.ts +92 -0
- package/dist/types/transaction.js +12 -0
- package/dist/types/transaction.js.map +1 -0
- package/dist/types/types/electrum.d.ts +113 -0
- package/dist/types/types/index.d.ts +3 -0
- package/dist/types/types/transaction.d.ts +51 -0
- package/dist/types/types/wallet.d.ts +400 -0
- package/dist/types/utils/conversion.d.ts +10 -0
- package/dist/types/utils/derivation-path.d.ts +19 -0
- package/dist/types/utils/electrum.d.ts +10 -0
- package/dist/types/utils/exchange-rate.d.ts +30 -0
- package/dist/types/utils/helpers.d.ts +23 -0
- package/dist/types/utils/index.d.ts +7 -0
- package/dist/types/utils/result.d.ts +16 -0
- package/dist/types/utils/transaction.d.ts +21 -0
- package/dist/types/utils/wallet.d.ts +47 -0
- package/dist/types/wallet/constants.d.ts +12 -0
- package/dist/types/wallet/index.d.ts +214 -0
- package/dist/types/wallet.js +36 -0
- package/dist/types/wallet.js.map +1 -0
- package/dist/utils/conversion.js +52 -0
- package/dist/utils/conversion.js.map +1 -0
- package/dist/utils/derivation-path.js +104 -0
- package/dist/utils/derivation-path.js.map +1 -0
- package/dist/utils/electrum.js +149 -0
- package/dist/utils/electrum.js.map +1 -0
- package/dist/utils/exchange-rate.js +49 -0
- package/dist/utils/exchange-rate.js.map +1 -0
- package/dist/utils/helpers.js +137 -0
- package/dist/utils/helpers.js.map +1 -0
- package/dist/utils/index.js +24 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/result.js +36 -0
- package/dist/utils/result.js.map +1 -0
- package/dist/utils/transaction.js +327 -0
- package/dist/utils/transaction.js.map +1 -0
- package/dist/utils/wallet.js +227 -0
- package/dist/utils/wallet.js.map +1 -0
- package/dist/wallet/constants.js +15 -0
- package/dist/wallet/constants.js.map +1 -0
- package/dist/wallet/index.js +2113 -0
- package/dist/wallet/index.js.map +1 -0
- package/docs/html/.nojekyll +1 -0
- package/docs/html/assets/highlight.css +22 -0
- package/docs/html/assets/main.js +58 -0
- package/docs/html/assets/search.js +1 -0
- package/docs/html/assets/style.css +1367 -0
- package/docs/html/classes/Electrum.html +812 -0
- package/docs/html/classes/Transaction.html +687 -0
- package/docs/html/classes/Wallet.html +2030 -0
- package/docs/html/enums/EAddressType.html +227 -0
- package/docs/html/enums/EAvailableNetworks.html +255 -0
- package/docs/html/enums/EBoostType.html +220 -0
- package/docs/html/enums/EFeeId.html +241 -0
- package/docs/html/enums/EPaymentType.html +220 -0
- package/docs/html/enums/EProtocol.html +220 -0
- package/docs/html/enums/EUnit.html +227 -0
- package/docs/html/functions/availableNetworks.html +200 -0
- package/docs/html/functions/constructByteCountParam.html +210 -0
- package/docs/html/functions/decodeOpReturnMessage.html +202 -0
- package/docs/html/functions/decodeRawTransaction.html +210 -0
- package/docs/html/functions/err.html +214 -0
- package/docs/html/functions/formatKeyDerivationPath.html +219 -0
- package/docs/html/functions/formatPeerData.html +207 -0
- package/docs/html/functions/generateMnemonic.html +223 -0
- package/docs/html/functions/generateWalletId.html +202 -0
- package/docs/html/functions/getAddressFromScriptPubKey.html +209 -0
- package/docs/html/functions/getAddressTypeFromPath.html +206 -0
- package/docs/html/functions/getByteCount.html +206 -0
- package/docs/html/functions/getDataFallback.html +207 -0
- package/docs/html/functions/getDefaultPort.html +209 -0
- package/docs/html/functions/getDefaultWalletData.html +200 -0
- package/docs/html/functions/getDefaultWalletDataKeys.html +200 -0
- package/docs/html/functions/getExchangeRates.html +200 -0
- package/docs/html/functions/getHighestUsedIndexFromTxHashes.html +216 -0
- package/docs/html/functions/getKeyDerivationPath.html +211 -0
- package/docs/html/functions/getKeyDerivationPathObject.html +216 -0
- package/docs/html/functions/getKeyDerivationPathString.html +220 -0
- package/docs/html/functions/getKeyValue.html +206 -0
- package/docs/html/functions/getPeers.html +211 -0
- package/docs/html/functions/getProtocolForPort.html +209 -0
- package/docs/html/functions/getScriptHash.html +210 -0
- package/docs/html/functions/getSeed.html +209 -0
- package/docs/html/functions/getSeedHash.html +206 -0
- package/docs/html/functions/getSha256.html +206 -0
- package/docs/html/functions/getStorageKeyValues.html +209 -0
- package/docs/html/functions/getTxFee.html +210 -0
- package/docs/html/functions/getWalletDataStorageKey.html +206 -0
- package/docs/html/functions/isValidBech32mEncodedString.html +211 -0
- package/docs/html/functions/objectKeys-1.html +211 -0
- package/docs/html/functions/objectsMatch.html +210 -0
- package/docs/html/functions/ok.html +214 -0
- package/docs/html/functions/parseOnChainPaymentRequest.html +204 -0
- package/docs/html/functions/reduceValue.html +215 -0
- package/docs/html/functions/removeDustOutputs.html +206 -0
- package/docs/html/functions/setReplaceByFee.html +210 -0
- package/docs/html/functions/shuffleArray.html +211 -0
- package/docs/html/functions/validateAddress.html +216 -0
- package/docs/html/functions/validateMnemonic.html +206 -0
- package/docs/html/functions/validateTransaction.html +206 -0
- package/docs/html/index.html +360 -0
- package/docs/html/interfaces/IAddInput.html +231 -0
- package/docs/html/interfaces/IAddress.html +247 -0
- package/docs/html/interfaces/IAddressData.html +231 -0
- package/docs/html/interfaces/IAddressType.html +199 -0
- package/docs/html/interfaces/IAddressTypeData.html +252 -0
- package/docs/html/interfaces/IAddresses.html +199 -0
- package/docs/html/interfaces/IBoostedTransaction.html +238 -0
- package/docs/html/interfaces/IBoostedTransactions.html +199 -0
- package/docs/html/interfaces/ICreateTransaction.html +224 -0
- package/docs/html/interfaces/ICustomGetAddress.html +231 -0
- package/docs/html/interfaces/ICustomGetScriptHash.html +224 -0
- package/docs/html/interfaces/IElectrumGetAddressBalanceRes.html +235 -0
- package/docs/html/interfaces/IExchangeRates.html +210 -0
- package/docs/html/interfaces/IFormattedPeerData.html +245 -0
- package/docs/html/interfaces/IFormattedTransaction.html +343 -0
- package/docs/html/interfaces/IFormattedTransactions.html +199 -0
- package/docs/html/interfaces/IGenerateAddresses.html +252 -0
- package/docs/html/interfaces/IGenerateAddressesResponse.html +224 -0
- package/docs/html/interfaces/IGetAddress.html +231 -0
- package/docs/html/interfaces/IGetAddressBalanceRes.html +226 -0
- package/docs/html/interfaces/IGetAddressByPath.html +224 -0
- package/docs/html/interfaces/IGetAddressHistoryResponse.html +269 -0
- package/docs/html/interfaces/IGetAddressResponse.html +231 -0
- package/docs/html/interfaces/IGetAddressScriptHashesHistoryResponse.html +245 -0
- package/docs/html/interfaces/IGetDerivationPath.html +259 -0
- package/docs/html/interfaces/IGetFeeEstimatesResponse.html +238 -0
- package/docs/html/interfaces/IGetHeaderResponse.html +245 -0
- package/docs/html/interfaces/IGetNextAvailableAddressResponse.html +238 -0
- package/docs/html/interfaces/IGetTransactions.html +245 -0
- package/docs/html/interfaces/IGetTransactionsFromInputs.html +245 -0
- package/docs/html/interfaces/IGetUtxosResponse.html +224 -0
- package/docs/html/interfaces/IHeader.html +231 -0
- package/docs/html/interfaces/IIndexes.html +238 -0
- package/docs/html/interfaces/IKeyDerivationPath.html +247 -0
- package/docs/html/interfaces/IKeyDerivationPathData.html +224 -0
- package/docs/html/interfaces/INewBlock.html +224 -0
- package/docs/html/interfaces/IOnchainFees.html +245 -0
- package/docs/html/interfaces/IOutput.html +231 -0
- package/docs/html/interfaces/IPeerData.html +231 -0
- package/docs/html/interfaces/IRbfData.html +252 -0
- package/docs/html/interfaces/ISend.html +224 -0
- package/docs/html/interfaces/ISendTransaction.html +322 -0
- package/docs/html/interfaces/ISendTx.html +231 -0
- package/docs/html/interfaces/ISetupTransaction.html +238 -0
- package/docs/html/interfaces/ISubscribeToAddress.html +247 -0
- package/docs/html/interfaces/ISubscribeToHeader.html +245 -0
- package/docs/html/interfaces/ITargets.html +238 -0
- package/docs/html/interfaces/ITransaction.html +281 -0
- package/docs/html/interfaces/ITxHash.html +217 -0
- package/docs/html/interfaces/ITxHashes.html +235 -0
- package/docs/html/interfaces/IUtxo.html +275 -0
- package/docs/html/interfaces/IVin.html +252 -0
- package/docs/html/interfaces/IVout.html +246 -0
- package/docs/html/interfaces/IWallet.html +350 -0
- package/docs/html/interfaces/IWalletData.html +343 -0
- package/docs/html/types/ElectrumConnectionPubSub.html +233 -0
- package/docs/html/types/ElectrumConnectionSubscription.html +204 -0
- package/docs/html/types/InputData.html +203 -0
- package/docs/html/types/ObjectKeys.html +198 -0
- package/docs/html/types/Result.html +201 -0
- package/docs/html/types/TAddressIndexInfo.html +204 -0
- package/docs/html/types/TAddressLabel.html +193 -0
- package/docs/html/types/TAddressType.html +193 -0
- package/docs/html/types/TAddressTypeContent.html +198 -0
- package/docs/html/types/TAddressTypes.html +193 -0
- package/docs/html/types/TAvailableNetworks.html +193 -0
- package/docs/html/types/TConnectToElectrumRes.html +193 -0
- package/docs/html/types/TDecodeRawTx.html +214 -0
- package/docs/html/types/TElectrumNetworks.html +193 -0
- package/docs/html/types/TGetAddressHistory.html +200 -0
- package/docs/html/types/TGetByteCountInput.html +193 -0
- package/docs/html/types/TGetByteCountInputs.html +193 -0
- package/docs/html/types/TGetByteCountOutput.html +193 -0
- package/docs/html/types/TGetByteCountOutputs.html +193 -0
- package/docs/html/types/TGetData.html +211 -0
- package/docs/html/types/TGetTotalFeeObj.html +204 -0
- package/docs/html/types/TKeyDerivationAccount.html +193 -0
- package/docs/html/types/TKeyDerivationChange.html +193 -0
- package/docs/html/types/TKeyDerivationCoinType.html +193 -0
- package/docs/html/types/TKeyDerivationIndex.html +193 -0
- package/docs/html/types/TKeyDerivationPurpose.html +193 -0
- package/docs/html/types/TMessageDataMap.html +210 -0
- package/docs/html/types/TMessageKeys.html +193 -0
- package/docs/html/types/TOnMessage.html +213 -0
- package/docs/html/types/TProcessUnconfirmedTransactions.html +202 -0
- package/docs/html/types/TProtocol.html +193 -0
- package/docs/html/types/TServer.html +204 -0
- package/docs/html/types/TSetData.html +213 -0
- package/docs/html/types/TSetupTransactionResponse.html +193 -0
- package/docs/html/types/TStorage.html +200 -0
- package/docs/html/types/TSubscribedReceive.html +193 -0
- package/docs/html/types/TTransactionMessage.html +198 -0
- package/docs/html/types/TTxResponse.html +206 -0
- package/docs/html/types/TTxResult.html +200 -0
- package/docs/html/types/TUnspentAddressScriptHashData.html +198 -0
- package/docs/html/types/TWalletDataKeys.html +193 -0
- package/docs/html/variables/defaultElectrumPorts.html +193 -0
- package/docs/html/variables/electrumConnection.html +199 -0
- package/docs/html/variables/mostUsedExchangeTickers.html +241 -0
- package/docs/markdown/.nojekyll +1 -0
- package/docs/markdown/README.md +1875 -0
- package/docs/markdown/classes/Electrum.md +718 -0
- package/docs/markdown/classes/Transaction.md +536 -0
- package/docs/markdown/classes/Wallet.md +2189 -0
- package/docs/markdown/enums/EAddressType.md +41 -0
- package/docs/markdown/enums/EAvailableNetworks.md +85 -0
- package/docs/markdown/enums/EBoostType.md +30 -0
- package/docs/markdown/enums/EFeeId.md +63 -0
- package/docs/markdown/enums/EPaymentType.md +30 -0
- package/docs/markdown/enums/EProtocol.md +30 -0
- package/docs/markdown/enums/EUnit.md +41 -0
- package/docs/markdown/interfaces/IAddInput.md +41 -0
- package/docs/markdown/interfaces/IAddress.md +69 -0
- package/docs/markdown/interfaces/IAddressData.md +41 -0
- package/docs/markdown/interfaces/IAddressType.md +7 -0
- package/docs/markdown/interfaces/IAddressTypeData.md +74 -0
- package/docs/markdown/interfaces/IAddresses.md +7 -0
- package/docs/markdown/interfaces/IBoostedTransaction.md +52 -0
- package/docs/markdown/interfaces/IBoostedTransactions.md +7 -0
- package/docs/markdown/interfaces/ICreateTransaction.md +30 -0
- package/docs/markdown/interfaces/ICustomGetAddress.md +41 -0
- package/docs/markdown/interfaces/ICustomGetScriptHash.md +30 -0
- package/docs/markdown/interfaces/IElectrumGetAddressBalanceRes.md +55 -0
- package/docs/markdown/interfaces/IExchangeRates.md +7 -0
- package/docs/markdown/interfaces/IFormattedPeerData.md +63 -0
- package/docs/markdown/interfaces/IFormattedTransaction.md +217 -0
- package/docs/markdown/interfaces/IFormattedTransactions.md +7 -0
- package/docs/markdown/interfaces/IGenerateAddresses.md +74 -0
- package/docs/markdown/interfaces/IGenerateAddressesResponse.md +30 -0
- package/docs/markdown/interfaces/IGetAddress.md +41 -0
- package/docs/markdown/interfaces/IGetAddressBalanceRes.md +36 -0
- package/docs/markdown/interfaces/IGetAddressByPath.md +30 -0
- package/docs/markdown/interfaces/IGetAddressHistoryResponse.md +121 -0
- package/docs/markdown/interfaces/IGetAddressResponse.md +41 -0
- package/docs/markdown/interfaces/IGetAddressScriptHashesHistoryResponse.md +63 -0
- package/docs/markdown/interfaces/IGetDerivationPath.md +100 -0
- package/docs/markdown/interfaces/IGetFeeEstimatesResponse.md +52 -0
- package/docs/markdown/interfaces/IGetHeaderResponse.md +63 -0
- package/docs/markdown/interfaces/IGetNextAvailableAddressResponse.md +52 -0
- package/docs/markdown/interfaces/IGetTransactions.md +63 -0
- package/docs/markdown/interfaces/IGetTransactionsFromInputs.md +63 -0
- package/docs/markdown/interfaces/IGetUtxosResponse.md +30 -0
- package/docs/markdown/interfaces/IHeader.md +41 -0
- package/docs/markdown/interfaces/IIndexes.md +52 -0
- package/docs/markdown/interfaces/IKeyDerivationPath.md +69 -0
- package/docs/markdown/interfaces/IKeyDerivationPathData.md +30 -0
- package/docs/markdown/interfaces/INewBlock.md +30 -0
- package/docs/markdown/interfaces/IOnchainFees.md +63 -0
- package/docs/markdown/interfaces/IOutput.md +41 -0
- package/docs/markdown/interfaces/IPeerData.md +41 -0
- package/docs/markdown/interfaces/IRbfData.md +74 -0
- package/docs/markdown/interfaces/ISend.md +30 -0
- package/docs/markdown/interfaces/ISendTransaction.md +184 -0
- package/docs/markdown/interfaces/ISendTx.md +41 -0
- package/docs/markdown/interfaces/ISetupTransaction.md +52 -0
- package/docs/markdown/interfaces/ISubscribeToAddress.md +60 -0
- package/docs/markdown/interfaces/ISubscribeToHeader.md +59 -0
- package/docs/markdown/interfaces/ITargets.md +52 -0
- package/docs/markdown/interfaces/ITransaction.md +88 -0
- package/docs/markdown/interfaces/ITxHash.md +19 -0
- package/docs/markdown/interfaces/ITxHashes.md +55 -0
- package/docs/markdown/interfaces/IUtxo.md +112 -0
- package/docs/markdown/interfaces/IVin.md +70 -0
- package/docs/markdown/interfaces/IVout.md +52 -0
- package/docs/markdown/interfaces/IWallet.md +209 -0
- package/docs/markdown/interfaces/IWalletData.md +217 -0
- package/example/helpers.ts +76 -0
- package/example/index.ts +77 -0
- package/package.json +69 -0
- package/src/electrum/constants.ts +28 -0
- package/src/electrum/index.ts +838 -0
- package/src/index.ts +6 -0
- package/src/shapes/electrum.ts +13 -0
- package/src/shapes/index.ts +2 -0
- package/src/shapes/wallet.ts +133 -0
- package/src/transaction/index.ts +1078 -0
- package/src/types/electrum.ts +139 -0
- package/src/types/index.ts +3 -0
- package/src/types/transaction.ts +58 -0
- package/src/types/wallet.ts +503 -0
- package/src/utils/conversion.ts +88 -0
- package/src/utils/derivation-path.ts +171 -0
- package/src/utils/electrum.ts +188 -0
- package/src/utils/exchange-rate.ts +70 -0
- package/src/utils/helpers.ts +191 -0
- package/src/utils/index.ts +7 -0
- package/src/utils/result.ts +79 -0
- package/src/utils/transaction.ts +417 -0
- package/src/utils/wallet.ts +351 -0
- package/src/wallet/constants.ts +24 -0
- package/src/wallet/index.ts +3304 -0
- package/tests/constants.ts +9 -0
- package/tests/derivation.test.ts +146 -0
- package/tests/electrum.test.ts +137 -0
- package/tests/storage.test.ts +222 -0
- package/tests/transaction.test.ts +187 -0
- package/tests/wallet.test.ts +307 -0
- package/tsconfig.json +32 -0
- package/typedoc.json +5 -0
package/.eslintignore
ADDED
package/.eslintrc
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"root": true,
|
|
3
|
+
"parser": "@typescript-eslint/parser",
|
|
4
|
+
"plugins": [
|
|
5
|
+
"@typescript-eslint"
|
|
6
|
+
],
|
|
7
|
+
"extends": [
|
|
8
|
+
"eslint:recommended",
|
|
9
|
+
"plugin:@typescript-eslint/eslint-recommended",
|
|
10
|
+
"plugin:@typescript-eslint/recommended",
|
|
11
|
+
"plugin:prettier/recommended"
|
|
12
|
+
],
|
|
13
|
+
"rules": {
|
|
14
|
+
"semi": "off",
|
|
15
|
+
"@typescript-eslint/semi": ["error"],
|
|
16
|
+
"no-shadow": "off",
|
|
17
|
+
"@typescript-eslint/no-shadow": "error",
|
|
18
|
+
"@typescript-eslint/no-unused-vars": "error",
|
|
19
|
+
"no-console": 0,
|
|
20
|
+
"no-empty": ["error", { "allowEmptyCatch": true }],
|
|
21
|
+
"no-buffer-constructor": 0,
|
|
22
|
+
"no-case-declarations": 0,
|
|
23
|
+
"no-useless-escape": 0,
|
|
24
|
+
"indent": "off",
|
|
25
|
+
"object-curly-spacing": [
|
|
26
|
+
"error",
|
|
27
|
+
"always",
|
|
28
|
+
{
|
|
29
|
+
"objectsInObjects": true
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"no-undef": 0,
|
|
33
|
+
"require-atomic-updates": 0,
|
|
34
|
+
"no-async-promise-executor": 0,
|
|
35
|
+
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
|
|
36
|
+
"@typescript-eslint/explicit-function-return-type": "warn",
|
|
37
|
+
"@typescript-eslint/ban-ts-comment": "off",
|
|
38
|
+
"@typescript-eslint/no-non-null-assertion": "off"
|
|
39
|
+
}
|
|
40
|
+
}
|
package/.prettierrc
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Synonym
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# Beignet
|
|
2
|
+
|
|
3
|
+
:warning: This is pre-alpha software and not suitable for production apps yet.
|
|
4
|
+
|
|
5
|
+
## Description
|
|
6
|
+
|
|
7
|
+
An instant, self-custodial Bitcoin wallet for JS devs.
|
|
8
|
+
|
|
9
|
+
This Typescript library offers JS developers a way to incorporate an on-chain, self-custodial Bitcoin wallet into their projects.
|
|
10
|
+
|
|
11
|
+
## Table of Contents
|
|
12
|
+
|
|
13
|
+
1. [Getting Started](#getting-started)
|
|
14
|
+
2. [Running Tests & Examples](#running-tests--examples)
|
|
15
|
+
- [Clone the Repository](#clone-the-repository)
|
|
16
|
+
- [Install Dependencies & Build](#install-dependencies--build)
|
|
17
|
+
- [Run Tests](#run-tests)
|
|
18
|
+
- [Run Example Project](#run-example-project)
|
|
19
|
+
3. [Implementation](#implementation)
|
|
20
|
+
4. [Advanced Usage](#advanced-usage)
|
|
21
|
+
5. [Documentation](#documentation)
|
|
22
|
+
6. [Support](#support)
|
|
23
|
+
|
|
24
|
+
## Getting Started
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Using Yarn
|
|
28
|
+
yarn add beignet
|
|
29
|
+
|
|
30
|
+
# Or, using NPM
|
|
31
|
+
npm i -S beignet
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Running Tests & Examples
|
|
35
|
+
|
|
36
|
+
### Clone the Repository
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
git clone git@github.com:synonymdev/beignet.git && cd beignet
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Install Dependencies & Build
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm i && npm run build
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Run tests:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm run test
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Run example project:
|
|
55
|
+
```bash
|
|
56
|
+
npm run example
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Implementation
|
|
60
|
+
```javascript
|
|
61
|
+
import { Wallet, generateMnemonic } from 'beignet';
|
|
62
|
+
|
|
63
|
+
// Generate a mnemonic phrase
|
|
64
|
+
const mnemonic = generateMnemonic();
|
|
65
|
+
|
|
66
|
+
// Create a wallet instance
|
|
67
|
+
const createWalletRes = await Wallet.create({ mnemonic });
|
|
68
|
+
if (createWalletRes.isErr()) return;
|
|
69
|
+
const wallet = createWalletRes.value;
|
|
70
|
+
|
|
71
|
+
// Get receiving address
|
|
72
|
+
const address = await wallet.getAddress();
|
|
73
|
+
|
|
74
|
+
// Get address balance
|
|
75
|
+
const addressBalanceRes = await wallet.getAddressBalance(address);
|
|
76
|
+
if (addressBalance.isErr()) return;
|
|
77
|
+
const addressBalance = addressBalanceRes.value;
|
|
78
|
+
|
|
79
|
+
// Get wallet balance
|
|
80
|
+
const walletBalance = wallet.getBalance();
|
|
81
|
+
|
|
82
|
+
// Get fee information to perform a transaction.
|
|
83
|
+
const feeInfo = wallet.getFeeInfo();
|
|
84
|
+
|
|
85
|
+
// Send sats
|
|
86
|
+
const sendRes = await wallet.send({ address: 'address to send sats to', amount: 1000 });
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Advanced Usage
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
import { Wallet, generateMnemonic } from 'beignet';
|
|
93
|
+
import { TStorage } from './wallet';
|
|
94
|
+
|
|
95
|
+
// Generate a mnemonic phrase
|
|
96
|
+
const mnemonic = generateMnemonic();
|
|
97
|
+
|
|
98
|
+
// Add a bip39 passphrase
|
|
99
|
+
const passphrase = 'passphrase';
|
|
100
|
+
|
|
101
|
+
// Connect to custom electrum server
|
|
102
|
+
const servers: TServer = {
|
|
103
|
+
host: '35.233.47.252',
|
|
104
|
+
ssl: 18484,
|
|
105
|
+
tcp: 18483,
|
|
106
|
+
protocol: EProtocol.ssl,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// Use a specific network (Defaults to mainnet)
|
|
110
|
+
const network = ENetworks.mainnet;
|
|
111
|
+
|
|
112
|
+
// Use a specific address type. (Defaults to EAddressType.p2wpkh)
|
|
113
|
+
const addressType = EAddressType.p2sh;
|
|
114
|
+
|
|
115
|
+
// Subscribe to server messages (TOnMessage)
|
|
116
|
+
const onMessage: TOnMessage = (id, data) => {
|
|
117
|
+
console.log(id);
|
|
118
|
+
console.dir(data, { depth: null });
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Persist sessions by getting and setting data from storage
|
|
122
|
+
const storage: TStorage = {
|
|
123
|
+
async getData<K extends keyof IWalletData>(
|
|
124
|
+
key: string
|
|
125
|
+
): Promise<Result<IWalletData[K]>> {
|
|
126
|
+
// Add your logic here
|
|
127
|
+
},
|
|
128
|
+
async setData<K extends keyof IWalletData>(
|
|
129
|
+
key: string,
|
|
130
|
+
value: IWalletData[K]
|
|
131
|
+
): Promise<Result<boolean>> {
|
|
132
|
+
// Add your logic here
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// Create a wallet instance
|
|
137
|
+
const createWalletRes = await Wallet.create({
|
|
138
|
+
mnemonic,
|
|
139
|
+
passphrase,
|
|
140
|
+
electrumOptions: { servers },
|
|
141
|
+
network,
|
|
142
|
+
onMessage,
|
|
143
|
+
storage
|
|
144
|
+
});
|
|
145
|
+
if (createWalletRes.isErr()) return;
|
|
146
|
+
const wallet = createWalletRes.value;
|
|
147
|
+
|
|
148
|
+
// List UTXO's
|
|
149
|
+
const utxos = wallet.listUtxos();
|
|
150
|
+
|
|
151
|
+
// Send sats to multiple outputs
|
|
152
|
+
const txs = [
|
|
153
|
+
{ address: 'address1', amount: 1000 },
|
|
154
|
+
{ address: 'address2', amount: 2000 },
|
|
155
|
+
{ address: 'address3', amount: 3000 },
|
|
156
|
+
];
|
|
157
|
+
const sendManyRes = await wallet.sendMany({ txs });
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Documentation
|
|
161
|
+
- [HTML](docs/html/classes/Wallet.html)
|
|
162
|
+
- [Markdown](docs/markdown/classes/Wallet.md)
|
|
163
|
+
|
|
164
|
+
## Support
|
|
165
|
+
|
|
166
|
+
If you are experiencing any problems, please open an issue or reach out to us on [Telegram](https://t.me/bitkitchat).
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TESTNET_PEERS = exports.TEST_MNEMONIC = void 0;
|
|
4
|
+
exports.TEST_MNEMONIC = 'decorate grass round powder swarm syrup identify resemble mass online grunt cruise';
|
|
5
|
+
exports.TESTNET_PEERS = [
|
|
6
|
+
{
|
|
7
|
+
host: 'testnet.hsmiths.com',
|
|
8
|
+
ssl: 53012,
|
|
9
|
+
tcp: 53012,
|
|
10
|
+
protocol: 'ssl'
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
host: 'tn.not.fyi',
|
|
14
|
+
ssl: 55002,
|
|
15
|
+
tcp: 55002,
|
|
16
|
+
protocol: 'ssl'
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
host: 'testnet.aranguren.org',
|
|
20
|
+
ssl: 51002,
|
|
21
|
+
tcp: 51001,
|
|
22
|
+
protocol: 'ssl'
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
host: 'blackie.c3-soft.com',
|
|
26
|
+
ssl: 57006,
|
|
27
|
+
tcp: 57006,
|
|
28
|
+
protocol: 'ssl'
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/electrum/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GACzB,oFAAoF,CAAC;AACzE,QAAA,aAAa,GAAG;IAC5B;QACC,IAAI,EAAE,qBAAqB;QAC3B,GAAG,EAAE,KAAK;QACV,GAAG,EAAE,KAAK;QACV,QAAQ,EAAE,KAAK;KACf;IACD;QACC,IAAI,EAAE,YAAY;QAClB,GAAG,EAAE,KAAK;QACV,GAAG,EAAE,KAAK;QACV,QAAQ,EAAE,KAAK;KACf;IACD;QACC,IAAI,EAAE,uBAAuB;QAC7B,GAAG,EAAE,KAAK;QACV,GAAG,EAAE,KAAK;QACV,QAAQ,EAAE,KAAK;KACf;IACD;QACC,IAAI,EAAE,qBAAqB;QAC3B,GAAG,EAAE,KAAK;QACV,GAAG,EAAE,KAAK;QACV,QAAQ,EAAE,KAAK;KACf;CACD,CAAC"}
|