├── .eslintignore ├── .eslintrc ├── .github └── workflows │ ├── lint-check.yml │ ├── tests.yml │ └── type-check.yml ├── .gitignore ├── .prettierrc ├── LICENSE ├── README.md ├── docker ├── docker-compose.yml └── electrs.toml ├── docs ├── html │ ├── .nojekyll │ ├── assets │ │ ├── highlight.css │ │ ├── main.js │ │ ├── search.js │ │ └── style.css │ ├── classes │ │ ├── Electrum.html │ │ ├── Transaction.html │ │ └── Wallet.html │ ├── enums │ │ ├── EAddressType.html │ │ ├── EAvailableNetworks.html │ │ ├── EBoostType.html │ │ ├── EElectrumNetworks.html │ │ ├── EFeeId.html │ │ ├── EPaymentType.html │ │ ├── EProtocol.html │ │ ├── EScanningStrategy.html │ │ └── EUnit.html │ ├── functions │ │ ├── availableNetworks.html │ │ ├── constructByteCountParam.html │ │ ├── decodeOpReturnMessage.html │ │ ├── decodeRawTransaction.html │ │ ├── err.html │ │ ├── filterAddressesForGapLimit.html │ │ ├── filterAddressesObjForGapLimit.html │ │ ├── filterAddressesObjForSingleIndex.html │ │ ├── filterAddressesObjForStartingIndex.html │ │ ├── formatKeyDerivationPath.html │ │ ├── formatPeerData.html │ │ ├── generateMnemonic.html │ │ ├── generateWalletId.html │ │ ├── getAddressFromKeyPair.html │ │ ├── getAddressFromScriptPubKey.html │ │ ├── getAddressIndexDiff.html │ │ ├── getAddressTypeFromPath.html │ │ ├── getAddressesFromPrivateKey.html │ │ ├── getByteCount.html │ │ ├── getDataFallback.html │ │ ├── getDefaultPort.html │ │ ├── getDefaultWalletData.html │ │ ├── getDefaultWalletDataKeys.html │ │ ├── getElectrumNetwork.html │ │ ├── getHighestUsedIndexFromTxHashes.html │ │ ├── getKeyDerivationPath.html │ │ ├── getKeyDerivationPathObject.html │ │ ├── getKeyDerivationPathString.html │ │ ├── getKeyValue.html │ │ ├── getPeers.html │ │ ├── getProtocolForPort.html │ │ ├── getScriptHash.html │ │ ├── getSeed.html │ │ ├── getSeedHash.html │ │ ├── getSha256.html │ │ ├── getStorageKeyValues.html │ │ ├── getTapRootAddressFromPublicKey.html │ │ ├── getTxFee.html │ │ ├── getWalletDataStorageKey.html │ │ ├── isP2trPrefix.html │ │ ├── isPositive.html │ │ ├── isValidBech32mEncodedString.html │ │ ├── objectKeys-1.html │ │ ├── objectsMatch.html │ │ ├── ok.html │ │ ├── parseOnChainPaymentRequest.html │ │ ├── reduceValue.html │ │ ├── removeDustOutputs.html │ │ ├── setReplaceByFee.html │ │ ├── shuffleArray.html │ │ ├── sleep.html │ │ ├── validateAddress.html │ │ ├── validateMnemonic.html │ │ └── validateTransaction.html │ ├── index.html │ ├── interfaces │ │ ├── IAddInput.html │ │ ├── IAddress.html │ │ ├── IAddressData.html │ │ ├── IAddressType.html │ │ ├── IAddressTypeData.html │ │ ├── IAddresses.html │ │ ├── IBoostedTransaction.html │ │ ├── IBoostedTransactions.html │ │ ├── ICreateTransaction.html │ │ ├── ICustomGetAddress.html │ │ ├── ICustomGetScriptHash.html │ │ ├── IElectrumGetAddressBalanceRes.html │ │ ├── IFormattedPeerData.html │ │ ├── IFormattedTransaction.html │ │ ├── IFormattedTransactions.html │ │ ├── IGenerateAddresses.html │ │ ├── IGenerateAddressesResponse.html │ │ ├── IGetAddress.html │ │ ├── IGetAddressBalanceRes.html │ │ ├── IGetAddressByPath.html │ │ ├── IGetAddressHistoryResponse.html │ │ ├── IGetAddressResponse.html │ │ ├── IGetAddressScriptHashBalances.html │ │ ├── IGetAddressScriptHashesHistoryResponse.html │ │ ├── IGetAddressTxResponse.html │ │ ├── IGetAddressesFromKeyPair.html │ │ ├── IGetAddressesFromPrivateKey.html │ │ ├── IGetDerivationPath.html │ │ ├── IGetFeeEstimatesResponse.html │ │ ├── IGetHeaderResponse.html │ │ ├── IGetNextAvailableAddressResponse.html │ │ ├── IGetTransactions.html │ │ ├── IGetTransactionsFromInputs.html │ │ ├── IGetUtxosResponse.html │ │ ├── IHeader.html │ │ ├── IIndexes.html │ │ ├── IKeyDerivationPath.html │ │ ├── IKeyDerivationPathData.html │ │ ├── INewBlock.html │ │ ├── IOnchainFees.html │ │ ├── IOutput.html │ │ ├── IPeerData.html │ │ ├── IPrivateKeyInfo.html │ │ ├── IRbfData.html │ │ ├── ISend.html │ │ ├── ISendTransaction.html │ │ ├── ISendTx.html │ │ ├── ISetupTransaction.html │ │ ├── ISubscribeToAddress.html │ │ ├── ISubscribeToHeader.html │ │ ├── ISweepPrivateKey.html │ │ ├── ISweepPrivateKeyRes.html │ │ ├── ITargets.html │ │ ├── ITransaction.html │ │ ├── ITxHash.html │ │ ├── ITxHashes.html │ │ ├── IUtxo.html │ │ ├── IVin.html │ │ ├── IVout.html │ │ ├── IWallet.html │ │ └── IWalletData.html │ ├── types │ │ ├── ElectrumConnectionPubSub.html │ │ ├── ElectrumConnectionSubscription.html │ │ ├── InputData.html │ │ ├── ObjectKeys.html │ │ ├── Result.html │ │ ├── TAddressIndexInfo.html │ │ ├── TAddressLabel.html │ │ ├── TAddressTxResponse.html │ │ ├── TAddressType.html │ │ ├── TAddressTypeContent.html │ │ ├── TAddressTypes.html │ │ ├── TAvailableNetworks.html │ │ ├── TConnectToElectrumRes.html │ │ ├── TDecodeRawTx.html │ │ ├── TElectrumNetworks.html │ │ ├── TGapLimitOptions.html │ │ ├── TGetAddressHistory.html │ │ ├── TGetByteCountInput.html │ │ ├── TGetByteCountInputs.html │ │ ├── TGetByteCountOutput.html │ │ ├── TGetByteCountOutputs.html │ │ ├── TGetData.html │ │ ├── TGetTotalFeeObj.html │ │ ├── TKeyDerivationAccount.html │ │ ├── TKeyDerivationChange.html │ │ ├── TKeyDerivationCoinType.html │ │ ├── TKeyDerivationIndex.html │ │ ├── TKeyDerivationPurpose.html │ │ ├── TMessageDataMap.html │ │ ├── TMessageKeys.html │ │ ├── TOnMessage.html │ │ ├── TProcessUnconfirmedTransactions.html │ │ ├── TProtocol.html │ │ ├── TServer.html │ │ ├── TSetData.html │ │ ├── TSetupTransactionResponse.html │ │ ├── TStorage.html │ │ ├── TSubscribedReceive.html │ │ ├── TTransactionMessage.html │ │ ├── TTxDetails.html │ │ ├── TTxResponse.html │ │ ├── TTxResult.html │ │ ├── TUnspentAddressScriptHashData.html │ │ └── TWalletDataKeys.html │ └── variables │ │ ├── defaultElectrumPorts.html │ │ └── electrumConnection.html └── markdown │ ├── .nojekyll │ ├── README.md │ ├── classes │ ├── Electrum.md │ ├── Transaction.md │ └── Wallet.md │ ├── enums │ ├── EAddressType.md │ ├── EAvailableNetworks.md │ ├── EBoostType.md │ ├── EElectrumNetworks.md │ ├── EFeeId.md │ ├── EPaymentType.md │ ├── EProtocol.md │ ├── EScanningStrategy.md │ └── EUnit.md │ └── interfaces │ ├── IAddInput.md │ ├── IAddress.md │ ├── IAddressData.md │ ├── IAddressType.md │ ├── IAddressTypeData.md │ ├── IAddresses.md │ ├── IBoostedTransaction.md │ ├── IBoostedTransactions.md │ ├── ICreateTransaction.md │ ├── ICustomGetAddress.md │ ├── ICustomGetScriptHash.md │ ├── IElectrumGetAddressBalanceRes.md │ ├── IFormattedPeerData.md │ ├── IFormattedTransaction.md │ ├── IFormattedTransactions.md │ ├── IGenerateAddresses.md │ ├── IGenerateAddressesResponse.md │ ├── IGetAddress.md │ ├── IGetAddressBalanceRes.md │ ├── IGetAddressByPath.md │ ├── IGetAddressHistoryResponse.md │ ├── IGetAddressResponse.md │ ├── IGetAddressScriptHashBalances.md │ ├── IGetAddressScriptHashesHistoryResponse.md │ ├── IGetAddressTxResponse.md │ ├── IGetAddressesFromKeyPair.md │ ├── IGetAddressesFromPrivateKey.md │ ├── IGetDerivationPath.md │ ├── IGetFeeEstimatesResponse.md │ ├── IGetHeaderResponse.md │ ├── IGetNextAvailableAddressResponse.md │ ├── IGetTransactions.md │ ├── IGetTransactionsFromInputs.md │ ├── IGetUtxosResponse.md │ ├── IHeader.md │ ├── IIndexes.md │ ├── IKeyDerivationPath.md │ ├── IKeyDerivationPathData.md │ ├── INewBlock.md │ ├── IOnchainFees.md │ ├── IOutput.md │ ├── IPeerData.md │ ├── IPrivateKeyInfo.md │ ├── IRbfData.md │ ├── ISend.md │ ├── ISendTransaction.md │ ├── ISendTx.md │ ├── ISetupTransaction.md │ ├── ISubscribeToAddress.md │ ├── ISubscribeToHeader.md │ ├── ISweepPrivateKey.md │ ├── ISweepPrivateKeyRes.md │ ├── ITargets.md │ ├── ITransaction.md │ ├── ITxHash.md │ ├── ITxHashes.md │ ├── IUtxo.md │ ├── IVin.md │ ├── IVout.md │ ├── IWallet.md │ └── IWalletData.md ├── example ├── helpers.ts └── index.ts ├── package-lock.json ├── package.json ├── src ├── electrum │ ├── constants.ts │ └── index.ts ├── index.ts ├── shapes │ ├── electrum.ts │ ├── index.ts │ └── wallet.ts ├── transaction │ └── index.ts ├── types │ ├── electrum.ts │ ├── index.ts │ ├── transaction.ts │ └── wallet.ts ├── utils │ ├── conversion.ts │ ├── derivation-path.ts │ ├── electrum.ts │ ├── helpers.ts │ ├── index.ts │ ├── result.ts │ ├── transaction.ts │ └── wallet.ts └── wallet │ ├── constants.ts │ └── index.ts ├── tests ├── boost.test.ts ├── constants.ts ├── derivation.test.ts ├── electrum.test.ts ├── expected-results.ts ├── receive.test.ts ├── storage.test.ts ├── transaction.test.ts ├── utils.ts └── wallet.test.ts ├── tsconfig.json └── typedoc.json /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | markdown 4 | html 5 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 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 | } 41 | -------------------------------------------------------------------------------- /.github/workflows/lint-check.yml: -------------------------------------------------------------------------------- 1 | name: lint-check 2 | 3 | on: 4 | workflow_dispatch: 5 | pull_request: 6 | 7 | jobs: 8 | lint: 9 | name: Run lint check 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - name: Check out Git repository 14 | uses: actions/checkout@v4 15 | with: 16 | fetch-depth: 1 17 | 18 | - name: Set up Node.js 19 | uses: actions/setup-node@v4 20 | with: 21 | node-version: 20 22 | cache: 'npm' 23 | 24 | - name: Install Node.js dependencies 25 | run: npm install || npm install 26 | 27 | - name: Lint check 28 | run: npm run lint:check 29 | -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: tests 2 | 3 | on: 4 | workflow_dispatch: 5 | pull_request: 6 | 7 | jobs: 8 | tests: 9 | name: Run unit tests 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - name: Check out Git repository 14 | uses: actions/checkout@v4 15 | with: 16 | fetch-depth: 1 17 | 18 | - name: Run regtest setup 19 | run: cd docker && docker compose up --quiet-pull -d 20 | 21 | - name: Wait for bitcoind 22 | run: | 23 | sudo apt install wait-for-it 24 | wait-for-it -h 127.0.0.1 -p 43782 -t 60 25 | 26 | - name: Wait for electrum server 27 | run: wait-for-it -h 127.0.0.1 -p 60001 -t 60 28 | 29 | - name: Set up Node.js 30 | uses: actions/setup-node@v4 31 | with: 32 | node-version: 20 33 | cache: 'npm' 34 | 35 | - name: Install Node.js dependencies 36 | run: npm install || npm install 37 | 38 | - name: Run Tests 39 | run: npm run test 40 | 41 | - name: Dump docker logs on failure 42 | if: failure() 43 | uses: jwalton/gh-docker-logs@v2 44 | -------------------------------------------------------------------------------- /.github/workflows/type-check.yml: -------------------------------------------------------------------------------- 1 | name: type-check 2 | 3 | on: 4 | workflow_dispatch: 5 | pull_request: 6 | 7 | jobs: 8 | typescript: 9 | name: Run type check 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - name: Check out Git repository 14 | uses: actions/checkout@v4 15 | with: 16 | fetch-depth: 1 17 | 18 | - name: Set up Node.js 19 | uses: actions/setup-node@v4 20 | with: 21 | node-version: 20 22 | cache: 'npm' 23 | 24 | - name: Install Node.js dependencies 25 | run: npm install || npm install 26 | 27 | - name: Type check 28 | run: npm run tsc:check 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # IDEs and editors 33 | .idea 34 | .project 35 | .classpath 36 | .c9/ 37 | *.launch 38 | .settings/ 39 | *.sublime-workspace 40 | 41 | # IDE - VSCode 42 | .vscode/* 43 | !.vscode/settings.json 44 | !.vscode/tasks.json 45 | !.vscode/launch.json 46 | !.vscode/extensions.json 47 | 48 | # misc 49 | .sass-cache 50 | connect.lock 51 | typings 52 | 53 | # Logs 54 | logs 55 | *.log 56 | npm-debug.log* 57 | yarn-debug.log* 58 | yarn-error.log* 59 | 60 | 61 | # Dependency directories 62 | node_modules/ 63 | jspm_packages/ 64 | 65 | # Optional npm cache directory 66 | .npm 67 | 68 | # Optional eslint cache 69 | .eslintcache 70 | 71 | # Optional REPL history 72 | .node_repl_history 73 | 74 | # Output of 'npm pack' 75 | *.tgz 76 | 77 | # Yarn Integrity file 78 | .yarn-integrity 79 | 80 | # dotenv environment variables file 81 | .env 82 | 83 | # next.js build output 84 | .next 85 | 86 | # Lerna 87 | lerna-debug.log 88 | 89 | # System Files 90 | .DS_Store 91 | Thumbs.db 92 | 93 | # Tests 94 | example/walletData 95 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "bracketSpacing": true, 3 | "bracketSameLine": true, 4 | "singleQuote": true, 5 | "trailingComma": "none", 6 | "useTabs": true, 7 | "tabWidth": 2, 8 | "semi": true 9 | } 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 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. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 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 | // View wallet data (addresses, indexes, utxos, transactions, etc.) 72 | const walletData = wallet.data; 73 | 74 | // Get receiving address 75 | const address = await wallet.getAddress(); 76 | 77 | // Get address balance 78 | const addressBalanceRes = await wallet.getAddressBalance(address); 79 | if (addressBalance.isErr()) return; 80 | const addressBalance = addressBalanceRes.value; 81 | 82 | // Get wallet balance 83 | const walletBalance = wallet.getBalance(); 84 | 85 | // Refresh Wallet 86 | const walletRefresh = await wallet.refreshWallet(); 87 | 88 | // Get fee information to perform a transaction. 89 | const feeInfo = wallet.getFeeInfo(); 90 | 91 | // Send sats 92 | const sendRes = await wallet.send({ address: 'address to send sats to', amount: 1000, satPerByte: 2 }); 93 | 94 | // Send all sats to an address 95 | const sendMaxRes = await wallet.sendMax({ address: 'address to send sats to', satPerByte: 2 }); 96 | ``` 97 | 98 | ## Advanced Usage 99 | 100 | ```typescript 101 | import { Wallet, generateMnemonic } from 'beignet'; 102 | import net from 'net' 103 | import tls from 'tls' 104 | import { TStorage } from './wallet'; 105 | import { ECoinSelectPreference } from "./transaction"; 106 | 107 | // Generate a mnemonic phrase 108 | const mnemonic = generateMnemonic(); 109 | 110 | // Add a bip39 passphrase 111 | const passphrase = 'passphrase'; 112 | 113 | // Connect to custom electrum server 114 | const servers: TServer = { 115 | host: '35.233.47.252', 116 | ssl: 18484, 117 | tcp: 18483, 118 | protocol: EProtocol.ssl, 119 | }; 120 | 121 | // Use a specific network (Defaults to mainnet) 122 | const network = ENetworks.mainnet; 123 | 124 | // Use a specific address type. (Defaults to EAddressType.p2wpkh) 125 | const addressType = EAddressType.p2tr; 126 | 127 | // Monitor certain address types. (Defaults to Object.values(EAddressType)) 128 | const addressTypesToMonitor = [EAddressType.p2tr, EAddressType.p2wpkh]; 129 | 130 | // Subscribe to server messages (TOnMessage) 131 | const onMessage: TOnMessage = (id, data) => { 132 | console.log(id); 133 | console.dir(data, { depth: null }); 134 | } 135 | 136 | // Disable startup messages. Messages resume once startup is complete. (Defaults to false) 137 | const disableMessagesOnCreate = true; 138 | 139 | // Persist sessions by getting and setting data from storage 140 | const storage: TStorage = { 141 | async getData( 142 | key: string 143 | ): Promise> { 144 | // Add your logic here 145 | }, 146 | async setData( 147 | key: string, 148 | value: IWalletData[K] 149 | ): Promise> { 150 | // Add your logic here 151 | } 152 | }; 153 | 154 | // Set the auto coin selection preference. (Defaults to ECoinSelectPreference.consolidate) 155 | const coinSelectPreference = ECoinSelectPreference.small; 156 | 157 | // Create a wallet instance 158 | const createWalletRes = await Wallet.create({ 159 | mnemonic, 160 | passphrase, 161 | electrumOptions: { 162 | servers, 163 | net, 164 | tls 165 | }, 166 | network, 167 | onMessage, 168 | storage, 169 | addressType, 170 | addressTypesToMonitor, 171 | disableMessagesOnCreate, 172 | coinSelectPreference 173 | }); 174 | if (createWalletRes.isErr()) return; 175 | const wallet = createWalletRes.value; 176 | 177 | // List UTXO's 178 | const utxos = wallet.listUtxos(); 179 | 180 | // Send sats to multiple outputs 181 | const txs = [ 182 | { address: 'address1', amount: 1000 }, 183 | { address: 'address2', amount: 2000 }, 184 | { address: 'address3', amount: 3000 }, 185 | ]; 186 | const sendManyRes = await wallet.sendMany({ txs }); 187 | 188 | // Sweep from a private key 189 | const sweepPrivateKeyRes = await wallet.sweepPrivateKey({ 190 | privateKey: 'privateKey', 191 | toAddress: 'toAddress', 192 | satsPerByte: 5, 193 | broadcast: false 194 | }); 195 | 196 | // Get tx history for a given address. { tx_hash: string; height: number; }[] 197 | const history = await wallet.getAddressHistory('address'); 198 | 199 | // Get transaction details for a given transaction id. TTxDetails 200 | const txDetails = await wallet.getTransactionDetails('txid'); 201 | ``` 202 | 203 | ## React Native 204 | 205 | You can use `react-native-tcp-socket` as a drop in replacement for `net` & `tls` in a react-native environment. In `package.json`: 206 | 207 | ```json 208 | "react-native": { 209 | "net": "react-native-tcp-socket", 210 | "tls": "react-native-tcp-socket" 211 | } 212 | ``` 213 | 214 | ## Documentation 215 | - [HTML](docs/html/classes/Wallet.html) 216 | - [Markdown](docs/markdown/classes/Wallet.md) 217 | 218 | ## Support 219 | 220 | If you are experiencing any problems, please open an issue or reach out to us on [Telegram](https://t.me/bitkitchat). 221 | -------------------------------------------------------------------------------- /docker/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | bitcoind: 3 | container_name: bitcoin 4 | image: btcpayserver/bitcoin:26.0 5 | restart: unless-stopped 6 | expose: 7 | - '43782' 8 | - '39388' 9 | ports: 10 | - '43782:43782' 11 | - '39388:39388' 12 | volumes: 13 | - 'bitcoin_home:/home/bitcoin/.bitcoin' 14 | environment: 15 | BITCOIN_NETWORK: ${NBITCOIN_NETWORK:-regtest} 16 | CREATE_WALLET: 'true' 17 | BITCOIN_WALLETDIR: '/walletdata' 18 | BITCOIN_EXTRA_ARGS: | 19 | rpcport=43782 20 | rpcbind=0.0.0.0:43782 21 | rpcallowip=0.0.0.0/0 22 | port=39388 23 | whitelist=0.0.0.0/0 24 | maxmempool=500 25 | rpcauth=polaruser:5e5e98c21f5c814568f8b55d83b23c1c$$066b03f92df30b11de8e4b1b1cd5b1b4281aa25205bd57df9be82caf97a05526 26 | txindex=1 27 | fallbackfee=0.00001 28 | zmqpubrawblock=tcp://0.0.0.0:28334 29 | zmqpubrawtx=tcp://0.0.0.0:28335 30 | zmqpubhashblock=tcp://0.0.0.0:28336 31 | 32 | bitcoinsetup: 33 | image: btcpayserver/bitcoin:26.0 34 | depends_on: 35 | - bitcoind 36 | restart: 'no' 37 | volumes: 38 | - 'bitcoin_home:/home/bitcoin/.bitcoin' 39 | user: bitcoin 40 | # generate one block so electrs stop complaining 41 | entrypoint: 42 | [ 43 | 'bash', 44 | '-c', 45 | 'sleep 1; while ! bitcoin-cli -rpcconnect=bitcoind -generate 1; do sleep 1; done', 46 | ] 47 | 48 | electrs: 49 | container_name: electrum 50 | image: getumbrel/electrs:v0.10.2 51 | restart: unless-stopped 52 | depends_on: 53 | - bitcoind 54 | expose: 55 | - '60001' 56 | - '28334' 57 | - '28335' 58 | - '28336' 59 | ports: 60 | - '60001:60001' 61 | # - '28334:28334' 62 | # - '28335:28335' 63 | # - '28336:28336' 64 | volumes: 65 | - './electrs.toml:/data/electrs.toml' 66 | environment: 67 | - ELECTRS_NETWORK=regtest 68 | - ELECTRS_ELECTRUM_RPC_ADDR=electrs:60001 69 | - ELECTRS_DAEMON_RPC_ADDR=bitcoind:43782 70 | - ELECTRS_DAEMON_P2P_ADDR=bitcoind:39388 71 | - ELECTRS_LOG_FILTERS=INFO 72 | 73 | 74 | volumes: 75 | bitcoin_home: 76 | 77 | networks: {} 78 | -------------------------------------------------------------------------------- /docker/electrs.toml: -------------------------------------------------------------------------------- 1 | auth = "polaruser:polarpass" 2 | -------------------------------------------------------------------------------- /docs/html/.nojekyll: -------------------------------------------------------------------------------- 1 | TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. -------------------------------------------------------------------------------- /docs/html/assets/highlight.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --light-code-background: #FFFFFF; 3 | --dark-code-background: #1E1E1E; 4 | } 5 | 6 | @media (prefers-color-scheme: light) { :root { 7 | --code-background: var(--light-code-background); 8 | } } 9 | 10 | @media (prefers-color-scheme: dark) { :root { 11 | --code-background: var(--dark-code-background); 12 | } } 13 | 14 | :root[data-theme='light'] { 15 | --code-background: var(--light-code-background); 16 | } 17 | 18 | :root[data-theme='dark'] { 19 | --code-background: var(--dark-code-background); 20 | } 21 | 22 | pre, code { background: var(--code-background); } 23 | -------------------------------------------------------------------------------- /docs/markdown/.nojekyll: -------------------------------------------------------------------------------- 1 | TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. -------------------------------------------------------------------------------- /docs/markdown/enums/EAddressType.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / EAddressType 2 | 3 | # Enumeration: EAddressType 4 | 5 | ## Table of contents 6 | 7 | ### Enumeration Members 8 | 9 | - [p2pkh](EAddressType.md#p2pkh) 10 | - [p2sh](EAddressType.md#p2sh) 11 | - [p2tr](EAddressType.md#p2tr) 12 | - [p2wpkh](EAddressType.md#p2wpkh) 13 | 14 | ## Enumeration Members 15 | 16 | ### p2pkh 17 | 18 | • **p2pkh** = ``"p2pkh"`` 19 | 20 | #### Defined in 21 | 22 | [types/wallet.ts:38](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L38) 23 | 24 | ___ 25 | 26 | ### p2sh 27 | 28 | • **p2sh** = ``"p2sh"`` 29 | 30 | #### Defined in 31 | 32 | [types/wallet.ts:37](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L37) 33 | 34 | ___ 35 | 36 | ### p2tr 37 | 38 | • **p2tr** = ``"p2tr"`` 39 | 40 | #### Defined in 41 | 42 | [types/wallet.ts:39](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L39) 43 | 44 | ___ 45 | 46 | ### p2wpkh 47 | 48 | • **p2wpkh** = ``"p2wpkh"`` 49 | 50 | #### Defined in 51 | 52 | [types/wallet.ts:36](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L36) 53 | -------------------------------------------------------------------------------- /docs/markdown/enums/EAvailableNetworks.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / EAvailableNetworks 2 | 3 | # Enumeration: EAvailableNetworks 4 | 5 | ## Table of contents 6 | 7 | ### Enumeration Members 8 | 9 | - [bitcoin](EAvailableNetworks.md#bitcoin) 10 | - [bitcoinMainnet](EAvailableNetworks.md#bitcoinmainnet) 11 | - [bitcoinRegtest](EAvailableNetworks.md#bitcoinregtest) 12 | - [bitcoinTestnet](EAvailableNetworks.md#bitcointestnet) 13 | - [mainnet](EAvailableNetworks.md#mainnet) 14 | - [regtest](EAvailableNetworks.md#regtest) 15 | - [testnet](EAvailableNetworks.md#testnet) 16 | 17 | ## Enumeration Members 18 | 19 | ### bitcoin 20 | 21 | • **bitcoin** = ``"bitcoin"`` 22 | 23 | #### Defined in 24 | 25 | [types/wallet.ts:27](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L27) 26 | 27 | ___ 28 | 29 | ### bitcoinMainnet 30 | 31 | • **bitcoinMainnet** = ``"bitcoin"`` 32 | 33 | #### Defined in 34 | 35 | [types/wallet.ts:29](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L29) 36 | 37 | ___ 38 | 39 | ### bitcoinRegtest 40 | 41 | • **bitcoinRegtest** = ``"regtest"`` 42 | 43 | #### Defined in 44 | 45 | [types/wallet.ts:33](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L33) 46 | 47 | ___ 48 | 49 | ### bitcoinTestnet 50 | 51 | • **bitcoinTestnet** = ``"testnet"`` 52 | 53 | #### Defined in 54 | 55 | [types/wallet.ts:31](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L31) 56 | 57 | ___ 58 | 59 | ### mainnet 60 | 61 | • **mainnet** = ``"bitcoin"`` 62 | 63 | #### Defined in 64 | 65 | [types/wallet.ts:28](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L28) 66 | 67 | ___ 68 | 69 | ### regtest 70 | 71 | • **regtest** = ``"regtest"`` 72 | 73 | #### Defined in 74 | 75 | [types/wallet.ts:32](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L32) 76 | 77 | ___ 78 | 79 | ### testnet 80 | 81 | • **testnet** = ``"testnet"`` 82 | 83 | #### Defined in 84 | 85 | [types/wallet.ts:30](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L30) 86 | -------------------------------------------------------------------------------- /docs/markdown/enums/EBoostType.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / EBoostType 2 | 3 | # Enumeration: EBoostType 4 | 5 | ## Table of contents 6 | 7 | ### Enumeration Members 8 | 9 | - [cpfp](EBoostType.md#cpfp) 10 | - [rbf](EBoostType.md#rbf) 11 | 12 | ## Enumeration Members 13 | 14 | ### cpfp 15 | 16 | • **cpfp** = ``"cpfp"`` 17 | 18 | #### Defined in 19 | 20 | [types/wallet.ts:119](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L119) 21 | 22 | ___ 23 | 24 | ### rbf 25 | 26 | • **rbf** = ``"rbf"`` 27 | 28 | #### Defined in 29 | 30 | [types/wallet.ts:118](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L118) 31 | -------------------------------------------------------------------------------- /docs/markdown/enums/EElectrumNetworks.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / EElectrumNetworks 2 | 3 | # Enumeration: EElectrumNetworks 4 | 5 | ## Table of contents 6 | 7 | ### Enumeration Members 8 | 9 | - [bitcoin](EElectrumNetworks.md#bitcoin) 10 | - [bitcoinRegtest](EElectrumNetworks.md#bitcoinregtest) 11 | - [bitcoinTestnet](EElectrumNetworks.md#bitcointestnet) 12 | 13 | ## Enumeration Members 14 | 15 | ### bitcoin 16 | 17 | • **bitcoin** = ``"bitcoin"`` 18 | 19 | #### Defined in 20 | 21 | [types/electrum.ts:11](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L11) 22 | 23 | ___ 24 | 25 | ### bitcoinRegtest 26 | 27 | • **bitcoinRegtest** = ``"bitcoinRegtest"`` 28 | 29 | #### Defined in 30 | 31 | [types/electrum.ts:13](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L13) 32 | 33 | ___ 34 | 35 | ### bitcoinTestnet 36 | 37 | • **bitcoinTestnet** = ``"bitcoinTestnet"`` 38 | 39 | #### Defined in 40 | 41 | [types/electrum.ts:12](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L12) 42 | -------------------------------------------------------------------------------- /docs/markdown/enums/EFeeId.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / EFeeId 2 | 3 | # Enumeration: EFeeId 4 | 5 | ## Table of contents 6 | 7 | ### Enumeration Members 8 | 9 | - [custom](EFeeId.md#custom) 10 | - [fast](EFeeId.md#fast) 11 | - [none](EFeeId.md#none) 12 | - [normal](EFeeId.md#normal) 13 | - [slow](EFeeId.md#slow) 14 | 15 | ## Enumeration Members 16 | 17 | ### custom 18 | 19 | • **custom** = ``"custom"`` 20 | 21 | #### Defined in 22 | 23 | [types/transaction.ts:37](https://github.com/synonymdev/beignet/blob/3144d66/src/types/transaction.ts#L37) 24 | 25 | ___ 26 | 27 | ### fast 28 | 29 | • **fast** = ``"fast"`` 30 | 31 | #### Defined in 32 | 33 | [types/transaction.ts:34](https://github.com/synonymdev/beignet/blob/3144d66/src/types/transaction.ts#L34) 34 | 35 | ___ 36 | 37 | ### none 38 | 39 | • **none** = ``"none"`` 40 | 41 | #### Defined in 42 | 43 | [types/transaction.ts:38](https://github.com/synonymdev/beignet/blob/3144d66/src/types/transaction.ts#L38) 44 | 45 | ___ 46 | 47 | ### normal 48 | 49 | • **normal** = ``"normal"`` 50 | 51 | #### Defined in 52 | 53 | [types/transaction.ts:35](https://github.com/synonymdev/beignet/blob/3144d66/src/types/transaction.ts#L35) 54 | 55 | ___ 56 | 57 | ### slow 58 | 59 | • **slow** = ``"slow"`` 60 | 61 | #### Defined in 62 | 63 | [types/transaction.ts:36](https://github.com/synonymdev/beignet/blob/3144d66/src/types/transaction.ts#L36) 64 | -------------------------------------------------------------------------------- /docs/markdown/enums/EPaymentType.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / EPaymentType 2 | 3 | # Enumeration: EPaymentType 4 | 5 | ## Table of contents 6 | 7 | ### Enumeration Members 8 | 9 | - [received](EPaymentType.md#received) 10 | - [sent](EPaymentType.md#sent) 11 | 12 | ## Enumeration Members 13 | 14 | ### received 15 | 16 | • **received** = ``"received"`` 17 | 18 | #### Defined in 19 | 20 | [types/wallet.ts:45](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L45) 21 | 22 | ___ 23 | 24 | ### sent 25 | 26 | • **sent** = ``"sent"`` 27 | 28 | #### Defined in 29 | 30 | [types/wallet.ts:44](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L44) 31 | -------------------------------------------------------------------------------- /docs/markdown/enums/EProtocol.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / EProtocol 2 | 3 | # Enumeration: EProtocol 4 | 5 | ## Table of contents 6 | 7 | ### Enumeration Members 8 | 9 | - [ssl](EProtocol.md#ssl) 10 | - [tcp](EProtocol.md#tcp) 11 | 12 | ## Enumeration Members 13 | 14 | ### ssl 15 | 16 | • **ssl** = ``"ssl"`` 17 | 18 | #### Defined in 19 | 20 | [types/electrum.ts:30](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L30) 21 | 22 | ___ 23 | 24 | ### tcp 25 | 26 | • **tcp** = ``"tcp"`` 27 | 28 | #### Defined in 29 | 30 | [types/electrum.ts:29](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L29) 31 | -------------------------------------------------------------------------------- /docs/markdown/enums/EScanningStrategy.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / EScanningStrategy 2 | 3 | # Enumeration: EScanningStrategy 4 | 5 | ## Table of contents 6 | 7 | ### Enumeration Members 8 | 9 | - [all](EScanningStrategy.md#all) 10 | - [gapLimit](EScanningStrategy.md#gaplimit) 11 | - [singleIndex](EScanningStrategy.md#singleindex) 12 | - [startingIndex](EScanningStrategy.md#startingindex) 13 | 14 | ## Enumeration Members 15 | 16 | ### all 17 | 18 | • **all** = ``"all"`` 19 | 20 | #### Defined in 21 | 22 | [types/electrum.ts:34](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L34) 23 | 24 | ___ 25 | 26 | ### gapLimit 27 | 28 | • **gapLimit** = ``"gapLimit"`` 29 | 30 | #### Defined in 31 | 32 | [types/electrum.ts:35](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L35) 33 | 34 | ___ 35 | 36 | ### singleIndex 37 | 38 | • **singleIndex** = ``"singleIndex"`` 39 | 40 | #### Defined in 41 | 42 | [types/electrum.ts:37](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L37) 43 | 44 | ___ 45 | 46 | ### startingIndex 47 | 48 | • **startingIndex** = ``"startingIndex"`` 49 | 50 | #### Defined in 51 | 52 | [types/electrum.ts:36](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L36) 53 | -------------------------------------------------------------------------------- /docs/markdown/enums/EUnit.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / EUnit 2 | 3 | # Enumeration: EUnit 4 | 5 | ## Table of contents 6 | 7 | ### Enumeration Members 8 | 9 | - [BTC](EUnit.md#btc) 10 | - [fiat](EUnit.md#fiat) 11 | - [satoshi](EUnit.md#satoshi) 12 | 13 | ## Enumeration Members 14 | 15 | ### BTC 16 | 17 | • **BTC** = ``"BTC"`` 18 | 19 | #### Defined in 20 | 21 | [types/wallet.ts:379](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L379) 22 | 23 | ___ 24 | 25 | ### fiat 26 | 27 | • **fiat** = ``"fiat"`` 28 | 29 | #### Defined in 30 | 31 | [types/wallet.ts:380](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L380) 32 | 33 | ___ 34 | 35 | ### satoshi 36 | 37 | • **satoshi** = ``"satoshi"`` 38 | 39 | #### Defined in 40 | 41 | [types/wallet.ts:378](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L378) 42 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IAddInput.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IAddInput 2 | 3 | # Interface: IAddInput 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [input](IAddInput.md#input) 10 | - [keyPair](IAddInput.md#keypair) 11 | - [psbt](IAddInput.md#psbt) 12 | 13 | ## Properties 14 | 15 | ### input 16 | 17 | • **input**: [`IUtxo`](IUtxo.md) 18 | 19 | #### Defined in 20 | 21 | [types/transaction.ts:15](https://github.com/synonymdev/beignet/blob/3144d66/src/types/transaction.ts#L15) 22 | 23 | ___ 24 | 25 | ### keyPair 26 | 27 | • **keyPair**: `BIP32Interface` \| `ECPairInterface` 28 | 29 | #### Defined in 30 | 31 | [types/transaction.ts:14](https://github.com/synonymdev/beignet/blob/3144d66/src/types/transaction.ts#L14) 32 | 33 | ___ 34 | 35 | ### psbt 36 | 37 | • **psbt**: `Psbt` 38 | 39 | #### Defined in 40 | 41 | [types/transaction.ts:13](https://github.com/synonymdev/beignet/blob/3144d66/src/types/transaction.ts#L13) 42 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IAddress.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IAddress 2 | 3 | # Interface: IAddress 4 | 5 | ## Hierarchy 6 | 7 | - **`IAddress`** 8 | 9 | ↳ [`IGetAddressHistoryResponse`](IGetAddressHistoryResponse.md) 10 | 11 | ## Table of contents 12 | 13 | ### Properties 14 | 15 | - [address](IAddress.md#address) 16 | - [index](IAddress.md#index) 17 | - [path](IAddress.md#path) 18 | - [publicKey](IAddress.md#publickey) 19 | - [scriptHash](IAddress.md#scripthash) 20 | 21 | ## Properties 22 | 23 | ### address 24 | 25 | • **address**: `string` 26 | 27 | #### Defined in 28 | 29 | [types/wallet.ts:148](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L148) 30 | 31 | ___ 32 | 33 | ### index 34 | 35 | • **index**: `number` 36 | 37 | #### Defined in 38 | 39 | [types/wallet.ts:146](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L146) 40 | 41 | ___ 42 | 43 | ### path 44 | 45 | • **path**: `string` 46 | 47 | #### Defined in 48 | 49 | [types/wallet.ts:147](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L147) 50 | 51 | ___ 52 | 53 | ### publicKey 54 | 55 | • **publicKey**: `string` 56 | 57 | #### Defined in 58 | 59 | [types/wallet.ts:150](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L150) 60 | 61 | ___ 62 | 63 | ### scriptHash 64 | 65 | • **scriptHash**: `string` 66 | 67 | #### Defined in 68 | 69 | [types/wallet.ts:149](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L149) 70 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IAddressData.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IAddressData 2 | 3 | # Interface: IAddressData 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [label](IAddressData.md#label) 10 | - [path](IAddressData.md#path) 11 | - [type](IAddressData.md#type) 12 | 13 | ## Properties 14 | 15 | ### label 16 | 17 | • **label**: `string` 18 | 19 | #### Defined in 20 | 21 | [types/wallet.ts:219](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L219) 22 | 23 | ___ 24 | 25 | ### path 26 | 27 | • **path**: `string` 28 | 29 | #### Defined in 30 | 31 | [types/wallet.ts:217](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L217) 32 | 33 | ___ 34 | 35 | ### type 36 | 37 | • **type**: ``"p2wpkh"`` \| ``"p2sh"`` \| ``"p2pkh"`` 38 | 39 | #### Defined in 40 | 41 | [types/wallet.ts:218](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L218) 42 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IAddressType.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IAddressType 2 | 3 | # Interface: IAddressType 4 | 5 | ## Indexable 6 | 7 | ▪ [key: `string`]: [`IAddressData`](IAddressData.md) 8 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IAddressTypeData.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IAddressTypeData 2 | 3 | # Interface: IAddressTypeData 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [description](IAddressTypeData.md#description) 10 | - [example](IAddressTypeData.md#example) 11 | - [name](IAddressTypeData.md#name) 12 | - [path](IAddressTypeData.md#path) 13 | - [shortName](IAddressTypeData.md#shortname) 14 | - [type](IAddressTypeData.md#type) 15 | 16 | ## Properties 17 | 18 | ### description 19 | 20 | • **description**: `string` 21 | 22 | #### Defined in 23 | 24 | [types/wallet.ts:57](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L57) 25 | 26 | ___ 27 | 28 | ### example 29 | 30 | • **example**: `string` 31 | 32 | #### Defined in 33 | 34 | [types/wallet.ts:58](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L58) 35 | 36 | ___ 37 | 38 | ### name 39 | 40 | • **name**: `string` 41 | 42 | #### Defined in 43 | 44 | [types/wallet.ts:55](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L55) 45 | 46 | ___ 47 | 48 | ### path 49 | 50 | • **path**: `string` 51 | 52 | #### Defined in 53 | 54 | [types/wallet.ts:54](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L54) 55 | 56 | ___ 57 | 58 | ### shortName 59 | 60 | • **shortName**: `string` 61 | 62 | #### Defined in 63 | 64 | [types/wallet.ts:56](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L56) 65 | 66 | ___ 67 | 68 | ### type 69 | 70 | • **type**: [`EAddressType`](../enums/EAddressType.md) 71 | 72 | #### Defined in 73 | 74 | [types/wallet.ts:53](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L53) 75 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IAddresses.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IAddresses 2 | 3 | # Interface: IAddresses 4 | 5 | ## Indexable 6 | 7 | ▪ [scriptHash: `string`]: [`IAddress`](IAddress.md) 8 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IBoostedTransaction.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IBoostedTransaction 2 | 3 | # Interface: IBoostedTransaction 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [childTransaction](IBoostedTransaction.md#childtransaction) 10 | - [fee](IBoostedTransaction.md#fee) 11 | - [parentTransactions](IBoostedTransaction.md#parenttransactions) 12 | - [type](IBoostedTransaction.md#type) 13 | 14 | ## Properties 15 | 16 | ### childTransaction 17 | 18 | • **childTransaction**: `string` 19 | 20 | #### Defined in 21 | 22 | [types/wallet.ts:500](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L500) 23 | 24 | ___ 25 | 26 | ### fee 27 | 28 | • **fee**: `number` 29 | 30 | #### Defined in 31 | 32 | [types/wallet.ts:502](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L502) 33 | 34 | ___ 35 | 36 | ### parentTransactions 37 | 38 | • **parentTransactions**: `string`[] 39 | 40 | #### Defined in 41 | 42 | [types/wallet.ts:499](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L499) 43 | 44 | ___ 45 | 46 | ### type 47 | 48 | • **type**: [`EBoostType`](../enums/EBoostType.md) 49 | 50 | #### Defined in 51 | 52 | [types/wallet.ts:501](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L501) 53 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IBoostedTransactions.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IBoostedTransactions 2 | 3 | # Interface: IBoostedTransactions 4 | 5 | ## Indexable 6 | 7 | ▪ [txId: `string`]: [`IBoostedTransaction`](IBoostedTransaction.md) 8 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/ICreateTransaction.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / ICreateTransaction 2 | 3 | # Interface: ICreateTransaction 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [shuffleOutputs](ICreateTransaction.md#shuffleoutputs) 10 | - [transactionData](ICreateTransaction.md#transactiondata) 11 | 12 | ## Properties 13 | 14 | ### shuffleOutputs 15 | 16 | • `Optional` **shuffleOutputs**: `boolean` 17 | 18 | #### Defined in 19 | 20 | [types/transaction.ts:9](https://github.com/synonymdev/beignet/blob/3144d66/src/types/transaction.ts#L9) 21 | 22 | ___ 23 | 24 | ### transactionData 25 | 26 | • `Optional` **transactionData**: [`ISendTransaction`](ISendTransaction.md) 27 | 28 | #### Defined in 29 | 30 | [types/transaction.ts:8](https://github.com/synonymdev/beignet/blob/3144d66/src/types/transaction.ts#L8) 31 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/ICustomGetAddress.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / ICustomGetAddress 2 | 3 | # Interface: ICustomGetAddress 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [path](ICustomGetAddress.md#path) 10 | - [selectedNetwork](ICustomGetAddress.md#selectednetwork) 11 | - [type](ICustomGetAddress.md#type) 12 | 13 | ## Properties 14 | 15 | ### path 16 | 17 | • **path**: `string` 18 | 19 | #### Defined in 20 | 21 | [types/wallet.ts:246](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L246) 22 | 23 | ___ 24 | 25 | ### selectedNetwork 26 | 27 | • **selectedNetwork**: [`EElectrumNetworks`](../enums/EElectrumNetworks.md) 28 | 29 | #### Defined in 30 | 31 | [types/wallet.ts:248](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L248) 32 | 33 | ___ 34 | 35 | ### type 36 | 37 | • **type**: [`EAddressType`](../enums/EAddressType.md) 38 | 39 | #### Defined in 40 | 41 | [types/wallet.ts:247](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L247) 42 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/ICustomGetScriptHash.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / ICustomGetScriptHash 2 | 3 | # Interface: ICustomGetScriptHash 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [address](ICustomGetScriptHash.md#address) 10 | - [selectedNetwork](ICustomGetScriptHash.md#selectednetwork) 11 | 12 | ## Properties 13 | 14 | ### address 15 | 16 | • **address**: `string` 17 | 18 | #### Defined in 19 | 20 | [types/wallet.ts:252](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L252) 21 | 22 | ___ 23 | 24 | ### selectedNetwork 25 | 26 | • **selectedNetwork**: [`EElectrumNetworks`](../enums/EElectrumNetworks.md) 27 | 28 | #### Defined in 29 | 30 | [types/wallet.ts:253](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L253) 31 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IElectrumGetAddressBalanceRes.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IElectrumGetAddressBalanceRes 2 | 3 | # Interface: IElectrumGetAddressBalanceRes 4 | 5 | ## Hierarchy 6 | 7 | - [`IGetAddressBalanceRes`](IGetAddressBalanceRes.md) 8 | 9 | ↳ **`IElectrumGetAddressBalanceRes`** 10 | 11 | ## Table of contents 12 | 13 | ### Properties 14 | 15 | - [confirmed](IElectrumGetAddressBalanceRes.md#confirmed) 16 | - [error](IElectrumGetAddressBalanceRes.md#error) 17 | - [unconfirmed](IElectrumGetAddressBalanceRes.md#unconfirmed) 18 | 19 | ## Properties 20 | 21 | ### confirmed 22 | 23 | • **confirmed**: `number` 24 | 25 | #### Inherited from 26 | 27 | [IGetAddressBalanceRes](IGetAddressBalanceRes.md).[confirmed](IGetAddressBalanceRes.md#confirmed) 28 | 29 | #### Defined in 30 | 31 | [types/wallet.ts:262](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L262) 32 | 33 | ___ 34 | 35 | ### error 36 | 37 | • **error**: `boolean` 38 | 39 | #### Defined in 40 | 41 | [types/electrum.ts:18](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L18) 42 | 43 | ___ 44 | 45 | ### unconfirmed 46 | 47 | • **unconfirmed**: `number` 48 | 49 | #### Inherited from 50 | 51 | [IGetAddressBalanceRes](IGetAddressBalanceRes.md).[unconfirmed](IGetAddressBalanceRes.md#unconfirmed) 52 | 53 | #### Defined in 54 | 55 | [types/wallet.ts:263](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L263) 56 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IFormattedPeerData.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IFormattedPeerData 2 | 3 | # Interface: IFormattedPeerData 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [host](IFormattedPeerData.md#host) 10 | - [ip](IFormattedPeerData.md#ip) 11 | - [ssl](IFormattedPeerData.md#ssl) 12 | - [tcp](IFormattedPeerData.md#tcp) 13 | - [version](IFormattedPeerData.md#version) 14 | 15 | ## Properties 16 | 17 | ### host 18 | 19 | • **host**: `string` 20 | 21 | #### Defined in 22 | 23 | [types/electrum.ts:162](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L162) 24 | 25 | ___ 26 | 27 | ### ip 28 | 29 | • `Optional` **ip**: `string` 30 | 31 | #### Defined in 32 | 33 | [types/electrum.ts:161](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L161) 34 | 35 | ___ 36 | 37 | ### ssl 38 | 39 | • **ssl**: `string` \| `number` 40 | 41 | #### Defined in 42 | 43 | [types/electrum.ts:164](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L164) 44 | 45 | ___ 46 | 47 | ### tcp 48 | 49 | • **tcp**: `string` \| `number` 50 | 51 | #### Defined in 52 | 53 | [types/electrum.ts:165](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L165) 54 | 55 | ___ 56 | 57 | ### version 58 | 59 | • `Optional` **version**: `string` 60 | 61 | #### Defined in 62 | 63 | [types/electrum.ts:163](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L163) 64 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IFormattedTransaction.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IFormattedTransaction 2 | 3 | # Interface: IFormattedTransaction 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [address](IFormattedTransaction.md#address) 10 | - [confirmTimestamp](IFormattedTransaction.md#confirmtimestamp) 11 | - [exists](IFormattedTransaction.md#exists) 12 | - [fee](IFormattedTransaction.md#fee) 13 | - [height](IFormattedTransaction.md#height) 14 | - [matchedInputValue](IFormattedTransaction.md#matchedinputvalue) 15 | - [matchedOutputValue](IFormattedTransaction.md#matchedoutputvalue) 16 | - [messages](IFormattedTransaction.md#messages) 17 | - [rbf](IFormattedTransaction.md#rbf) 18 | - [satsPerByte](IFormattedTransaction.md#satsperbyte) 19 | - [scriptHash](IFormattedTransaction.md#scripthash) 20 | - [timestamp](IFormattedTransaction.md#timestamp) 21 | - [totalInputValue](IFormattedTransaction.md#totalinputvalue) 22 | - [totalOutputValue](IFormattedTransaction.md#totaloutputvalue) 23 | - [txid](IFormattedTransaction.md#txid) 24 | - [type](IFormattedTransaction.md#type) 25 | - [value](IFormattedTransaction.md#value) 26 | - [vin](IFormattedTransaction.md#vin) 27 | - [vsize](IFormattedTransaction.md#vsize) 28 | 29 | ## Properties 30 | 31 | ### address 32 | 33 | • **address**: `string` 34 | 35 | #### Defined in 36 | 37 | [types/wallet.ts:86](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L86) 38 | 39 | ___ 40 | 41 | ### confirmTimestamp 42 | 43 | • `Optional` **confirmTimestamp**: `number` 44 | 45 | #### Defined in 46 | 47 | [types/wallet.ts:101](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L101) 48 | 49 | ___ 50 | 51 | ### exists 52 | 53 | • `Optional` **exists**: `boolean` 54 | 55 | #### Defined in 56 | 57 | [types/wallet.ts:102](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L102) 58 | 59 | ___ 60 | 61 | ### fee 62 | 63 | • **fee**: `number` 64 | 65 | #### Defined in 66 | 67 | [types/wallet.ts:93](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L93) 68 | 69 | ___ 70 | 71 | ### height 72 | 73 | • **height**: `number` 74 | 75 | #### Defined in 76 | 77 | [types/wallet.ts:87](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L87) 78 | 79 | ___ 80 | 81 | ### matchedInputValue 82 | 83 | • **matchedInputValue**: `number` 84 | 85 | #### Defined in 86 | 87 | [types/wallet.ts:90](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L90) 88 | 89 | ___ 90 | 91 | ### matchedOutputValue 92 | 93 | • **matchedOutputValue**: `number` 94 | 95 | #### Defined in 96 | 97 | [types/wallet.ts:92](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L92) 98 | 99 | ___ 100 | 101 | ### messages 102 | 103 | • **messages**: `string`[] 104 | 105 | #### Defined in 106 | 107 | [types/wallet.ts:98](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L98) 108 | 109 | ___ 110 | 111 | ### rbf 112 | 113 | • `Optional` **rbf**: `boolean` 114 | 115 | #### Defined in 116 | 117 | [types/wallet.ts:103](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L103) 118 | 119 | ___ 120 | 121 | ### satsPerByte 122 | 123 | • **satsPerByte**: `number` 124 | 125 | #### Defined in 126 | 127 | [types/wallet.ts:94](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L94) 128 | 129 | ___ 130 | 131 | ### scriptHash 132 | 133 | • **scriptHash**: `string` 134 | 135 | #### Defined in 136 | 137 | [types/wallet.ts:88](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L88) 138 | 139 | ___ 140 | 141 | ### timestamp 142 | 143 | • **timestamp**: `number` 144 | 145 | #### Defined in 146 | 147 | [types/wallet.ts:100](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L100) 148 | 149 | ___ 150 | 151 | ### totalInputValue 152 | 153 | • **totalInputValue**: `number` 154 | 155 | #### Defined in 156 | 157 | [types/wallet.ts:89](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L89) 158 | 159 | ___ 160 | 161 | ### totalOutputValue 162 | 163 | • **totalOutputValue**: `number` 164 | 165 | #### Defined in 166 | 167 | [types/wallet.ts:91](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L91) 168 | 169 | ___ 170 | 171 | ### txid 172 | 173 | • **txid**: `string` 174 | 175 | #### Defined in 176 | 177 | [types/wallet.ts:97](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L97) 178 | 179 | ___ 180 | 181 | ### type 182 | 183 | • **type**: [`EPaymentType`](../enums/EPaymentType.md) 184 | 185 | #### Defined in 186 | 187 | [types/wallet.ts:95](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L95) 188 | 189 | ___ 190 | 191 | ### value 192 | 193 | • **value**: `number` 194 | 195 | #### Defined in 196 | 197 | [types/wallet.ts:96](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L96) 198 | 199 | ___ 200 | 201 | ### vin 202 | 203 | • **vin**: [`IVin`](IVin.md)[] 204 | 205 | #### Defined in 206 | 207 | [types/wallet.ts:99](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L99) 208 | 209 | ___ 210 | 211 | ### vsize 212 | 213 | • **vsize**: `number` 214 | 215 | #### Defined in 216 | 217 | [types/wallet.ts:104](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L104) 218 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IFormattedTransactions.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IFormattedTransactions 2 | 3 | # Interface: IFormattedTransactions 4 | 5 | ## Indexable 6 | 7 | ▪ [key: `string`]: [`IFormattedTransaction`](IFormattedTransaction.md) 8 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IGenerateAddresses.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IGenerateAddresses 2 | 3 | # Interface: IGenerateAddresses 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [addressAmount](IGenerateAddresses.md#addressamount) 10 | - [addressIndex](IGenerateAddresses.md#addressindex) 11 | - [addressType](IGenerateAddresses.md#addresstype) 12 | - [changeAddressAmount](IGenerateAddresses.md#changeaddressamount) 13 | - [changeAddressIndex](IGenerateAddresses.md#changeaddressindex) 14 | - [keyDerivationPath](IGenerateAddresses.md#keyderivationpath) 15 | - [saveAddresses](IGenerateAddresses.md#saveaddresses) 16 | 17 | ## Properties 18 | 19 | ### addressAmount 20 | 21 | • `Optional` **addressAmount**: `number` 22 | 23 | #### Defined in 24 | 25 | [types/wallet.ts:267](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L267) 26 | 27 | ___ 28 | 29 | ### addressIndex 30 | 31 | • `Optional` **addressIndex**: `number` 32 | 33 | #### Defined in 34 | 35 | [types/wallet.ts:269](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L269) 36 | 37 | ___ 38 | 39 | ### addressType 40 | 41 | • `Optional` **addressType**: [`EAddressType`](../enums/EAddressType.md) 42 | 43 | #### Defined in 44 | 45 | [types/wallet.ts:272](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L272) 46 | 47 | ___ 48 | 49 | ### changeAddressAmount 50 | 51 | • `Optional` **changeAddressAmount**: `number` 52 | 53 | #### Defined in 54 | 55 | [types/wallet.ts:268](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L268) 56 | 57 | ___ 58 | 59 | ### changeAddressIndex 60 | 61 | • `Optional` **changeAddressIndex**: `number` 62 | 63 | #### Defined in 64 | 65 | [types/wallet.ts:270](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L270) 66 | 67 | ___ 68 | 69 | ### keyDerivationPath 70 | 71 | • `Optional` **keyDerivationPath**: [`IKeyDerivationPath`](IKeyDerivationPath.md) 72 | 73 | #### Defined in 74 | 75 | [types/wallet.ts:271](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L271) 76 | 77 | ___ 78 | 79 | ### saveAddresses 80 | 81 | • `Optional` **saveAddresses**: `boolean` 82 | 83 | #### Defined in 84 | 85 | [types/wallet.ts:273](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L273) 86 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IGenerateAddressesResponse.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IGenerateAddressesResponse 2 | 3 | # Interface: IGenerateAddressesResponse 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [addresses](IGenerateAddressesResponse.md#addresses) 10 | - [changeAddresses](IGenerateAddressesResponse.md#changeaddresses) 11 | 12 | ## Properties 13 | 14 | ### addresses 15 | 16 | • **addresses**: [`IAddresses`](IAddresses.md) 17 | 18 | #### Defined in 19 | 20 | [types/wallet.ts:282](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L282) 21 | 22 | ___ 23 | 24 | ### changeAddresses 25 | 26 | • **changeAddresses**: [`IAddresses`](IAddresses.md) 27 | 28 | #### Defined in 29 | 30 | [types/wallet.ts:283](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L283) 31 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IGetAddress.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IGetAddress 2 | 3 | # Interface: IGetAddress 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [addressType](IGetAddress.md#addresstype) 10 | - [changeAddress](IGetAddress.md#changeaddress) 11 | - [index](IGetAddress.md#index) 12 | 13 | ## Properties 14 | 15 | ### addressType 16 | 17 | • `Optional` **addressType**: [`EAddressType`](../enums/EAddressType.md) 18 | 19 | #### Defined in 20 | 21 | [types/wallet.ts:242](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L242) 22 | 23 | ___ 24 | 25 | ### changeAddress 26 | 27 | • `Optional` **changeAddress**: `boolean` 28 | 29 | #### Defined in 30 | 31 | [types/wallet.ts:241](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L241) 32 | 33 | ___ 34 | 35 | ### index 36 | 37 | • `Optional` **index**: `string` 38 | 39 | #### Defined in 40 | 41 | [types/wallet.ts:240](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L240) 42 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IGetAddressBalanceRes.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IGetAddressBalanceRes 2 | 3 | # Interface: IGetAddressBalanceRes 4 | 5 | ## Hierarchy 6 | 7 | - **`IGetAddressBalanceRes`** 8 | 9 | ↳ [`IElectrumGetAddressBalanceRes`](IElectrumGetAddressBalanceRes.md) 10 | 11 | ## Table of contents 12 | 13 | ### Properties 14 | 15 | - [confirmed](IGetAddressBalanceRes.md#confirmed) 16 | - [unconfirmed](IGetAddressBalanceRes.md#unconfirmed) 17 | 18 | ## Properties 19 | 20 | ### confirmed 21 | 22 | • **confirmed**: `number` 23 | 24 | #### Defined in 25 | 26 | [types/wallet.ts:262](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L262) 27 | 28 | ___ 29 | 30 | ### unconfirmed 31 | 32 | • **unconfirmed**: `number` 33 | 34 | #### Defined in 35 | 36 | [types/wallet.ts:263](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L263) 37 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IGetAddressByPath.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IGetAddressByPath 2 | 3 | # Interface: IGetAddressByPath 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [addressType](IGetAddressByPath.md#addresstype) 10 | - [path](IGetAddressByPath.md#path) 11 | 12 | ## Properties 13 | 14 | ### addressType 15 | 16 | • `Optional` **addressType**: [`EAddressType`](../enums/EAddressType.md) 17 | 18 | #### Defined in 19 | 20 | [types/wallet.ts:258](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L258) 21 | 22 | ___ 23 | 24 | ### path 25 | 26 | • **path**: `string` 27 | 28 | #### Defined in 29 | 30 | [types/wallet.ts:257](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L257) 31 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IGetAddressHistoryResponse.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IGetAddressHistoryResponse 2 | 3 | # Interface: IGetAddressHistoryResponse 4 | 5 | ## Hierarchy 6 | 7 | - [`TTxResult`](../README.md#ttxresult) 8 | 9 | - [`IAddress`](IAddress.md) 10 | 11 | ↳ **`IGetAddressHistoryResponse`** 12 | 13 | ## Table of contents 14 | 15 | ### Properties 16 | 17 | - [address](IGetAddressHistoryResponse.md#address) 18 | - [height](IGetAddressHistoryResponse.md#height) 19 | - [index](IGetAddressHistoryResponse.md#index) 20 | - [path](IGetAddressHistoryResponse.md#path) 21 | - [publicKey](IGetAddressHistoryResponse.md#publickey) 22 | - [scriptHash](IGetAddressHistoryResponse.md#scripthash) 23 | - [tx\_hash](IGetAddressHistoryResponse.md#tx_hash) 24 | 25 | ## Properties 26 | 27 | ### address 28 | 29 | • **address**: `string` 30 | 31 | #### Inherited from 32 | 33 | [IAddress](IAddress.md).[address](IAddress.md#address) 34 | 35 | #### Defined in 36 | 37 | [types/wallet.ts:148](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L148) 38 | 39 | ___ 40 | 41 | ### height 42 | 43 | • **height**: `number` 44 | 45 | #### Inherited from 46 | 47 | TTxResult.height 48 | 49 | #### Defined in 50 | 51 | [types/electrum.ts:51](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L51) 52 | 53 | ___ 54 | 55 | ### index 56 | 57 | • **index**: `number` 58 | 59 | #### Inherited from 60 | 61 | [IAddress](IAddress.md).[index](IAddress.md#index) 62 | 63 | #### Defined in 64 | 65 | [types/wallet.ts:146](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L146) 66 | 67 | ___ 68 | 69 | ### path 70 | 71 | • **path**: `string` 72 | 73 | #### Inherited from 74 | 75 | [IAddress](IAddress.md).[path](IAddress.md#path) 76 | 77 | #### Defined in 78 | 79 | [types/wallet.ts:147](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L147) 80 | 81 | ___ 82 | 83 | ### publicKey 84 | 85 | • **publicKey**: `string` 86 | 87 | #### Inherited from 88 | 89 | [IAddress](IAddress.md).[publicKey](IAddress.md#publickey) 90 | 91 | #### Defined in 92 | 93 | [types/wallet.ts:150](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L150) 94 | 95 | ___ 96 | 97 | ### scriptHash 98 | 99 | • **scriptHash**: `string` 100 | 101 | #### Inherited from 102 | 103 | [IAddress](IAddress.md).[scriptHash](IAddress.md#scripthash) 104 | 105 | #### Defined in 106 | 107 | [types/wallet.ts:149](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L149) 108 | 109 | ___ 110 | 111 | ### tx\_hash 112 | 113 | • **tx\_hash**: `string` 114 | 115 | #### Inherited from 116 | 117 | TTxResult.tx\_hash 118 | 119 | #### Defined in 120 | 121 | [types/electrum.ts:50](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L50) 122 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IGetAddressResponse.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IGetAddressResponse 2 | 3 | # Interface: IGetAddressResponse 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [address](IGetAddressResponse.md#address) 10 | - [path](IGetAddressResponse.md#path) 11 | - [publicKey](IGetAddressResponse.md#publickey) 12 | 13 | ## Properties 14 | 15 | ### address 16 | 17 | • **address**: `string` 18 | 19 | #### Defined in 20 | 21 | [types/wallet.ts:287](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L287) 22 | 23 | ___ 24 | 25 | ### path 26 | 27 | • **path**: `string` 28 | 29 | #### Defined in 30 | 31 | [types/wallet.ts:288](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L288) 32 | 33 | ___ 34 | 35 | ### publicKey 36 | 37 | • **publicKey**: `string` 38 | 39 | #### Defined in 40 | 41 | [types/wallet.ts:289](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L289) 42 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IGetAddressScriptHashBalances.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IGetAddressScriptHashBalances 2 | 3 | # Interface: IGetAddressScriptHashBalances 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [data](IGetAddressScriptHashBalances.md#data) 10 | - [error](IGetAddressScriptHashBalances.md#error) 11 | - [id](IGetAddressScriptHashBalances.md#id) 12 | - [method](IGetAddressScriptHashBalances.md#method) 13 | - [network](IGetAddressScriptHashBalances.md#network) 14 | 15 | ## Properties 16 | 17 | ### data 18 | 19 | • **data**: `string` \| { `data`: `Record`<`string`, `unknown`\> ; `id`: `number` ; `jsonrpc`: `string` ; `param`: `string` ; `result`: { `confirmed`: `number` ; `unconfirmed`: `number` } }[] 20 | 21 | #### Defined in 22 | 23 | [types/electrum.ts:88](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L88) 24 | 25 | ___ 26 | 27 | ### error 28 | 29 | • **error**: `boolean` 30 | 31 | #### Defined in 32 | 33 | [types/electrum.ts:87](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L87) 34 | 35 | ___ 36 | 37 | ### id 38 | 39 | • **id**: `number` 40 | 41 | #### Defined in 42 | 43 | [types/electrum.ts:100](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L100) 44 | 45 | ___ 46 | 47 | ### method 48 | 49 | • **method**: `string` 50 | 51 | #### Defined in 52 | 53 | [types/electrum.ts:101](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L101) 54 | 55 | ___ 56 | 57 | ### network 58 | 59 | • **network**: [`EElectrumNetworks`](../enums/EElectrumNetworks.md) 60 | 61 | #### Defined in 62 | 63 | [types/electrum.ts:102](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L102) 64 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IGetAddressScriptHashesHistoryResponse.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IGetAddressScriptHashesHistoryResponse 2 | 3 | # Interface: IGetAddressScriptHashesHistoryResponse 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [data](IGetAddressScriptHashesHistoryResponse.md#data) 10 | - [error](IGetAddressScriptHashesHistoryResponse.md#error) 11 | - [id](IGetAddressScriptHashesHistoryResponse.md#id) 12 | - [method](IGetAddressScriptHashesHistoryResponse.md#method) 13 | - [network](IGetAddressScriptHashesHistoryResponse.md#network) 14 | 15 | ## Properties 16 | 17 | ### data 18 | 19 | • **data**: [`TTxResponse`](../README.md#ttxresponse)[] 20 | 21 | #### Defined in 22 | 23 | [types/electrum.ts:55](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L55) 24 | 25 | ___ 26 | 27 | ### error 28 | 29 | • **error**: `boolean` 30 | 31 | #### Defined in 32 | 33 | [types/electrum.ts:56](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L56) 34 | 35 | ___ 36 | 37 | ### id 38 | 39 | • **id**: `number` 40 | 41 | #### Defined in 42 | 43 | [types/electrum.ts:57](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L57) 44 | 45 | ___ 46 | 47 | ### method 48 | 49 | • **method**: `string` 50 | 51 | #### Defined in 52 | 53 | [types/electrum.ts:58](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L58) 54 | 55 | ___ 56 | 57 | ### network 58 | 59 | • **network**: `string` 60 | 61 | #### Defined in 62 | 63 | [types/electrum.ts:59](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L59) 64 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IGetAddressTxResponse.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IGetAddressTxResponse 2 | 3 | # Interface: IGetAddressTxResponse 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [data](IGetAddressTxResponse.md#data) 10 | - [error](IGetAddressTxResponse.md#error) 11 | - [id](IGetAddressTxResponse.md#id) 12 | - [method](IGetAddressTxResponse.md#method) 13 | - [network](IGetAddressTxResponse.md#network) 14 | 15 | ## Properties 16 | 17 | ### data 18 | 19 | • **data**: [`TAddressTxResponse`](../README.md#taddresstxresponse)[] 20 | 21 | #### Defined in 22 | 23 | [types/electrum.ts:71](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L71) 24 | 25 | ___ 26 | 27 | ### error 28 | 29 | • **error**: `boolean` 30 | 31 | #### Defined in 32 | 33 | [types/electrum.ts:72](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L72) 34 | 35 | ___ 36 | 37 | ### id 38 | 39 | • **id**: `number` 40 | 41 | #### Defined in 42 | 43 | [types/electrum.ts:73](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L73) 44 | 45 | ___ 46 | 47 | ### method 48 | 49 | • **method**: `string` 50 | 51 | #### Defined in 52 | 53 | [types/electrum.ts:74](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L74) 54 | 55 | ___ 56 | 57 | ### network 58 | 59 | • **network**: `string` 60 | 61 | #### Defined in 62 | 63 | [types/electrum.ts:75](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L75) 64 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IGetAddressesFromKeyPair.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IGetAddressesFromKeyPair 2 | 3 | # Interface: IGetAddressesFromKeyPair 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [address](IGetAddressesFromKeyPair.md#address) 10 | - [publicKey](IGetAddressesFromKeyPair.md#publickey) 11 | 12 | ## Properties 13 | 14 | ### address 15 | 16 | • **address**: `string` 17 | 18 | #### Defined in 19 | 20 | [types/wallet.ts:298](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L298) 21 | 22 | ___ 23 | 24 | ### publicKey 25 | 26 | • **publicKey**: `string` 27 | 28 | #### Defined in 29 | 30 | [types/wallet.ts:299](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L299) 31 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IGetAddressesFromPrivateKey.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IGetAddressesFromPrivateKey 2 | 3 | # Interface: IGetAddressesFromPrivateKey 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [addresses](IGetAddressesFromPrivateKey.md#addresses) 10 | - [keyPair](IGetAddressesFromPrivateKey.md#keypair) 11 | 12 | ## Properties 13 | 14 | ### addresses 15 | 16 | • **addresses**: [`IGetAddressesFromKeyPair`](IGetAddressesFromKeyPair.md)[] 17 | 18 | #### Defined in 19 | 20 | [types/wallet.ts:294](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L294) 21 | 22 | ___ 23 | 24 | ### keyPair 25 | 26 | • **keyPair**: `BIP32Interface` \| `ECPairInterface` 27 | 28 | #### Defined in 29 | 30 | [types/wallet.ts:293](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L293) 31 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IGetDerivationPath.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IGetDerivationPath 2 | 3 | # Interface: IGetDerivationPath 4 | 5 | ## Hierarchy 6 | 7 | - [`IKeyDerivationPath`](IKeyDerivationPath.md) 8 | 9 | ↳ **`IGetDerivationPath`** 10 | 11 | ## Table of contents 12 | 13 | ### Properties 14 | 15 | - [account](IGetDerivationPath.md#account) 16 | - [addressType](IGetDerivationPath.md#addresstype) 17 | - [change](IGetDerivationPath.md#change) 18 | - [coinType](IGetDerivationPath.md#cointype) 19 | - [index](IGetDerivationPath.md#index) 20 | - [purpose](IGetDerivationPath.md#purpose) 21 | 22 | ## Properties 23 | 24 | ### account 25 | 26 | • `Optional` **account**: `string` 27 | 28 | #### Inherited from 29 | 30 | [IKeyDerivationPath](IKeyDerivationPath.md).[account](IKeyDerivationPath.md#account) 31 | 32 | #### Defined in 33 | 34 | [types/wallet.ts:230](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L230) 35 | 36 | ___ 37 | 38 | ### addressType 39 | 40 | • `Optional` **addressType**: [`EAddressType`](../enums/EAddressType.md) 41 | 42 | #### Defined in 43 | 44 | [types/wallet.ts:236](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L236) 45 | 46 | ___ 47 | 48 | ### change 49 | 50 | • `Optional` **change**: [`TKeyDerivationChange`](../README.md#tkeyderivationchange) 51 | 52 | #### Inherited from 53 | 54 | [IKeyDerivationPath](IKeyDerivationPath.md).[change](IKeyDerivationPath.md#change) 55 | 56 | #### Defined in 57 | 58 | [types/wallet.ts:231](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L231) 59 | 60 | ___ 61 | 62 | ### coinType 63 | 64 | • `Optional` **coinType**: `string` 65 | 66 | #### Inherited from 67 | 68 | [IKeyDerivationPath](IKeyDerivationPath.md).[coinType](IKeyDerivationPath.md#cointype) 69 | 70 | #### Defined in 71 | 72 | [types/wallet.ts:229](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L229) 73 | 74 | ___ 75 | 76 | ### index 77 | 78 | • `Optional` **index**: `string` 79 | 80 | #### Inherited from 81 | 82 | [IKeyDerivationPath](IKeyDerivationPath.md).[index](IKeyDerivationPath.md#index) 83 | 84 | #### Defined in 85 | 86 | [types/wallet.ts:232](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L232) 87 | 88 | ___ 89 | 90 | ### purpose 91 | 92 | • `Optional` **purpose**: `string` 93 | 94 | #### Inherited from 95 | 96 | [IKeyDerivationPath](IKeyDerivationPath.md).[purpose](IKeyDerivationPath.md#purpose) 97 | 98 | #### Defined in 99 | 100 | [types/wallet.ts:228](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L228) 101 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IGetFeeEstimatesResponse.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IGetFeeEstimatesResponse 2 | 3 | # Interface: IGetFeeEstimatesResponse 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [fastestFee](IGetFeeEstimatesResponse.md#fastestfee) 10 | - [halfHourFee](IGetFeeEstimatesResponse.md#halfhourfee) 11 | - [hourFee](IGetFeeEstimatesResponse.md#hourfee) 12 | - [minimumFee](IGetFeeEstimatesResponse.md#minimumfee) 13 | 14 | ## Properties 15 | 16 | ### fastestFee 17 | 18 | • **fastestFee**: `number` 19 | 20 | #### Defined in 21 | 22 | [types/wallet.ts:424](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L424) 23 | 24 | ___ 25 | 26 | ### halfHourFee 27 | 28 | • **halfHourFee**: `number` 29 | 30 | #### Defined in 31 | 32 | [types/wallet.ts:425](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L425) 33 | 34 | ___ 35 | 36 | ### hourFee 37 | 38 | • **hourFee**: `number` 39 | 40 | #### Defined in 41 | 42 | [types/wallet.ts:426](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L426) 43 | 44 | ___ 45 | 46 | ### minimumFee 47 | 48 | • **minimumFee**: `number` 49 | 50 | #### Defined in 51 | 52 | [types/wallet.ts:427](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L427) 53 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IGetHeaderResponse.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IGetHeaderResponse 2 | 3 | # Interface: IGetHeaderResponse 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [data](IGetHeaderResponse.md#data) 10 | - [error](IGetHeaderResponse.md#error) 11 | - [id](IGetHeaderResponse.md#id) 12 | - [method](IGetHeaderResponse.md#method) 13 | - [network](IGetHeaderResponse.md#network) 14 | 15 | ## Properties 16 | 17 | ### data 18 | 19 | • **data**: `string` 20 | 21 | #### Defined in 22 | 23 | [types/electrum.ts:122](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L122) 24 | 25 | ___ 26 | 27 | ### error 28 | 29 | • **error**: `boolean` 30 | 31 | #### Defined in 32 | 33 | [types/electrum.ts:120](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L120) 34 | 35 | ___ 36 | 37 | ### id 38 | 39 | • **id**: `number` 40 | 41 | #### Defined in 42 | 43 | [types/electrum.ts:119](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L119) 44 | 45 | ___ 46 | 47 | ### method 48 | 49 | • **method**: ``"getHeader"`` 50 | 51 | #### Defined in 52 | 53 | [types/electrum.ts:121](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L121) 54 | 55 | ___ 56 | 57 | ### network 58 | 59 | • **network**: [`EAvailableNetworks`](../enums/EAvailableNetworks.md) 60 | 61 | #### Defined in 62 | 63 | [types/electrum.ts:123](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L123) 64 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IGetNextAvailableAddressResponse.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IGetNextAvailableAddressResponse 2 | 3 | # Interface: IGetNextAvailableAddressResponse 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [addressIndex](IGetNextAvailableAddressResponse.md#addressindex) 10 | - [changeAddressIndex](IGetNextAvailableAddressResponse.md#changeaddressindex) 11 | - [lastUsedAddressIndex](IGetNextAvailableAddressResponse.md#lastusedaddressindex) 12 | - [lastUsedChangeAddressIndex](IGetNextAvailableAddressResponse.md#lastusedchangeaddressindex) 13 | 14 | ## Properties 15 | 16 | ### addressIndex 17 | 18 | • **addressIndex**: [`IAddress`](IAddress.md) 19 | 20 | #### Defined in 21 | 22 | [types/wallet.ts:303](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L303) 23 | 24 | ___ 25 | 26 | ### changeAddressIndex 27 | 28 | • **changeAddressIndex**: [`IAddress`](IAddress.md) 29 | 30 | #### Defined in 31 | 32 | [types/wallet.ts:305](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L305) 33 | 34 | ___ 35 | 36 | ### lastUsedAddressIndex 37 | 38 | • **lastUsedAddressIndex**: [`IAddress`](IAddress.md) 39 | 40 | #### Defined in 41 | 42 | [types/wallet.ts:304](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L304) 43 | 44 | ___ 45 | 46 | ### lastUsedChangeAddressIndex 47 | 48 | • **lastUsedChangeAddressIndex**: [`IAddress`](IAddress.md) 49 | 50 | #### Defined in 51 | 52 | [types/wallet.ts:306](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L306) 53 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IGetTransactions.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IGetTransactions 2 | 3 | # Interface: IGetTransactions 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [data](IGetTransactions.md#data) 10 | - [error](IGetTransactions.md#error) 11 | - [id](IGetTransactions.md#id) 12 | - [method](IGetTransactions.md#method) 13 | - [network](IGetTransactions.md#network) 14 | 15 | ## Properties 16 | 17 | ### data 18 | 19 | • **data**: [`ITransaction`](ITransaction.md)<[`IUtxo`](IUtxo.md)\>[] 20 | 21 | #### Defined in 22 | 23 | [types/wallet.ts:329](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L329) 24 | 25 | ___ 26 | 27 | ### error 28 | 29 | • **error**: `boolean` 30 | 31 | #### Defined in 32 | 33 | [types/wallet.ts:325](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L325) 34 | 35 | ___ 36 | 37 | ### id 38 | 39 | • **id**: `number` 40 | 41 | #### Defined in 42 | 43 | [types/wallet.ts:326](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L326) 44 | 45 | ___ 46 | 47 | ### method 48 | 49 | • **method**: `string` 50 | 51 | #### Defined in 52 | 53 | [types/wallet.ts:327](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L327) 54 | 55 | ___ 56 | 57 | ### network 58 | 59 | • **network**: `string` 60 | 61 | #### Defined in 62 | 63 | [types/wallet.ts:328](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L328) 64 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IGetTransactionsFromInputs.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IGetTransactionsFromInputs 2 | 3 | # Interface: IGetTransactionsFromInputs 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [data](IGetTransactionsFromInputs.md#data) 10 | - [error](IGetTransactionsFromInputs.md#error) 11 | - [id](IGetTransactionsFromInputs.md#id) 12 | - [method](IGetTransactionsFromInputs.md#method) 13 | - [network](IGetTransactionsFromInputs.md#network) 14 | 15 | ## Properties 16 | 17 | ### data 18 | 19 | • **data**: [`ITransaction`](ITransaction.md)<{ `tx_hash`: `string` ; `vout`: `number` }\>[] 20 | 21 | #### Defined in 22 | 23 | [types/electrum.ts:131](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L131) 24 | 25 | ___ 26 | 27 | ### error 28 | 29 | • **error**: `boolean` 30 | 31 | #### Defined in 32 | 33 | [types/electrum.ts:127](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L127) 34 | 35 | ___ 36 | 37 | ### id 38 | 39 | • **id**: `number` 40 | 41 | #### Defined in 42 | 43 | [types/electrum.ts:128](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L128) 44 | 45 | ___ 46 | 47 | ### method 48 | 49 | • **method**: `string` 50 | 51 | #### Defined in 52 | 53 | [types/electrum.ts:129](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L129) 54 | 55 | ___ 56 | 57 | ### network 58 | 59 | • **network**: `string` 60 | 61 | #### Defined in 62 | 63 | [types/electrum.ts:130](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L130) 64 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IGetUtxosResponse.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IGetUtxosResponse 2 | 3 | # Interface: IGetUtxosResponse 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [balance](IGetUtxosResponse.md#balance) 10 | - [utxos](IGetUtxosResponse.md#utxos) 11 | 12 | ## Properties 13 | 14 | ### balance 15 | 16 | • **balance**: `number` 17 | 18 | #### Defined in 19 | 20 | [types/electrum.ts:42](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L42) 21 | 22 | ___ 23 | 24 | ### utxos 25 | 26 | • **utxos**: [`IUtxo`](IUtxo.md)[] 27 | 28 | #### Defined in 29 | 30 | [types/electrum.ts:41](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L41) 31 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IHeader.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IHeader 2 | 3 | # Interface: IHeader 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [hash](IHeader.md#hash) 10 | - [height](IHeader.md#height) 11 | - [hex](IHeader.md#hex) 12 | 13 | ## Properties 14 | 15 | ### hash 16 | 17 | • **hash**: `string` 18 | 19 | #### Defined in 20 | 21 | [types/electrum.ts:109](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L109) 22 | 23 | ___ 24 | 25 | ### height 26 | 27 | • **height**: `number` 28 | 29 | #### Defined in 30 | 31 | [types/electrum.ts:108](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L108) 32 | 33 | ___ 34 | 35 | ### hex 36 | 37 | • **hex**: `string` 38 | 39 | #### Defined in 40 | 41 | [types/electrum.ts:110](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L110) 42 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IIndexes.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IIndexes 2 | 3 | # Interface: IIndexes 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [addressIndex](IIndexes.md#addressindex) 10 | - [changeAddressIndex](IIndexes.md#changeaddressindex) 11 | - [foundAddressIndex](IIndexes.md#foundaddressindex) 12 | - [foundChangeAddressIndex](IIndexes.md#foundchangeaddressindex) 13 | 14 | ## Properties 15 | 16 | ### addressIndex 17 | 18 | • **addressIndex**: [`IAddress`](IAddress.md) 19 | 20 | #### Defined in 21 | 22 | [types/wallet.ts:314](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L314) 23 | 24 | ___ 25 | 26 | ### changeAddressIndex 27 | 28 | • **changeAddressIndex**: [`IAddress`](IAddress.md) 29 | 30 | #### Defined in 31 | 32 | [types/wallet.ts:315](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L315) 33 | 34 | ___ 35 | 36 | ### foundAddressIndex 37 | 38 | • **foundAddressIndex**: `boolean` 39 | 40 | #### Defined in 41 | 42 | [types/wallet.ts:316](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L316) 43 | 44 | ___ 45 | 46 | ### foundChangeAddressIndex 47 | 48 | • **foundChangeAddressIndex**: `boolean` 49 | 50 | #### Defined in 51 | 52 | [types/wallet.ts:317](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L317) 53 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IKeyDerivationPath.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IKeyDerivationPath 2 | 3 | # Interface: IKeyDerivationPath 4 | 5 | ## Hierarchy 6 | 7 | - **`IKeyDerivationPath`** 8 | 9 | ↳ [`IGetDerivationPath`](IGetDerivationPath.md) 10 | 11 | ## Table of contents 12 | 13 | ### Properties 14 | 15 | - [account](IKeyDerivationPath.md#account) 16 | - [change](IKeyDerivationPath.md#change) 17 | - [coinType](IKeyDerivationPath.md#cointype) 18 | - [index](IKeyDerivationPath.md#index) 19 | - [purpose](IKeyDerivationPath.md#purpose) 20 | 21 | ## Properties 22 | 23 | ### account 24 | 25 | • `Optional` **account**: `string` 26 | 27 | #### Defined in 28 | 29 | [types/wallet.ts:230](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L230) 30 | 31 | ___ 32 | 33 | ### change 34 | 35 | • `Optional` **change**: [`TKeyDerivationChange`](../README.md#tkeyderivationchange) 36 | 37 | #### Defined in 38 | 39 | [types/wallet.ts:231](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L231) 40 | 41 | ___ 42 | 43 | ### coinType 44 | 45 | • `Optional` **coinType**: `string` 46 | 47 | #### Defined in 48 | 49 | [types/wallet.ts:229](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L229) 50 | 51 | ___ 52 | 53 | ### index 54 | 55 | • `Optional` **index**: `string` 56 | 57 | #### Defined in 58 | 59 | [types/wallet.ts:232](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L232) 60 | 61 | ___ 62 | 63 | ### purpose 64 | 65 | • `Optional` **purpose**: `string` 66 | 67 | #### Defined in 68 | 69 | [types/wallet.ts:228](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L228) 70 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IKeyDerivationPathData.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IKeyDerivationPathData 2 | 3 | # Interface: IKeyDerivationPathData 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [pathObject](IKeyDerivationPathData.md#pathobject) 10 | - [pathString](IKeyDerivationPathData.md#pathstring) 11 | 12 | ## Properties 13 | 14 | ### pathObject 15 | 16 | • **pathObject**: [`IKeyDerivationPath`](IKeyDerivationPath.md) 17 | 18 | #### Defined in 19 | 20 | [types/wallet.ts:278](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L278) 21 | 22 | ___ 23 | 24 | ### pathString 25 | 26 | • **pathString**: `string` 27 | 28 | #### Defined in 29 | 30 | [types/wallet.ts:277](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L277) 31 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/INewBlock.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / INewBlock 2 | 3 | # Interface: INewBlock 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [height](INewBlock.md#height) 10 | - [hex](INewBlock.md#hex) 11 | 12 | ## Properties 13 | 14 | ### height 15 | 16 | • **height**: `number` 17 | 18 | #### Defined in 19 | 20 | [types/electrum.ts:114](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L114) 21 | 22 | ___ 23 | 24 | ### hex 25 | 26 | • **hex**: `string` 27 | 28 | #### Defined in 29 | 30 | [types/electrum.ts:115](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L115) 31 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IOnchainFees.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IOnchainFees 2 | 3 | # Interface: IOnchainFees 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [fast](IOnchainFees.md#fast) 10 | - [minimum](IOnchainFees.md#minimum) 11 | - [normal](IOnchainFees.md#normal) 12 | - [slow](IOnchainFees.md#slow) 13 | - [timestamp](IOnchainFees.md#timestamp) 14 | 15 | ## Properties 16 | 17 | ### fast 18 | 19 | • **fast**: `number` 20 | 21 | #### Defined in 22 | 23 | [types/wallet.ts:432](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L432) 24 | 25 | ___ 26 | 27 | ### minimum 28 | 29 | • **minimum**: `number` 30 | 31 | #### Defined in 32 | 33 | [types/wallet.ts:435](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L435) 34 | 35 | ___ 36 | 37 | ### normal 38 | 39 | • **normal**: `number` 40 | 41 | #### Defined in 42 | 43 | [types/wallet.ts:433](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L433) 44 | 45 | ___ 46 | 47 | ### slow 48 | 49 | • **slow**: `number` 50 | 51 | #### Defined in 52 | 53 | [types/wallet.ts:434](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L434) 54 | 55 | ___ 56 | 57 | ### timestamp 58 | 59 | • **timestamp**: `number` 60 | 61 | #### Defined in 62 | 63 | [types/wallet.ts:436](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L436) 64 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IOutput.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IOutput 2 | 3 | # Interface: IOutput 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [address](IOutput.md#address) 10 | - [index](IOutput.md#index) 11 | - [value](IOutput.md#value) 12 | 13 | ## Properties 14 | 15 | ### address 16 | 17 | • **address**: `string` 18 | 19 | #### Defined in 20 | 21 | [types/wallet.ts:112](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L112) 22 | 23 | ___ 24 | 25 | ### index 26 | 27 | • **index**: `number` 28 | 29 | #### Defined in 30 | 31 | [types/wallet.ts:114](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L114) 32 | 33 | ___ 34 | 35 | ### value 36 | 37 | • **value**: `number` 38 | 39 | #### Defined in 40 | 41 | [types/wallet.ts:113](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L113) 42 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IPeerData.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IPeerData 2 | 3 | # Interface: IPeerData 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [host](IPeerData.md#host) 10 | - [port](IPeerData.md#port) 11 | - [protocol](IPeerData.md#protocol) 12 | 13 | ## Properties 14 | 15 | ### host 16 | 17 | • **host**: `string` 18 | 19 | #### Defined in 20 | 21 | [types/electrum.ts:169](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L169) 22 | 23 | ___ 24 | 25 | ### port 26 | 27 | • **port**: `string` 28 | 29 | #### Defined in 30 | 31 | [types/electrum.ts:170](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L170) 32 | 33 | ___ 34 | 35 | ### protocol 36 | 37 | • **protocol**: [`TProtocol`](../README.md#tprotocol) 38 | 39 | #### Defined in 40 | 41 | [types/electrum.ts:171](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L171) 42 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IPrivateKeyInfo.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IPrivateKeyInfo 2 | 3 | # Interface: IPrivateKeyInfo 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [addresses](IPrivateKeyInfo.md#addresses) 10 | - [balance](IPrivateKeyInfo.md#balance) 11 | - [keyPair](IPrivateKeyInfo.md#keypair) 12 | - [utxos](IPrivateKeyInfo.md#utxos) 13 | 14 | ## Properties 15 | 16 | ### addresses 17 | 18 | • **addresses**: [`IGetAddressesFromKeyPair`](IGetAddressesFromKeyPair.md)[] 19 | 20 | #### Defined in 21 | 22 | [types/wallet.ts:513](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L513) 23 | 24 | ___ 25 | 26 | ### balance 27 | 28 | • **balance**: `number` 29 | 30 | #### Defined in 31 | 32 | [types/wallet.ts:510](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L510) 33 | 34 | ___ 35 | 36 | ### keyPair 37 | 38 | • **keyPair**: `BIP32Interface` \| `ECPairInterface` 39 | 40 | #### Defined in 41 | 42 | [types/wallet.ts:512](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L512) 43 | 44 | ___ 45 | 46 | ### utxos 47 | 48 | • **utxos**: [`IUtxo`](IUtxo.md)[] 49 | 50 | #### Defined in 51 | 52 | [types/wallet.ts:511](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L511) 53 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IRbfData.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IRbfData 2 | 3 | # Interface: IRbfData 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [addressType](IRbfData.md#addresstype) 10 | - [balance](IRbfData.md#balance) 11 | - [fee](IRbfData.md#fee) 12 | - [inputs](IRbfData.md#inputs) 13 | - [message](IRbfData.md#message) 14 | - [outputs](IRbfData.md#outputs) 15 | 16 | ## Properties 17 | 18 | ### addressType 19 | 20 | • **addressType**: [`EAddressType`](../enums/EAddressType.md) 21 | 22 | #### Defined in 23 | 24 | [types/wallet.ts:492](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L492) 25 | 26 | ___ 27 | 28 | ### balance 29 | 30 | • **balance**: `number` 31 | 32 | #### Defined in 33 | 34 | [types/wallet.ts:491](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L491) 35 | 36 | ___ 37 | 38 | ### fee 39 | 40 | • **fee**: `number` 41 | 42 | #### Defined in 43 | 44 | [types/wallet.ts:493](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L493) 45 | 46 | ___ 47 | 48 | ### inputs 49 | 50 | • **inputs**: [`IUtxo`](IUtxo.md)[] 51 | 52 | #### Defined in 53 | 54 | [types/wallet.ts:494](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L494) 55 | 56 | ___ 57 | 58 | ### message 59 | 60 | • **message**: `string` 61 | 62 | #### Defined in 63 | 64 | [types/wallet.ts:495](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L495) 65 | 66 | ___ 67 | 68 | ### outputs 69 | 70 | • **outputs**: [`IOutput`](IOutput.md)[] 71 | 72 | #### Defined in 73 | 74 | [types/wallet.ts:490](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L490) 75 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/ISend.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / ISend 2 | 3 | # Interface: ISend 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [satsPerByte](ISend.md#satsperbyte) 10 | - [txs](ISend.md#txs) 11 | 12 | ## Properties 13 | 14 | ### satsPerByte 15 | 16 | • `Optional` **satsPerByte**: `number` 17 | 18 | #### Defined in 19 | 20 | [types/wallet.ts:474](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L474) 21 | 22 | ___ 23 | 24 | ### txs 25 | 26 | • **txs**: [`ISendTx`](ISendTx.md) \| [`ISendTx`](ISendTx.md)[] 27 | 28 | #### Defined in 29 | 30 | [types/wallet.ts:473](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L473) 31 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/ISendTransaction.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / ISendTransaction 2 | 3 | # Interface: ISendTransaction 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [boostType](ISendTransaction.md#boosttype) 10 | - [changeAddress](ISendTransaction.md#changeaddress) 11 | - [fee](ISendTransaction.md#fee) 12 | - [fiatAmount](ISendTransaction.md#fiatamount) 13 | - [inputs](ISendTransaction.md#inputs) 14 | - [label](ISendTransaction.md#label) 15 | - [lightningInvoice](ISendTransaction.md#lightninginvoice) 16 | - [max](ISendTransaction.md#max) 17 | - [message](ISendTransaction.md#message) 18 | - [minFee](ISendTransaction.md#minfee) 19 | - [outputs](ISendTransaction.md#outputs) 20 | - [rbf](ISendTransaction.md#rbf) 21 | - [satsPerByte](ISendTransaction.md#satsperbyte) 22 | - [selectedFeeId](ISendTransaction.md#selectedfeeid) 23 | - [slashTagsUrl](ISendTransaction.md#slashtagsurl) 24 | - [tags](ISendTransaction.md#tags) 25 | 26 | ## Properties 27 | 28 | ### boostType 29 | 30 | • **boostType**: [`EBoostType`](../enums/EBoostType.md) 31 | 32 | #### Defined in 33 | 34 | [types/wallet.ts:133](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L133) 35 | 36 | ___ 37 | 38 | ### changeAddress 39 | 40 | • **changeAddress**: `string` 41 | 42 | #### Defined in 43 | 44 | [types/wallet.ts:125](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L125) 45 | 46 | ___ 47 | 48 | ### fee 49 | 50 | • **fee**: `number` 51 | 52 | #### Defined in 53 | 54 | [types/wallet.ts:127](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L127) 55 | 56 | ___ 57 | 58 | ### fiatAmount 59 | 60 | • **fiatAmount**: `number` 61 | 62 | #### Defined in 63 | 64 | [types/wallet.ts:126](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L126) 65 | 66 | ___ 67 | 68 | ### inputs 69 | 70 | • **inputs**: [`IUtxo`](IUtxo.md)[] 71 | 72 | #### Defined in 73 | 74 | [types/wallet.ts:124](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L124) 75 | 76 | ___ 77 | 78 | ### label 79 | 80 | • **label**: `string` 81 | 82 | #### Defined in 83 | 84 | [types/wallet.ts:131](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L131) 85 | 86 | ___ 87 | 88 | ### lightningInvoice 89 | 90 | • `Optional` **lightningInvoice**: `string` 91 | 92 | #### Defined in 93 | 94 | [types/wallet.ts:138](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L138) 95 | 96 | ___ 97 | 98 | ### max 99 | 100 | • **max**: `boolean` 101 | 102 | #### Defined in 103 | 104 | [types/wallet.ts:135](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L135) 105 | 106 | ___ 107 | 108 | ### message 109 | 110 | • **message**: `string` 111 | 112 | #### Defined in 113 | 114 | [types/wallet.ts:130](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L130) 115 | 116 | ___ 117 | 118 | ### minFee 119 | 120 | • **minFee**: `number` 121 | 122 | #### Defined in 123 | 124 | [types/wallet.ts:134](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L134) 125 | 126 | ___ 127 | 128 | ### outputs 129 | 130 | • **outputs**: [`IOutput`](IOutput.md)[] 131 | 132 | #### Defined in 133 | 134 | [types/wallet.ts:123](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L123) 135 | 136 | ___ 137 | 138 | ### rbf 139 | 140 | • **rbf**: `boolean` 141 | 142 | #### Defined in 143 | 144 | [types/wallet.ts:132](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L132) 145 | 146 | ___ 147 | 148 | ### satsPerByte 149 | 150 | • **satsPerByte**: `number` 151 | 152 | #### Defined in 153 | 154 | [types/wallet.ts:128](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L128) 155 | 156 | ___ 157 | 158 | ### selectedFeeId 159 | 160 | • **selectedFeeId**: [`EFeeId`](../enums/EFeeId.md) 161 | 162 | #### Defined in 163 | 164 | [types/wallet.ts:129](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L129) 165 | 166 | ___ 167 | 168 | ### slashTagsUrl 169 | 170 | • `Optional` **slashTagsUrl**: `string` 171 | 172 | #### Defined in 173 | 174 | [types/wallet.ts:137](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L137) 175 | 176 | ___ 177 | 178 | ### tags 179 | 180 | • **tags**: `string`[] 181 | 182 | #### Defined in 183 | 184 | [types/wallet.ts:136](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L136) 185 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/ISendTx.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / ISendTx 2 | 3 | # Interface: ISendTx 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [address](ISendTx.md#address) 10 | - [amount](ISendTx.md#amount) 11 | - [message](ISendTx.md#message) 12 | 13 | ## Properties 14 | 15 | ### address 16 | 17 | • **address**: `string` 18 | 19 | #### Defined in 20 | 21 | [types/wallet.ts:467](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L467) 22 | 23 | ___ 24 | 25 | ### amount 26 | 27 | • **amount**: `number` 28 | 29 | #### Defined in 30 | 31 | [types/wallet.ts:468](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L468) 32 | 33 | ___ 34 | 35 | ### message 36 | 37 | • `Optional` **message**: `string` 38 | 39 | #### Defined in 40 | 41 | [types/wallet.ts:469](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L469) 42 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/ISetupTransaction.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / ISetupTransaction 2 | 3 | # Interface: ISetupTransaction 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [inputTxHashes](ISetupTransaction.md#inputtxhashes) 10 | - [outputs](ISetupTransaction.md#outputs) 11 | - [rbf](ISetupTransaction.md#rbf) 12 | - [satsPerByte](ISetupTransaction.md#satsperbyte) 13 | - [utxos](ISetupTransaction.md#utxos) 14 | 15 | ## Properties 16 | 17 | ### inputTxHashes 18 | 19 | • `Optional` **inputTxHashes**: `string`[] 20 | 21 | #### Defined in 22 | 23 | [types/transaction.ts:26](https://github.com/synonymdev/beignet/blob/3144d66/src/types/transaction.ts#L26) 24 | 25 | ___ 26 | 27 | ### outputs 28 | 29 | • `Optional` **outputs**: [`IOutput`](IOutput.md)[] 30 | 31 | #### Defined in 32 | 33 | [types/transaction.ts:30](https://github.com/synonymdev/beignet/blob/3144d66/src/types/transaction.ts#L30) 34 | 35 | ___ 36 | 37 | ### rbf 38 | 39 | • `Optional` **rbf**: `boolean` 40 | 41 | #### Defined in 42 | 43 | [types/transaction.ts:28](https://github.com/synonymdev/beignet/blob/3144d66/src/types/transaction.ts#L28) 44 | 45 | ___ 46 | 47 | ### satsPerByte 48 | 49 | • `Optional` **satsPerByte**: `number` 50 | 51 | #### Defined in 52 | 53 | [types/transaction.ts:29](https://github.com/synonymdev/beignet/blob/3144d66/src/types/transaction.ts#L29) 54 | 55 | ___ 56 | 57 | ### utxos 58 | 59 | • `Optional` **utxos**: [`IUtxo`](IUtxo.md)[] 60 | 61 | #### Defined in 62 | 63 | [types/transaction.ts:27](https://github.com/synonymdev/beignet/blob/3144d66/src/types/transaction.ts#L27) 64 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/ISubscribeToAddress.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / ISubscribeToAddress 2 | 3 | # Interface: ISubscribeToAddress 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [data](ISubscribeToAddress.md#data) 10 | - [error](ISubscribeToAddress.md#error) 11 | - [id](ISubscribeToAddress.md#id) 12 | - [method](ISubscribeToAddress.md#method) 13 | 14 | ## Properties 15 | 16 | ### data 17 | 18 | • **data**: `Object` 19 | 20 | #### Type declaration 21 | 22 | | Name | Type | 23 | | :------ | :------ | 24 | | `id` | `number` | 25 | | `jsonrpc` | `string` | 26 | | `result` | ``null`` | 27 | 28 | #### Defined in 29 | 30 | [types/electrum.ts:148](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L148) 31 | 32 | ___ 33 | 34 | ### error 35 | 36 | • **error**: `boolean` 37 | 38 | #### Defined in 39 | 40 | [types/electrum.ts:153](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L153) 41 | 42 | ___ 43 | 44 | ### id 45 | 46 | • **id**: `number` 47 | 48 | #### Defined in 49 | 50 | [types/electrum.ts:154](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L154) 51 | 52 | ___ 53 | 54 | ### method 55 | 56 | • **method**: `string` 57 | 58 | #### Defined in 59 | 60 | [types/electrum.ts:155](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L155) 61 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/ISubscribeToHeader.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / ISubscribeToHeader 2 | 3 | # Interface: ISubscribeToHeader 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [data](ISubscribeToHeader.md#data) 10 | - [error](ISubscribeToHeader.md#error) 11 | - [id](ISubscribeToHeader.md#id) 12 | - [method](ISubscribeToHeader.md#method) 13 | 14 | ## Properties 15 | 16 | ### data 17 | 18 | • **data**: `Object` 19 | 20 | #### Type declaration 21 | 22 | | Name | Type | 23 | | :------ | :------ | 24 | | `height` | `number` | 25 | | `hex` | `string` | 26 | 27 | #### Defined in 28 | 29 | [types/electrum.ts:138](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L138) 30 | 31 | ___ 32 | 33 | ### error 34 | 35 | • **error**: `boolean` 36 | 37 | #### Defined in 38 | 39 | [types/electrum.ts:142](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L142) 40 | 41 | ___ 42 | 43 | ### id 44 | 45 | • **id**: `string` 46 | 47 | #### Defined in 48 | 49 | [types/electrum.ts:143](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L143) 50 | 51 | ___ 52 | 53 | ### method 54 | 55 | • **method**: `string` 56 | 57 | #### Defined in 58 | 59 | [types/electrum.ts:144](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L144) 60 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/ISweepPrivateKey.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / ISweepPrivateKey 2 | 3 | # Interface: ISweepPrivateKey 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [broadcast](ISweepPrivateKey.md#broadcast) 10 | - [combineWithWalletUtxos](ISweepPrivateKey.md#combinewithwalletutxos) 11 | - [privateKey](ISweepPrivateKey.md#privatekey) 12 | - [satsPerByte](ISweepPrivateKey.md#satsperbyte) 13 | - [toAddress](ISweepPrivateKey.md#toaddress) 14 | 15 | ## Properties 16 | 17 | ### broadcast 18 | 19 | • `Optional` **broadcast**: `boolean` 20 | 21 | #### Defined in 22 | 23 | [types/wallet.ts:520](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L520) 24 | 25 | ___ 26 | 27 | ### combineWithWalletUtxos 28 | 29 | • `Optional` **combineWithWalletUtxos**: `boolean` 30 | 31 | #### Defined in 32 | 33 | [types/wallet.ts:521](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L521) 34 | 35 | ___ 36 | 37 | ### privateKey 38 | 39 | • **privateKey**: `string` 40 | 41 | #### Defined in 42 | 43 | [types/wallet.ts:517](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L517) 44 | 45 | ___ 46 | 47 | ### satsPerByte 48 | 49 | • `Optional` **satsPerByte**: `number` 50 | 51 | #### Defined in 52 | 53 | [types/wallet.ts:519](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L519) 54 | 55 | ___ 56 | 57 | ### toAddress 58 | 59 | • **toAddress**: `string` 60 | 61 | #### Defined in 62 | 63 | [types/wallet.ts:518](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L518) 64 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/ISweepPrivateKeyRes.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / ISweepPrivateKeyRes 2 | 3 | # Interface: ISweepPrivateKeyRes 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [balance](ISweepPrivateKeyRes.md#balance) 10 | - [hex](ISweepPrivateKeyRes.md#hex) 11 | - [id](ISweepPrivateKeyRes.md#id) 12 | 13 | ## Properties 14 | 15 | ### balance 16 | 17 | • **balance**: `number` 18 | 19 | #### Defined in 20 | 21 | [types/wallet.ts:525](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L525) 22 | 23 | ___ 24 | 25 | ### hex 26 | 27 | • **hex**: `string` 28 | 29 | #### Defined in 30 | 31 | [types/wallet.ts:527](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L527) 32 | 33 | ___ 34 | 35 | ### id 36 | 37 | • **id**: `string` 38 | 39 | #### Defined in 40 | 41 | [types/wallet.ts:526](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L526) 42 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/ITargets.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / ITargets 2 | 3 | # Interface: ITargets 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [address](ITargets.md#address) 10 | - [index](ITargets.md#index) 11 | - [script](ITargets.md#script) 12 | - [value](ITargets.md#value) 13 | 14 | ## Properties 15 | 16 | ### address 17 | 18 | • `Optional` **address**: `string` 19 | 20 | #### Defined in 21 | 22 | [types/transaction.ts:21](https://github.com/synonymdev/beignet/blob/3144d66/src/types/transaction.ts#L21) 23 | 24 | ___ 25 | 26 | ### index 27 | 28 | • **index**: `number` 29 | 30 | #### Defined in 31 | 32 | [types/transaction.ts:20](https://github.com/synonymdev/beignet/blob/3144d66/src/types/transaction.ts#L20) 33 | 34 | ___ 35 | 36 | ### script 37 | 38 | • `Optional` **script**: `Buffer` 39 | 40 | #### Defined in 41 | 42 | [types/transaction.ts:22](https://github.com/synonymdev/beignet/blob/3144d66/src/types/transaction.ts#L22) 43 | 44 | ___ 45 | 46 | ### value 47 | 48 | • **value**: `number` 49 | 50 | #### Defined in 51 | 52 | [types/transaction.ts:19](https://github.com/synonymdev/beignet/blob/3144d66/src/types/transaction.ts#L19) 53 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/ITransaction.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / ITransaction 2 | 3 | # Interface: ITransaction 4 | 5 | ## Type parameters 6 | 7 | | Name | 8 | | :------ | 9 | | `T` | 10 | 11 | ## Table of contents 12 | 13 | ### Properties 14 | 15 | - [data](ITransaction.md#data) 16 | - [error](ITransaction.md#error) 17 | - [id](ITransaction.md#id) 18 | - [jsonrpc](ITransaction.md#jsonrpc) 19 | - [param](ITransaction.md#param) 20 | - [result](ITransaction.md#result) 21 | 22 | ## Properties 23 | 24 | ### data 25 | 26 | • **data**: `T` 27 | 28 | #### Defined in 29 | 30 | [types/wallet.ts:336](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L336) 31 | 32 | ___ 33 | 34 | ### error 35 | 36 | • `Optional` **error**: `Object` 37 | 38 | #### Type declaration 39 | 40 | | Name | Type | 41 | | :------ | :------ | 42 | | `code` | `number` | 43 | | `message` | `string` | 44 | 45 | #### Defined in 46 | 47 | [types/wallet.ts:338](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L338) 48 | 49 | ___ 50 | 51 | ### id 52 | 53 | • **id**: `number` 54 | 55 | #### Defined in 56 | 57 | [types/wallet.ts:333](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L333) 58 | 59 | ___ 60 | 61 | ### jsonrpc 62 | 63 | • **jsonrpc**: `string` 64 | 65 | #### Defined in 66 | 67 | [types/wallet.ts:334](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L334) 68 | 69 | ___ 70 | 71 | ### param 72 | 73 | • **param**: `string` 74 | 75 | #### Defined in 76 | 77 | [types/wallet.ts:335](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L335) 78 | 79 | ___ 80 | 81 | ### result 82 | 83 | • **result**: [`TTxDetails`](../README.md#ttxdetails) 84 | 85 | #### Defined in 86 | 87 | [types/wallet.ts:337](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L337) 88 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/ITxHash.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / ITxHash 2 | 3 | # Interface: ITxHash 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [tx\_hash](ITxHash.md#tx_hash) 10 | 11 | ## Properties 12 | 13 | ### tx\_hash 14 | 15 | • **tx\_hash**: `string` 16 | 17 | #### Defined in 18 | 19 | [types/wallet.ts:321](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L321) 20 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/ITxHashes.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / ITxHashes 2 | 3 | # Interface: ITxHashes 4 | 5 | ## Hierarchy 6 | 7 | - [`TTxResult`](../README.md#ttxresult) 8 | 9 | ↳ **`ITxHashes`** 10 | 11 | ## Table of contents 12 | 13 | ### Properties 14 | 15 | - [height](ITxHashes.md#height) 16 | - [scriptHash](ITxHashes.md#scripthash) 17 | - [tx\_hash](ITxHashes.md#tx_hash) 18 | 19 | ## Properties 20 | 21 | ### height 22 | 23 | • **height**: `number` 24 | 25 | #### Inherited from 26 | 27 | TTxResult.height 28 | 29 | #### Defined in 30 | 31 | [types/electrum.ts:51](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L51) 32 | 33 | ___ 34 | 35 | ### scriptHash 36 | 37 | • **scriptHash**: `string` 38 | 39 | #### Defined in 40 | 41 | [types/wallet.ts:310](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L310) 42 | 43 | ___ 44 | 45 | ### tx\_hash 46 | 47 | • **tx\_hash**: `string` 48 | 49 | #### Inherited from 50 | 51 | TTxResult.tx\_hash 52 | 53 | #### Defined in 54 | 55 | [types/electrum.ts:50](https://github.com/synonymdev/beignet/blob/3144d66/src/types/electrum.ts#L50) 56 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IUtxo.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IUtxo 2 | 3 | # Interface: IUtxo 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [address](IUtxo.md#address) 10 | - [height](IUtxo.md#height) 11 | - [index](IUtxo.md#index) 12 | - [keyPair](IUtxo.md#keypair) 13 | - [path](IUtxo.md#path) 14 | - [publicKey](IUtxo.md#publickey) 15 | - [scriptHash](IUtxo.md#scripthash) 16 | - [tx\_hash](IUtxo.md#tx_hash) 17 | - [tx\_pos](IUtxo.md#tx_pos) 18 | - [value](IUtxo.md#value) 19 | 20 | ## Properties 21 | 22 | ### address 23 | 24 | • **address**: `string` 25 | 26 | #### Defined in 27 | 28 | [types/wallet.ts:62](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L62) 29 | 30 | ___ 31 | 32 | ### height 33 | 34 | • **height**: `number` 35 | 36 | #### Defined in 37 | 38 | [types/wallet.ts:66](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L66) 39 | 40 | ___ 41 | 42 | ### index 43 | 44 | • **index**: `number` 45 | 46 | #### Defined in 47 | 48 | [types/wallet.ts:63](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L63) 49 | 50 | ___ 51 | 52 | ### keyPair 53 | 54 | • `Optional` **keyPair**: `BIP32Interface` \| `ECPairInterface` 55 | 56 | #### Defined in 57 | 58 | [types/wallet.ts:71](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L71) 59 | 60 | ___ 61 | 62 | ### path 63 | 64 | • **path**: `string` 65 | 66 | #### Defined in 67 | 68 | [types/wallet.ts:64](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L64) 69 | 70 | ___ 71 | 72 | ### publicKey 73 | 74 | • **publicKey**: `string` 75 | 76 | #### Defined in 77 | 78 | [types/wallet.ts:70](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L70) 79 | 80 | ___ 81 | 82 | ### scriptHash 83 | 84 | • **scriptHash**: `string` 85 | 86 | #### Defined in 87 | 88 | [types/wallet.ts:65](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L65) 89 | 90 | ___ 91 | 92 | ### tx\_hash 93 | 94 | • **tx\_hash**: `string` 95 | 96 | #### Defined in 97 | 98 | [types/wallet.ts:67](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L67) 99 | 100 | ___ 101 | 102 | ### tx\_pos 103 | 104 | • **tx\_pos**: `number` 105 | 106 | #### Defined in 107 | 108 | [types/wallet.ts:68](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L68) 109 | 110 | ___ 111 | 112 | ### value 113 | 114 | • **value**: `number` 115 | 116 | #### Defined in 117 | 118 | [types/wallet.ts:69](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L69) 119 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IVin.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IVin 2 | 3 | # Interface: IVin 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [scriptSig](IVin.md#scriptsig) 10 | - [sequence](IVin.md#sequence) 11 | - [txid](IVin.md#txid) 12 | - [txinwitness](IVin.md#txinwitness) 13 | - [vout](IVin.md#vout) 14 | 15 | ## Properties 16 | 17 | ### scriptSig 18 | 19 | • **scriptSig**: `Object` 20 | 21 | #### Type declaration 22 | 23 | | Name | Type | 24 | | :------ | :------ | 25 | | `asm` | `string` | 26 | | `hex` | `string` | 27 | 28 | #### Defined in 29 | 30 | [types/wallet.ts:75](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L75) 31 | 32 | ___ 33 | 34 | ### sequence 35 | 36 | • **sequence**: `number` 37 | 38 | #### Defined in 39 | 40 | [types/wallet.ts:79](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L79) 41 | 42 | ___ 43 | 44 | ### txid 45 | 46 | • **txid**: `string` 47 | 48 | #### Defined in 49 | 50 | [types/wallet.ts:80](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L80) 51 | 52 | ___ 53 | 54 | ### txinwitness 55 | 56 | • **txinwitness**: `string`[] 57 | 58 | #### Defined in 59 | 60 | [types/wallet.ts:81](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L81) 61 | 62 | ___ 63 | 64 | ### vout 65 | 66 | • **vout**: `number` 67 | 68 | #### Defined in 69 | 70 | [types/wallet.ts:82](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L82) 71 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IVout.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IVout 2 | 3 | # Interface: IVout 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [n](IVout.md#n) 10 | - [scriptPubKey](IVout.md#scriptpubkey) 11 | - [value](IVout.md#value) 12 | 13 | ## Properties 14 | 15 | ### n 16 | 17 | • **n**: `number` 18 | 19 | #### Defined in 20 | 21 | [types/wallet.ts:359](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L359) 22 | 23 | ___ 24 | 25 | ### scriptPubKey 26 | 27 | • **scriptPubKey**: `Object` 28 | 29 | #### Type declaration 30 | 31 | | Name | Type | 32 | | :------ | :------ | 33 | | `address?` | `string` | 34 | | `addresses?` | `string`[] | 35 | | `asm` | `string` | 36 | | `hex` | `string` | 37 | | `reqSigs?` | `number` | 38 | | `type?` | `string` | 39 | 40 | #### Defined in 41 | 42 | [types/wallet.ts:360](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L360) 43 | 44 | ___ 45 | 46 | ### value 47 | 48 | • **value**: `number` 49 | 50 | #### Defined in 51 | 52 | [types/wallet.ts:368](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L368) 53 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IWallet.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IWallet 2 | 3 | # Interface: IWallet 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [addressLookAhead](IWallet.md#addresslookahead) 10 | - [addressLookBehind](IWallet.md#addresslookbehind) 11 | - [addressType](IWallet.md#addresstype) 12 | - [addressTypesToMonitor](IWallet.md#addresstypestomonitor) 13 | - [customGetAddress](IWallet.md#customgetaddress) 14 | - [customGetScriptHash](IWallet.md#customgetscripthash) 15 | - [data](IWallet.md#data) 16 | - [disableMessages](IWallet.md#disablemessages) 17 | - [disableMessagesOnCreate](IWallet.md#disablemessagesoncreate) 18 | - [electrumOptions](IWallet.md#electrumoptions) 19 | - [gapLimitOptions](IWallet.md#gaplimitoptions) 20 | - [id](IWallet.md#id) 21 | - [mnemonic](IWallet.md#mnemonic) 22 | - [name](IWallet.md#name) 23 | - [network](IWallet.md#network) 24 | - [onMessage](IWallet.md#onmessage) 25 | - [passphrase](IWallet.md#passphrase) 26 | - [rbf](IWallet.md#rbf) 27 | - [remainOffline](IWallet.md#remainoffline) 28 | - [selectedFeeId](IWallet.md#selectedfeeid) 29 | - [storage](IWallet.md#storage) 30 | 31 | ## Properties 32 | 33 | ### addressLookAhead 34 | 35 | • `Optional` **addressLookAhead**: `number` 36 | 37 | #### Defined in 38 | 39 | [types/wallet.ts:213](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L213) 40 | 41 | ___ 42 | 43 | ### addressLookBehind 44 | 45 | • `Optional` **addressLookBehind**: `number` 46 | 47 | #### Defined in 48 | 49 | [types/wallet.ts:212](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L212) 50 | 51 | ___ 52 | 53 | ### addressType 54 | 55 | • `Optional` **addressType**: [`EAddressType`](../enums/EAddressType.md) 56 | 57 | #### Defined in 58 | 59 | [types/wallet.ts:190](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L190) 60 | 61 | ___ 62 | 63 | ### addressTypesToMonitor 64 | 65 | • `Optional` **addressTypesToMonitor**: [`EAddressType`](../enums/EAddressType.md)[] 66 | 67 | #### Defined in 68 | 69 | [types/wallet.ts:210](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L210) 70 | 71 | ___ 72 | 73 | ### customGetAddress 74 | 75 | • `Optional` **customGetAddress**: (`data`: [`ICustomGetAddress`](ICustomGetAddress.md)) => `Promise`<[`Result`](../README.md#result)<[`IGetAddressResponse`](IGetAddressResponse.md)\>\> 76 | 77 | #### Type declaration 78 | 79 | ▸ (`data`): `Promise`<[`Result`](../README.md#result)<[`IGetAddressResponse`](IGetAddressResponse.md)\>\> 80 | 81 | ##### Parameters 82 | 83 | | Name | Type | 84 | | :------ | :------ | 85 | | `data` | [`ICustomGetAddress`](ICustomGetAddress.md) | 86 | 87 | ##### Returns 88 | 89 | `Promise`<[`Result`](../README.md#result)<[`IGetAddressResponse`](IGetAddressResponse.md)\>\> 90 | 91 | #### Defined in 92 | 93 | [types/wallet.ts:202](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L202) 94 | 95 | ___ 96 | 97 | ### customGetScriptHash 98 | 99 | • `Optional` **customGetScriptHash**: (`data`: [`ICustomGetScriptHash`](ICustomGetScriptHash.md)) => `Promise`<`string`\> 100 | 101 | #### Type declaration 102 | 103 | ▸ (`data`): `Promise`<`string`\> 104 | 105 | ##### Parameters 106 | 107 | | Name | Type | 108 | | :------ | :------ | 109 | | `data` | [`ICustomGetScriptHash`](ICustomGetScriptHash.md) | 110 | 111 | ##### Returns 112 | 113 | `Promise`<`string`\> 114 | 115 | #### Defined in 116 | 117 | [types/wallet.ts:205](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L205) 118 | 119 | ___ 120 | 121 | ### data 122 | 123 | • `Optional` **data**: [`IWalletData`](IWalletData.md) 124 | 125 | #### Defined in 126 | 127 | [types/wallet.ts:191](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L191) 128 | 129 | ___ 130 | 131 | ### disableMessages 132 | 133 | • `Optional` **disableMessages**: `boolean` 134 | 135 | #### Defined in 136 | 137 | [types/wallet.ts:208](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L208) 138 | 139 | ___ 140 | 141 | ### disableMessagesOnCreate 142 | 143 | • `Optional` **disableMessagesOnCreate**: `boolean` 144 | 145 | #### Defined in 146 | 147 | [types/wallet.ts:209](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L209) 148 | 149 | ___ 150 | 151 | ### electrumOptions 152 | 153 | • `Optional` **electrumOptions**: `Object` 154 | 155 | #### Type declaration 156 | 157 | | Name | Type | 158 | | :------ | :------ | 159 | | `batchDelay?` | `number` | 160 | | `batchLimit?` | `number` | 161 | | `net?` | `Server` | 162 | | `servers?` | [`TServer`](../README.md#tserver) \| [`TServer`](../README.md#tserver)[] | 163 | | `tls?` | `TLSSocket` | 164 | 165 | #### Defined in 166 | 167 | [types/wallet.ts:193](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L193) 168 | 169 | ___ 170 | 171 | ### gapLimitOptions 172 | 173 | • `Optional` **gapLimitOptions**: [`TGapLimitOptions`](../README.md#tgaplimitoptions) 174 | 175 | #### Defined in 176 | 177 | [types/wallet.ts:211](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L211) 178 | 179 | ___ 180 | 181 | ### id 182 | 183 | • `Optional` **id**: `string` 184 | 185 | #### Defined in 186 | 187 | [types/wallet.ts:186](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L186) 188 | 189 | ___ 190 | 191 | ### mnemonic 192 | 193 | • **mnemonic**: `string` 194 | 195 | #### Defined in 196 | 197 | [types/wallet.ts:185](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L185) 198 | 199 | ___ 200 | 201 | ### name 202 | 203 | • `Optional` **name**: `string` 204 | 205 | #### Defined in 206 | 207 | [types/wallet.ts:187](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L187) 208 | 209 | ___ 210 | 211 | ### network 212 | 213 | • `Optional` **network**: [`EAvailableNetworks`](../enums/EAvailableNetworks.md) 214 | 215 | #### Defined in 216 | 217 | [types/wallet.ts:189](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L189) 218 | 219 | ___ 220 | 221 | ### onMessage 222 | 223 | • `Optional` **onMessage**: [`TOnMessage`](../README.md#tonmessage) 224 | 225 | #### Defined in 226 | 227 | [types/wallet.ts:201](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L201) 228 | 229 | ___ 230 | 231 | ### passphrase 232 | 233 | • `Optional` **passphrase**: `string` 234 | 235 | #### Defined in 236 | 237 | [types/wallet.ts:188](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L188) 238 | 239 | ___ 240 | 241 | ### rbf 242 | 243 | • `Optional` **rbf**: `boolean` 244 | 245 | #### Defined in 246 | 247 | [types/wallet.ts:206](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L206) 248 | 249 | ___ 250 | 251 | ### remainOffline 252 | 253 | • `Optional` **remainOffline**: `boolean` 254 | 255 | #### Defined in 256 | 257 | [types/wallet.ts:200](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L200) 258 | 259 | ___ 260 | 261 | ### selectedFeeId 262 | 263 | • `Optional` **selectedFeeId**: [`EFeeId`](../enums/EFeeId.md) 264 | 265 | #### Defined in 266 | 267 | [types/wallet.ts:207](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L207) 268 | 269 | ___ 270 | 271 | ### storage 272 | 273 | • `Optional` **storage**: [`TStorage`](../README.md#tstorage) 274 | 275 | #### Defined in 276 | 277 | [types/wallet.ts:192](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L192) 278 | -------------------------------------------------------------------------------- /docs/markdown/interfaces/IWalletData.md: -------------------------------------------------------------------------------- 1 | [beignet](../README.md) / IWalletData 2 | 3 | # Interface: IWalletData 4 | 5 | ## Table of contents 6 | 7 | ### Properties 8 | 9 | - [addressIndex](IWalletData.md#addressindex) 10 | - [addressType](IWalletData.md#addresstype) 11 | - [addresses](IWalletData.md#addresses) 12 | - [balance](IWalletData.md#balance) 13 | - [blacklistedUtxos](IWalletData.md#blacklistedutxos) 14 | - [boostedTransactions](IWalletData.md#boostedtransactions) 15 | - [changeAddressIndex](IWalletData.md#changeaddressindex) 16 | - [changeAddresses](IWalletData.md#changeaddresses) 17 | - [feeEstimates](IWalletData.md#feeestimates) 18 | - [header](IWalletData.md#header) 19 | - [id](IWalletData.md#id) 20 | - [lastUsedAddressIndex](IWalletData.md#lastusedaddressindex) 21 | - [lastUsedChangeAddressIndex](IWalletData.md#lastusedchangeaddressindex) 22 | - [selectedFeeId](IWalletData.md#selectedfeeid) 23 | - [transaction](IWalletData.md#transaction) 24 | - [transactions](IWalletData.md#transactions) 25 | - [unconfirmedTransactions](IWalletData.md#unconfirmedtransactions) 26 | - [utxos](IWalletData.md#utxos) 27 | 28 | ## Properties 29 | 30 | ### addressIndex 31 | 32 | • **addressIndex**: [`TAddressTypeContent`](../README.md#taddresstypecontent)<[`IAddress`](IAddress.md)\> 33 | 34 | #### Defined in 35 | 36 | [types/wallet.ts:159](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L159) 37 | 38 | ___ 39 | 40 | ### addressType 41 | 42 | • **addressType**: [`EAddressType`](../enums/EAddressType.md) 43 | 44 | #### Defined in 45 | 46 | [types/wallet.ts:155](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L155) 47 | 48 | ___ 49 | 50 | ### addresses 51 | 52 | • **addresses**: [`TAddressTypeContent`](../README.md#taddresstypecontent)<[`IAddresses`](IAddresses.md)\> 53 | 54 | #### Defined in 55 | 56 | [types/wallet.ts:157](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L157) 57 | 58 | ___ 59 | 60 | ### balance 61 | 62 | • **balance**: `number` 63 | 64 | #### Defined in 65 | 66 | [types/wallet.ts:169](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L169) 67 | 68 | ___ 69 | 70 | ### blacklistedUtxos 71 | 72 | • **blacklistedUtxos**: [`IUtxo`](IUtxo.md)[] 73 | 74 | #### Defined in 75 | 76 | [types/wallet.ts:164](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L164) 77 | 78 | ___ 79 | 80 | ### boostedTransactions 81 | 82 | • **boostedTransactions**: [`IBoostedTransactions`](IBoostedTransactions.md) 83 | 84 | #### Defined in 85 | 86 | [types/wallet.ts:167](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L167) 87 | 88 | ___ 89 | 90 | ### changeAddressIndex 91 | 92 | • **changeAddressIndex**: [`TAddressTypeContent`](../README.md#taddresstypecontent)<[`IAddress`](IAddress.md)\> 93 | 94 | #### Defined in 95 | 96 | [types/wallet.ts:160](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L160) 97 | 98 | ___ 99 | 100 | ### changeAddresses 101 | 102 | • **changeAddresses**: [`TAddressTypeContent`](../README.md#taddresstypecontent)<[`IAddresses`](IAddresses.md)\> 103 | 104 | #### Defined in 105 | 106 | [types/wallet.ts:158](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L158) 107 | 108 | ___ 109 | 110 | ### feeEstimates 111 | 112 | • **feeEstimates**: [`IOnchainFees`](IOnchainFees.md) 113 | 114 | #### Defined in 115 | 116 | [types/wallet.ts:171](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L171) 117 | 118 | ___ 119 | 120 | ### header 121 | 122 | • **header**: [`IHeader`](IHeader.md) 123 | 124 | #### Defined in 125 | 126 | [types/wallet.ts:156](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L156) 127 | 128 | ___ 129 | 130 | ### id 131 | 132 | • **id**: `string` 133 | 134 | #### Defined in 135 | 136 | [types/wallet.ts:154](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L154) 137 | 138 | ___ 139 | 140 | ### lastUsedAddressIndex 141 | 142 | • **lastUsedAddressIndex**: [`TAddressTypeContent`](../README.md#taddresstypecontent)<[`IAddress`](IAddress.md)\> 143 | 144 | #### Defined in 145 | 146 | [types/wallet.ts:161](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L161) 147 | 148 | ___ 149 | 150 | ### lastUsedChangeAddressIndex 151 | 152 | • **lastUsedChangeAddressIndex**: [`TAddressTypeContent`](../README.md#taddresstypecontent)<[`IAddress`](IAddress.md)\> 153 | 154 | #### Defined in 155 | 156 | [types/wallet.ts:162](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L162) 157 | 158 | ___ 159 | 160 | ### selectedFeeId 161 | 162 | • **selectedFeeId**: [`EFeeId`](../enums/EFeeId.md) 163 | 164 | #### Defined in 165 | 166 | [types/wallet.ts:170](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L170) 167 | 168 | ___ 169 | 170 | ### transaction 171 | 172 | • **transaction**: [`ISendTransaction`](ISendTransaction.md) 173 | 174 | #### Defined in 175 | 176 | [types/wallet.ts:168](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L168) 177 | 178 | ___ 179 | 180 | ### transactions 181 | 182 | • **transactions**: [`IFormattedTransactions`](IFormattedTransactions.md) 183 | 184 | #### Defined in 185 | 186 | [types/wallet.ts:166](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L166) 187 | 188 | ___ 189 | 190 | ### unconfirmedTransactions 191 | 192 | • **unconfirmedTransactions**: [`IFormattedTransactions`](IFormattedTransactions.md) 193 | 194 | #### Defined in 195 | 196 | [types/wallet.ts:165](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L165) 197 | 198 | ___ 199 | 200 | ### utxos 201 | 202 | • **utxos**: [`IUtxo`](IUtxo.md)[] 203 | 204 | #### Defined in 205 | 206 | [types/wallet.ts:163](https://github.com/synonymdev/beignet/blob/3144d66/src/types/wallet.ts#L163) 207 | -------------------------------------------------------------------------------- /example/helpers.ts: -------------------------------------------------------------------------------- 1 | import { promises as fs } from 'fs'; 2 | import { 3 | TGetData, 4 | TSetData, 5 | IWalletData, 6 | EAvailableNetworks, 7 | EProtocol 8 | } from '../src'; 9 | import { err, Result, ok } from '../src'; 10 | import { getDefaultWalletData } from '../src'; 11 | 12 | export const getData: TGetData = async ( 13 | key: string 14 | ): Promise> => { 15 | try { 16 | const data = await fs.readFile(`example/walletData/${key}.json`, 'utf8'); 17 | const walletData: IWalletData[K] = JSON.parse(data); 18 | if (walletData) return ok(walletData); 19 | const defaultWalletData = getDefaultWalletData(); 20 | return ok(defaultWalletData[key]); 21 | } catch (e) { 22 | const defaultWalletData = getDefaultWalletData(); 23 | return ok(defaultWalletData[key]); 24 | } 25 | }; 26 | 27 | export const setData: TSetData = async ( 28 | key: string, 29 | value: IWalletData[K] 30 | ): Promise> => { 31 | try { 32 | const dir = 'example/walletData'; 33 | // Ensure that the directory exists 34 | await fs.mkdir(dir, { recursive: true }); 35 | 36 | await fs.writeFile(`${dir}/${key}.json`, JSON.stringify(value, null, 2)); 37 | return ok(true); 38 | } catch (e) { 39 | return err(e); 40 | } 41 | }; 42 | 43 | export const deleteDirectory = async ( 44 | dir = 'example/walletData' 45 | ): Promise => { 46 | try { 47 | await fs.rm(dir, { recursive: true, force: true }); 48 | } catch (e) { 49 | console.error(`Error deleting directory ${dir}: ${e}`); 50 | } 51 | }; 52 | 53 | export const onMessage = (id, data): void => { 54 | console.log(id); 55 | console.dir(data, { depth: null }); 56 | }; 57 | 58 | export const servers = { 59 | [EAvailableNetworks.mainnet]: [ 60 | { 61 | host: '35.187.18.233', 62 | ssl: 8900, 63 | tcp: 8911, 64 | protocol: EProtocol.ssl 65 | } 66 | ], 67 | [EAvailableNetworks.testnet]: [ 68 | { 69 | host: 'testnet.aranguren.org', 70 | ssl: 51002, 71 | tcp: 51001, 72 | protocol: EProtocol.ssl 73 | } 74 | ], 75 | [EAvailableNetworks.regtest]: [ 76 | { 77 | host: '35.233.47.252', 78 | ssl: 18484, 79 | tcp: 18483, 80 | protocol: EProtocol.tcp 81 | } 82 | ] 83 | }; 84 | -------------------------------------------------------------------------------- /example/index.ts: -------------------------------------------------------------------------------- 1 | import { 2 | EAvailableNetworks, 3 | ECoinSelectPreference, 4 | generateMnemonic, 5 | Wallet 6 | } from '../src'; 7 | import { getData, onMessage, servers, setData } from './helpers'; 8 | import * as repl from 'repl'; 9 | import net from 'net'; 10 | import tls from 'tls'; 11 | 12 | const network: EAvailableNetworks = EAvailableNetworks.mainnet; 13 | 14 | const runExample = async (mnemonic = generateMnemonic()): Promise => { 15 | // Create Wallet 16 | const createWalletResponse = await Wallet.create({ 17 | mnemonic, 18 | onMessage, 19 | network, 20 | storage: { 21 | getData, 22 | setData 23 | }, 24 | electrumOptions: { 25 | net, 26 | tls, 27 | servers: servers[network] 28 | }, 29 | gapLimitOptions: { 30 | lookAhead: 5, 31 | lookBehind: 5, 32 | lookAheadChange: 5, 33 | lookBehindChange: 5 34 | }, 35 | coinSelectPreference: ECoinSelectPreference.small 36 | }); 37 | if (createWalletResponse.isErr()) return; 38 | const wallet = createWalletResponse.value; 39 | 40 | // Get the wallet's balance. 41 | const balance = wallet.getBalance(); 42 | console.log('\nBalance: ', balance); 43 | 44 | // Get a receiving address. 45 | const address = await wallet.getAddress(); 46 | console.log('\nAddress:', address); 47 | 48 | // Get fee information to perform a transaction. 49 | // const feeInfo = wallet.getFeeInfo({ satsPerByte: 5 }); 50 | // if (feeInfo.isErr()) return; 51 | // console.log('\nFee Info:', feeInfo.value); 52 | 53 | // Get fee estimate in sats for a given satsPerByte to perform a transaction. 54 | // This is useful for quickly calculating how many sats are needed to perform a transaction when using a slider. 55 | // const txFeeInSats = getTxFee({ 56 | // satsPerByte: 5, 57 | // transactionByteCount: feeInfo.value.transactionByteCount 58 | // }); 59 | // console.log('\nFee In Sats:', txFeeInSats); 60 | 61 | // Create a transaction. 62 | // const sendRes = await wallet.send({ 63 | // address, 64 | // amount: 5000, 65 | // satsPerByte: 5, 66 | // broadcast: false // Mostly set to false for testing, but can also be used to return the raw transaction hex. 67 | // }); 68 | // if (sendRes.isErr()) return; 69 | // console.log('\nSend Res:', sendRes.value); 70 | 71 | // Decode the transaction to verify prior to broadcasting. 72 | // const decodeRes = decodeRawTransaction(sendRes.value, network); 73 | // if (decodeRes.isErr()) return; 74 | // console.log('\nDecode Transaction:'); 75 | // console.dir(decodeRes.value, { depth: null }); 76 | 77 | // Broadcast the transaction. 78 | // const broadcastRes = await wallet.electrum.broadcastTransaction({ 79 | // rawTx: createRes.value.hex 80 | // }); 81 | // console.log('\nBroadcast Response:', broadcastRes); 82 | // if (broadcastRes.isErr()) return; 83 | 84 | const r = repl.start('> '); 85 | r.context.wallet = wallet; 86 | }; 87 | 88 | const mnemonic = process.argv[2]; 89 | runExample(mnemonic).then(); 90 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "beignet", 3 | "version": "0.0.54", 4 | "description": "A self-custodial, JS Bitcoin wallet management library.", 5 | "main": "dist/index.js", 6 | "scripts": { 7 | "test": "yarn build && env mocha --exit -r ts-node/register 'tests/**/*.test.ts'", 8 | "test:boost": "yarn build && env mocha --exit -r ts-node/register 'tests/boost.test.ts'", 9 | "test:wallet": "yarn build && env mocha --exit -r ts-node/register 'tests/wallet.test.ts'", 10 | "test:receive": "yarn build && env mocha --exit -r ts-node/register 'tests/receive.test.ts'", 11 | "test:storage": "yarn build && env mocha --exit -r ts-node/register 'tests/storage.test.ts'", 12 | "test:electrum": "yarn build && env mocha --exit -r ts-node/register 'tests/electrum.test.ts'", 13 | "test:derivation": "yarn build && env mocha --exit -r ts-node/register 'tests/derivation.test.ts'", 14 | "test:transaction": "yarn build && env mocha --exit -r ts-node/register 'tests/transaction.test.ts'", 15 | "example": "ts-node example", 16 | "lint": "eslint . --ext .js,.jsx,.ts,.tsx", 17 | "lint:check": "eslint . --ext .js,.jsx,.ts,.tsx", 18 | "lint:fix": "eslint . --fix --ext .js,.jsx,.ts,.tsx", 19 | "tsc:check": "tsc -p tsconfig.json --noEmit", 20 | "build": "tsc", 21 | "docs:markdown": "npx typedoc --plugin typedoc-plugin-markdown --out docs/markdown src/index.ts", 22 | "docs:html": "npx typedoc --out docs/html", 23 | "docs": "npm run build && npm run docs:markdown && npm run docs:html" 24 | }, 25 | "repository": { 26 | "type": "git", 27 | "url": "git+https://github.com/synonymdev/beignet.git", 28 | "baseUrl": "https://github.com/synonymdev/beignet" 29 | }, 30 | "keywords": [ 31 | "Bitcoin", 32 | "wallet" 33 | ], 34 | "types": "dist/types/index.d.ts", 35 | "author": "synonymdev", 36 | "license": "MIT", 37 | "bugs": { 38 | "url": "https://github.com/synonymdev/beignet/issues" 39 | }, 40 | "homepage": "https://github.com/synonymdev/beignet#readme", 41 | "dependencies": { 42 | "@bitcoinerlab/secp256k1": "1.0.5", 43 | "bech32": "2.0.0", 44 | "bip21": "2.0.3", 45 | "bip32": "4.0.0", 46 | "bip39": "3.1.0", 47 | "bitcoin-address-validation": "2.2.3", 48 | "bitcoin-units": "0.3.0", 49 | "bitcoinjs-lib": "6.1.4", 50 | "ecpair": "2.1.0", 51 | "lodash.clonedeep": "4.5.0", 52 | "net": "1.0.2", 53 | "rn-electrum-client": "0.0.22" 54 | }, 55 | "devDependencies": { 56 | "@types/chai": "4.3.0", 57 | "@types/mocha": "9.0.0", 58 | "@types/node": "20.4.10", 59 | "@typescript-eslint/eslint-plugin": "5.6.0", 60 | "@typescript-eslint/parser": "5.6.0", 61 | "bitcoin-json-rpc": "1.3.3", 62 | "bw-electrum-client": "BlueWallet/rn-electrum-client#47acb51149e97fab249c3f8a314f708dbee4fb6e", 63 | "chai": "4.3.4", 64 | "eslint": "8.4.1", 65 | "eslint-config-prettier": "9.0.0", 66 | "eslint-plugin-prettier": "5.0.0", 67 | "mocha": "10.1.0", 68 | "prettier": "3.0.2", 69 | "sinon": "18.0.0", 70 | "ts-node": "10.9.0", 71 | "typedoc": "0.24.8", 72 | "typedoc-plugin-markdown": "3.15.4", 73 | "typescript": "4.9" 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/electrum/constants.ts: -------------------------------------------------------------------------------- 1 | export const TEST_MNEMONIC = 2 | 'decorate grass round powder swarm syrup identify resemble mass online grunt cruise'; 3 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './wallet/index'; 2 | export * from './types'; 3 | export * from './utils'; 4 | export * from './electrum'; 5 | export * from './transaction'; 6 | export * from './utils/result'; 7 | -------------------------------------------------------------------------------- /src/shapes/electrum.ts: -------------------------------------------------------------------------------- 1 | import { TMessageKeys } from '../types'; 2 | 3 | export const onMessageKeys: { [K in TMessageKeys]: K } = { 4 | newBlock: 'newBlock', 5 | transactionReceived: 'transactionReceived', 6 | transactionConfirmed: 'transactionConfirmed', 7 | transactionSent: 'transactionSent', 8 | rbf: 'rbf', 9 | reorg: 'reorg', 10 | connectedToElectrum: 'connectedToElectrum' 11 | }; 12 | 13 | export const POLLING_INTERVAL = 1000 * 10; 14 | -------------------------------------------------------------------------------- /src/shapes/index.ts: -------------------------------------------------------------------------------- 1 | export * from './wallet'; 2 | export * from './electrum'; 3 | -------------------------------------------------------------------------------- /src/shapes/wallet.ts: -------------------------------------------------------------------------------- 1 | import { 2 | IAddresses, 3 | TAddressTypeContent, 4 | IHeader, 5 | TAddressTypes, 6 | IOnchainFees 7 | } from '../types'; 8 | import cloneDeep from 'lodash.clonedeep'; 9 | import { 10 | EBoostType, 11 | IAddress, 12 | ISendTransaction, 13 | IWalletData, 14 | EAddressType 15 | } from '../types'; 16 | import { EFeeId } from '../types'; 17 | 18 | export const addressTypes: Readonly = { 19 | [EAddressType.p2wpkh]: { 20 | type: EAddressType.p2wpkh, 21 | path: "m/84'/0'/0'/0/0", 22 | name: 'Native Segwit Bech32', 23 | shortName: 'Native Segwit', 24 | description: 'Pay-to-witness-public-key-hash', 25 | example: '(bc1x...)' 26 | }, 27 | [EAddressType.p2sh]: { 28 | type: EAddressType.p2sh, 29 | path: "m/49'/0'/0'/0/0", 30 | name: 'Nested Segwit', 31 | shortName: 'Segwit', 32 | description: 'Pay-to-Script-Hash', 33 | example: '(3x...)' 34 | }, 35 | [EAddressType.p2pkh]: { 36 | type: EAddressType.p2pkh, 37 | path: "m/44'/0'/0'/0/0", 38 | name: 'Legacy', 39 | shortName: 'Legacy', 40 | description: 'Pay-to-public-key-hash', 41 | example: '(1x...)' 42 | }, 43 | [EAddressType.p2tr]: { 44 | type: EAddressType.p2tr, 45 | path: "m/86'/0'/0'/0/0", 46 | name: 'Taproot', 47 | shortName: 'Taproot', 48 | description: 'Taproot Address', 49 | example: '(bc1px...)' 50 | } 51 | }; 52 | 53 | export const defaultAddressContent: Readonly = { 54 | index: -1, 55 | path: '', 56 | address: '', 57 | scriptHash: '', 58 | publicKey: '' 59 | }; 60 | 61 | export const defaultSendTransaction: ISendTransaction = { 62 | outputs: [], 63 | inputs: [], 64 | changeAddress: '', 65 | fiatAmount: 0, 66 | fee: 512, 67 | satsPerByte: 2, 68 | message: '', 69 | label: '', 70 | rbf: false, 71 | boostType: EBoostType.cpfp, 72 | minFee: 1, 73 | max: false, 74 | tags: [], 75 | lightningInvoice: '', 76 | selectedFeeId: EFeeId.none 77 | }; 78 | 79 | export const getDefaultSendTransaction = (): ISendTransaction => { 80 | return cloneDeep(defaultSendTransaction); 81 | }; 82 | 83 | export const getAddressTypeContent = ( 84 | data: T 85 | ): Readonly> => { 86 | const addressTypeKeys = Object.values(EAddressType); 87 | const content = {} as TAddressTypeContent; 88 | 89 | addressTypeKeys.forEach((addressType) => { 90 | content[addressType] = data; 91 | }); 92 | 93 | return cloneDeep(content); 94 | }; 95 | 96 | export const getDefaultHeader = (): IHeader => { 97 | return cloneDeep({ 98 | height: 0, 99 | hash: '', 100 | hex: '' 101 | }); 102 | }; 103 | 104 | export const defaultWalletData: Readonly = { 105 | id: '', 106 | addressType: EAddressType.p2wpkh, 107 | header: getDefaultHeader(), 108 | addresses: getAddressTypeContent({}), 109 | changeAddresses: getAddressTypeContent({}), 110 | addressIndex: getAddressTypeContent(defaultAddressContent), 111 | changeAddressIndex: getAddressTypeContent(defaultAddressContent), 112 | lastUsedAddressIndex: getAddressTypeContent(defaultAddressContent), 113 | lastUsedChangeAddressIndex: getAddressTypeContent( 114 | defaultAddressContent 115 | ), 116 | utxos: [], 117 | blacklistedUtxos: [], 118 | unconfirmedTransactions: {}, 119 | transactions: {}, 120 | boostedTransactions: {}, 121 | transaction: getDefaultSendTransaction(), 122 | balance: 0, 123 | selectedFeeId: EFeeId.normal, 124 | feeEstimates: { 125 | fast: 5, 126 | normal: 4, 127 | slow: 3, 128 | minimum: 2, 129 | timestamp: 0 130 | } 131 | }; 132 | 133 | export const defaultFeesShape: IOnchainFees = { 134 | //On-chain fees in sats/vbyte 135 | fast: 4, // 10-20 mins 136 | normal: 3, // 20-60 mins 137 | slow: 2, // 1-2 hrs 138 | minimum: 1, 139 | timestamp: Date.now() - 60 * 30 * 1000 - 1 140 | }; 141 | 142 | export const getAddressTypes = (): EAddressType[] => { 143 | return cloneDeep(Object.values(EAddressType)); 144 | }; 145 | -------------------------------------------------------------------------------- /src/types/electrum.ts: -------------------------------------------------------------------------------- 1 | import { 2 | EAvailableNetworks, 3 | IAddress, 4 | IGetAddressBalanceRes, 5 | ITransaction, 6 | IUtxo 7 | } from './wallet'; 8 | 9 | export type Net = typeof import('net'); 10 | export type Tls = typeof import('tls'); 11 | 12 | export type TElectrumNetworks = 'bitcoin' | 'bitcoinTestnet' | 'bitcoinRegtest'; 13 | export enum EElectrumNetworks { 14 | bitcoin = 'bitcoin', 15 | bitcoinTestnet = 'bitcoinTestnet', 16 | bitcoinRegtest = 'bitcoinRegtest' 17 | } 18 | export type TConnectToElectrumRes = string; 19 | 20 | export interface IElectrumGetAddressBalanceRes extends IGetAddressBalanceRes { 21 | error: boolean; 22 | } 23 | 24 | export type TServer = { 25 | host: string; 26 | ssl: number; 27 | tcp: number; 28 | protocol: EProtocol; 29 | }; 30 | export type TProtocol = 'tcp' | 'ssl'; 31 | export enum EProtocol { 32 | tcp = 'tcp', 33 | ssl = 'ssl' 34 | } 35 | 36 | export enum EScanningStrategy { 37 | all = 'all', // Scan all addresses/scripthashes 38 | 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 39 | startingIndex = 'startingIndex', // Scan all addresses/scripthashes starting from the provided index. If higher than the current index, it will be ignored 40 | singleIndex = 'singleIndex' // Scan the single provided address/scripthash 41 | } 42 | 43 | export interface IGetUtxosResponse { 44 | utxos: IUtxo[]; 45 | balance: number; 46 | } 47 | 48 | export type TUnspentAddressScriptHashData = { 49 | [x: string]: IUtxo | IAddress; 50 | }; 51 | 52 | export type TTxResult = { 53 | tx_hash: string; 54 | height: number; 55 | }; 56 | 57 | export interface IGetAddressScriptHashesHistoryResponse { 58 | data: TTxResponse[]; 59 | error: boolean; 60 | id: number; 61 | method: string; 62 | network: string; 63 | } 64 | 65 | export type TTxResponse = { 66 | data: IAddress; 67 | id: number; 68 | jsonrpc: string; 69 | param: string; 70 | result: TTxResult[]; 71 | }; 72 | 73 | export interface IGetAddressTxResponse { 74 | data: TAddressTxResponse[]; 75 | error: boolean; 76 | id: number; 77 | method: string; 78 | network: string; 79 | } 80 | export type TAddressTxResponse = { 81 | data: string; 82 | id: number; 83 | jsonrpc: string; 84 | param: string; 85 | result: TTxResult[]; 86 | error?: { code: number; message: string }; 87 | }; 88 | 89 | export interface IGetAddressScriptHashBalances { 90 | error: boolean; 91 | data: 92 | | Array<{ 93 | id: number; 94 | jsonrpc: string; 95 | result: { 96 | confirmed: number; 97 | unconfirmed: number; 98 | }; 99 | param: string; 100 | data: Record; 101 | }> 102 | | string; 103 | id: number; 104 | method: string; 105 | network: EElectrumNetworks; 106 | } 107 | 108 | export interface IGetAddressHistoryResponse extends TTxResult, IAddress {} 109 | 110 | export interface IHeader { 111 | height: number; 112 | hash: string; 113 | hex: string; 114 | } 115 | 116 | export interface INewBlock { 117 | height: number; 118 | hex: string; 119 | } 120 | 121 | export interface IGetHeaderResponse { 122 | id: number; 123 | error: boolean; 124 | method: 'getHeader'; 125 | data: string; 126 | network: EAvailableNetworks; 127 | } 128 | 129 | export interface IGetTransactionsFromInputs { 130 | error: boolean; 131 | id: number; 132 | method: string; 133 | network: string; 134 | data: ITransaction<{ 135 | tx_hash: string; 136 | vout: number; 137 | }>[]; 138 | } 139 | 140 | export interface ISubscribeToHeader { 141 | data: { 142 | height: number; 143 | hex: string; 144 | }; 145 | error: boolean; 146 | id: string; 147 | method: string; 148 | } 149 | 150 | export interface ISubscribeToAddress { 151 | data: { 152 | id: number; 153 | jsonrpc: string; 154 | result: null; 155 | }; 156 | error: boolean; 157 | id: number; 158 | method: string; 159 | } 160 | 161 | export type TSubscribedReceive = [string, string]; 162 | 163 | export interface IFormattedPeerData { 164 | ip?: string; 165 | host: string; 166 | version?: string; 167 | ssl: string | number; 168 | tcp: string | number; 169 | } 170 | 171 | export interface IPeerData { 172 | host: string; 173 | port: string; 174 | protocol: TProtocol; 175 | } 176 | 177 | export type ElectrumConnectionPubSub = { 178 | publish: (isConnected: boolean) => void; 179 | subscribe: ( 180 | callback: (isConnected: boolean) => void 181 | ) => ElectrumConnectionSubscription; 182 | }; 183 | 184 | export type ElectrumConnectionSubscription = { 185 | remove(): void; 186 | }; 187 | 188 | export type TGetAddressHistory = { txid: string; height: number }; 189 | 190 | export type TUnspentAddressScriptHash = { 191 | height: number; 192 | tx_hash: string; 193 | tx_pos: number; 194 | value: number; 195 | }; 196 | 197 | export type TUnspentAddressScriptHashResult = { 198 | id: number; 199 | jsonrpc: string; 200 | result: TUnspentAddressScriptHash[]; 201 | param: string; 202 | data: IAddress; 203 | }; 204 | 205 | export type TUnspentAddressScriptHashResponse = { 206 | id: number; 207 | error: boolean; 208 | method: string; 209 | data: TUnspentAddressScriptHashResult[]; 210 | network: string; 211 | }; 212 | -------------------------------------------------------------------------------- /src/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from './wallet'; 2 | export * from './electrum'; 3 | export * from './transaction'; 4 | -------------------------------------------------------------------------------- /src/types/transaction.ts: -------------------------------------------------------------------------------- 1 | import { 2 | EAddressType, 3 | IOutput, 4 | ISendTransaction, 5 | IUtxo, 6 | IVin, 7 | IVout 8 | } from './wallet'; 9 | import { BIP32Interface } from 'bip32'; 10 | import { Psbt } from 'bitcoinjs-lib'; 11 | import { Result } from '../utils'; 12 | import { ECPairInterface } from 'ecpair'; 13 | 14 | export interface ICreateTransaction { 15 | transactionData?: ISendTransaction; 16 | shuffleOutputs?: boolean; 17 | runCoinSelect?: boolean; 18 | } 19 | 20 | export interface IAddInput { 21 | psbt: Psbt; 22 | keyPair: BIP32Interface | ECPairInterface; 23 | input: IUtxo; 24 | } 25 | 26 | export interface ITargets { 27 | value: number; // Amount denominated in sats. 28 | index: number; // Used to specify which output to update or edit when using updateSendTransaction. 29 | address?: string; // Amount denominated in sats. 30 | script?: Buffer; 31 | } 32 | 33 | export interface ISetupTransaction { 34 | inputTxHashes?: string[]; // Used to pre-specify inputs to use by tx_hash 35 | utxos?: IUtxo[]; // Used to pre-specify utxos to use 36 | rbf?: boolean; // Enable or disable rbf 37 | satsPerByte?: number; // Used to specify the fee rate in sats per vbyte 38 | outputs?: IOutput[]; // Used to pre-specify outputs to use 39 | } 40 | 41 | export enum EFeeId { 42 | fast = 'fast', 43 | normal = 'normal', 44 | slow = 'slow', 45 | custom = 'custom', 46 | none = 'none' 47 | } 48 | 49 | export type TSetupTransactionResponse = Result>; 50 | 51 | export type TDecodeRawTx = { 52 | txid: string; 53 | tx_hash: string; 54 | size: number; 55 | vsize: number; 56 | weight: number; 57 | version: number; 58 | locktime: number; 59 | vin: IVin[]; 60 | vout: IVout[]; 61 | }; 62 | 63 | export type TGetTotalFeeObj = { 64 | totalFee: number; 65 | transactionByteCount: number; 66 | satsPerByte: number; 67 | maxSatPerByte: number; // Max sats per byte that can be used for a given transaction without exceeding 50% of the balance. 68 | }; 69 | 70 | export type TGapLimitOptions = { 71 | lookAhead: number; 72 | lookBehind: number; 73 | lookAheadChange: number; 74 | lookBehindChange: number; 75 | }; 76 | 77 | export enum ECoinSelectPreference { 78 | small = 'small', 79 | large = 'large', 80 | consolidate = 'consolidate', 81 | firstInFirstOut = 'firstInFirstOut', 82 | lastInFirstOut = 'lastInFirstOut' 83 | } 84 | 85 | export interface ICoinSelectResponse { 86 | fee: number; 87 | inputs: IUtxo[]; 88 | outputs: IOutput[]; 89 | } 90 | 91 | export interface IAddressTypesIO { 92 | inputs: { 93 | [key in EAddressType]: number; 94 | }; 95 | outputs: { 96 | [key in EAddressType]: number; 97 | }; 98 | } 99 | -------------------------------------------------------------------------------- /src/utils/conversion.ts: -------------------------------------------------------------------------------- 1 | import { default as bitcoinUnits } from 'bitcoin-units'; 2 | 3 | /** 4 | * Converts a value in BTC to sats 5 | * @param {number} btc 6 | * @returns {number} 7 | */ 8 | export const btcToSats = (btc: number): number => { 9 | try { 10 | return Number(bitcoinUnits(btc, 'BTC').to('satoshi').value().toFixed(0)); 11 | } catch { 12 | return 0; 13 | } 14 | }; 15 | 16 | /** 17 | * Converts a value in sats to BTC 18 | * @param sats 19 | * @returns {number} 20 | */ 21 | export const satsToBtc = (sats: number): number => { 22 | return bitcoinUnits(sats, 'sats').to('BTC').value(); 23 | }; 24 | -------------------------------------------------------------------------------- /src/utils/derivation-path.ts: -------------------------------------------------------------------------------- 1 | import { 2 | EAddressType, 3 | EAvailableNetworks, 4 | IKeyDerivationPath, 5 | TKeyDerivationAccount, 6 | TKeyDerivationChange, 7 | TKeyDerivationCoinType, 8 | TKeyDerivationPurpose 9 | } from '../types'; 10 | import { addressTypes } from '../shapes'; 11 | import { err, ok, Result } from './result'; 12 | 13 | /** 14 | * Parses a key derivation path in string format Ex: "m/84'/0'/0'/0/0" and returns IKeyDerivationPath. 15 | * @param {string} keyDerivationPath 16 | * @param {TKeyDerivationPurpose | string} [purpose] 17 | * @param {boolean} [changeAddress] 18 | * @param {string} [index] 19 | * @param {TAvailableNetworks} [network] 20 | * @returns {Result} 21 | */ 22 | export const getKeyDerivationPathObject = ({ 23 | path = '', 24 | purpose, 25 | changeAddress, 26 | index, 27 | network 28 | }: { 29 | path: string; 30 | purpose?: TKeyDerivationPurpose; 31 | changeAddress?: boolean; 32 | index?: string; 33 | network: EAvailableNetworks; 34 | }): Result => { 35 | try { 36 | const parsedPath = path.replace(/'/g, '').split('/'); 37 | 38 | if (!purpose) { 39 | purpose = parsedPath[1] as TKeyDerivationPurpose; 40 | } 41 | 42 | let coinType = parsedPath[2] as TKeyDerivationCoinType; 43 | if (network) { 44 | coinType = 45 | network.toLocaleLowerCase() === EAvailableNetworks.bitcoin ? '0' : '1'; 46 | } 47 | 48 | const account = parsedPath[3] as TKeyDerivationAccount; 49 | 50 | let change = parsedPath[4] as TKeyDerivationChange; 51 | if (changeAddress !== undefined) { 52 | change = changeAddress ? '1' : '0'; 53 | } 54 | 55 | if (!index) { 56 | index = parsedPath[5]; 57 | } 58 | 59 | return ok({ 60 | purpose, 61 | coinType, 62 | account, 63 | change, 64 | index 65 | }); 66 | } catch (e) { 67 | return err(e); 68 | } 69 | }; 70 | 71 | /** 72 | * Parses a key derivation path object and returns it in string format. Ex: "m/84'/0'/0'/0/0" 73 | * @param {IKeyDerivationPath} path 74 | * @param {TKeyDerivationPurpose | string} [purpose] 75 | * @param {boolean} [changeAddress] 76 | * @param {number} [accountType] 77 | * @param {string} [addressIndex] 78 | * @returns {Result} 79 | */ 80 | export const getKeyDerivationPathString = ({ 81 | addressType = EAddressType.p2wpkh, 82 | path, 83 | purpose, 84 | accountType, 85 | changeAddress = false, 86 | index = '0', 87 | network 88 | }: { 89 | addressType: EAddressType; 90 | path?: IKeyDerivationPath; 91 | purpose?: TKeyDerivationPurpose; 92 | accountType?: string | number; 93 | changeAddress?: boolean; 94 | index?: string | number; 95 | network: EAvailableNetworks; 96 | }): Result => { 97 | try { 98 | if (!path) { 99 | // Get default path object for the network and set it from there. 100 | const str = addressTypes[addressType].path; 101 | const res = getKeyDerivationPathObject({ path: str, network }); 102 | if (res.isErr()) { 103 | return err(res.error.message); 104 | } 105 | path = res.value; 106 | } 107 | //Specifically specifying purpose will override the default accountType purpose value. 108 | if (purpose !== undefined) { 109 | path.purpose = purpose; 110 | } 111 | 112 | path.coinType = 113 | network.toLocaleLowerCase() === EAvailableNetworks.bitcoin ? '0' : '1'; 114 | 115 | if (accountType !== undefined) { 116 | if (typeof accountType === 'number') { 117 | path.account = String(accountType); 118 | } 119 | path.account = 120 | typeof accountType === 'number' ? String(accountType) : accountType; 121 | } else { 122 | path.account = '0'; 123 | } 124 | 125 | path.change = changeAddress ? '1' : '0'; 126 | 127 | if (!index) { 128 | index = '0'; 129 | } 130 | if (typeof index === 'number') { 131 | index = String(index); 132 | } 133 | 134 | return ok( 135 | `m/${path.purpose}'/${path.coinType}'/${path.account}'/${path.change}/${index}` 136 | ); 137 | } catch (e) { 138 | return err(e); 139 | } 140 | }; 141 | 142 | /** 143 | * Returns the address type from the specified derivation path. 144 | * @param {string | IKeyDerivationPath} path 145 | * @returns {Result} 146 | */ 147 | export const getAddressTypeFromPath = ( 148 | path: string | IKeyDerivationPath 149 | ): Result => { 150 | try { 151 | let purpose; 152 | if (typeof path === 'object') { 153 | purpose = path.purpose; 154 | } else if (typeof path === 'string') { 155 | const parsedPathString = path.replace(/'/g, '').split('/'); 156 | purpose = parsedPathString[1]; 157 | } 158 | switch (purpose) { 159 | case '44': 160 | return ok(EAddressType.p2pkh); 161 | case '49': 162 | return ok(EAddressType.p2sh); 163 | case '84': 164 | return ok(EAddressType.p2wpkh); 165 | case '86': 166 | return ok(EAddressType.p2tr); 167 | default: 168 | return err('Invalid path'); 169 | } 170 | } catch (e) { 171 | return err(e); 172 | } 173 | }; 174 | -------------------------------------------------------------------------------- /src/utils/electrum.ts: -------------------------------------------------------------------------------- 1 | import * as electrum from 'rn-electrum-client/helpers'; 2 | import { err, ok, Result } from './result'; 3 | 4 | import { 5 | EAvailableNetworks, 6 | EElectrumNetworks, 7 | ElectrumConnectionPubSub, 8 | ElectrumConnectionSubscription, 9 | IAddresses, 10 | IFormattedPeerData, 11 | TProtocol 12 | } from '../types'; 13 | import * as hardcodedPeers from 'rn-electrum-client/helpers/peers.json'; 14 | 15 | const POLLING_INTERVAL = 1000 * 20; 16 | export const defaultElectrumPorts = ['51002', '50002', '51001', '50001']; 17 | 18 | /** 19 | * Returns the default port for the given network and protocol. 20 | * @param {EAvailableNetworks} [selectedNetwork] 21 | * @param {string} [protocol] 22 | * @returns {number} 23 | */ 24 | export const getDefaultPort = ( 25 | selectedNetwork: EAvailableNetworks, 26 | protocol: TProtocol 27 | ): number => { 28 | if (protocol === 'ssl') { 29 | return selectedNetwork === 'testnet' ? 51002 : 50002; 30 | } else { 31 | return selectedNetwork === 'testnet' ? 51001 : 50001; 32 | } 33 | }; 34 | 35 | /** 36 | * Returns the protocol for the given network and default port. 37 | * @param {string} [port] 38 | * @param {EAvailableNetworks} [network] 39 | * @returns {TProtocol | undefined} 40 | */ 41 | export const getProtocolForPort = ( 42 | port: string, 43 | network: EAvailableNetworks 44 | ): TProtocol | undefined => { 45 | if (port === '443') { 46 | return 'ssl'; 47 | } 48 | 49 | if (network === 'testnet') { 50 | return port === '51002' ? 'ssl' : 'tcp'; 51 | } 52 | 53 | return port === '50002' ? 'ssl' : 'tcp'; 54 | }; 55 | 56 | /** 57 | * Formats the peer data response from an Electrum server. 58 | * @param {[string, string, [string, string, string]]} data 59 | * @returns Result 60 | */ 61 | export const formatPeerData = ( 62 | data: [string, string, [string, string, string]] 63 | ): Result => { 64 | try { 65 | if (!data) { 66 | return err('No data provided.'); 67 | } 68 | if (data?.length !== 3) { 69 | return err('Invalid peer data'); 70 | } 71 | if (data[2]?.length < 2) { 72 | return err('Invalid peer data'); 73 | } 74 | const [ip, host, ports] = data; 75 | const [version, ssl, tcp] = ports; 76 | return ok({ 77 | ip, 78 | host, 79 | version, 80 | ssl, 81 | tcp 82 | }); 83 | } catch (e) { 84 | if (typeof e === 'string' || e instanceof Error) { 85 | return err(e); 86 | } 87 | return err('Unable to format peer data.'); 88 | } 89 | }; 90 | 91 | /** 92 | * Returns an array of peers. 93 | * If unable to acquire peers from an Electrum server the method will default to the hardcoded peers in peers.json. 94 | * @param {EAvailableNetworks} [selectedNetwork] 95 | * @returns Promise> 96 | */ 97 | export const getPeers = async ({ 98 | selectedNetwork 99 | }: { 100 | selectedNetwork: EAvailableNetworks; 101 | }): Promise> => { 102 | try { 103 | const response = await electrum.getPeers({ network: selectedNetwork }); 104 | if (!response.error) { 105 | // Return an array of peers provided by the currently connected electrum server. 106 | const peers: IFormattedPeerData[] = []; 107 | await Promise.all( 108 | response.data.map(async (peer) => { 109 | const formattedPeer = await formatPeerData(peer); 110 | if (formattedPeer.isOk()) { 111 | peers.push(formattedPeer.value); 112 | } 113 | }) 114 | ); 115 | if (peers?.length > 0) { 116 | return ok(peers); 117 | } 118 | } 119 | // No peers available grab hardcoded peers instead. 120 | return ok(hardcodedPeers[selectedNetwork]); 121 | } catch (e) { 122 | if (typeof e === 'string' || e instanceof Error) { 123 | return err(e); 124 | } 125 | return err('Unable to get peers.'); 126 | } 127 | }; 128 | 129 | /** 130 | * Background task that checks the connection to the Electrum server with a PubSub 131 | * If connection was lost this will try to reconnect in the specified interval 132 | * @param {() => Result} [connectToElectrum] 133 | * @returns {ElectrumConnectionPubSub} 134 | */ 135 | export const electrumConnection = (( 136 | connectToElectrum?: () => Result 137 | ): ElectrumConnectionPubSub => { 138 | const subscribers: Set<(isConnected: boolean) => void> = new Set(); 139 | let latestState: boolean | null = null; 140 | 141 | setInterval(async () => { 142 | try { 143 | const { error } = await electrum.pingServer(); 144 | 145 | if (error) { 146 | if (connectToElectrum) { 147 | console.log('Connection to Electrum Server lost, reconnecting...'); 148 | const response = await connectToElectrum(); 149 | 150 | if (response.isErr()) { 151 | electrumConnection.publish(false); 152 | } 153 | } 154 | } else { 155 | electrumConnection.publish(true); 156 | } 157 | } catch (e) { 158 | console.error(e); 159 | } 160 | }, POLLING_INTERVAL); 161 | 162 | const publish = (isConnected: boolean): void => { 163 | // Skip if no subscribers 164 | if (subscribers.size === 0) { 165 | return; 166 | } 167 | 168 | // Skip if state hasn't changed 169 | if (latestState === isConnected) { 170 | return; 171 | } 172 | 173 | latestState = isConnected; 174 | subscribers.forEach((callback) => callback(isConnected)); 175 | }; 176 | 177 | const subscribe = ( 178 | callback: (isConnected: boolean) => void 179 | ): ElectrumConnectionSubscription => { 180 | subscribers.add(callback); 181 | 182 | return { 183 | remove: (): void => { 184 | subscribers.delete(callback); 185 | } 186 | }; 187 | }; 188 | 189 | return { publish, subscribe }; 190 | })(); 191 | 192 | /** 193 | * Returns the network string for use with Electrum methods. 194 | * @param {EAvailableNetworks} [network] 195 | * @return {EElectrumNetworks} 196 | */ 197 | export const getElectrumNetwork = ( 198 | network: EAvailableNetworks 199 | ): EElectrumNetworks => { 200 | switch (network) { 201 | case 'bitcoin': 202 | return EElectrumNetworks.bitcoin; 203 | case 'testnet': 204 | return EElectrumNetworks.bitcoinTestnet; 205 | case 'regtest': 206 | return EElectrumNetworks.bitcoinRegtest; 207 | default: 208 | return EElectrumNetworks.bitcoinTestnet; 209 | } 210 | }; 211 | 212 | /** 213 | * Splits the addresses into chunks of the specified batch limit. 214 | * @param {IAddresses} addresses 215 | * @param {number} batchLimit 216 | * @returns {IAddresses[]} 217 | */ 218 | export const splitAddresses = ( 219 | addresses: IAddresses, 220 | batchLimit: number 221 | ): IAddresses[] => { 222 | const chunks: IAddresses[] = []; 223 | const scriptHashes = Object.keys(addresses); 224 | for (let i = 0; i < scriptHashes.length; i += batchLimit) { 225 | const chunk: IAddresses = {}; 226 | const chunkScriptHashes = scriptHashes.slice(i, i + batchLimit); 227 | for (const scriptHash of chunkScriptHashes) { 228 | chunk[scriptHash] = addresses[scriptHash]; 229 | } 230 | chunks.push(chunk); 231 | } 232 | return chunks; 233 | }; 234 | -------------------------------------------------------------------------------- /src/utils/helpers.ts: -------------------------------------------------------------------------------- 1 | import { 2 | EAddressType, 3 | EAvailableNetworks, 4 | IGetAddressesFromKeyPair, 5 | IGetAddressesFromPrivateKey, 6 | IKeyDerivationPath 7 | } from '../types'; 8 | import { address as bitcoinJSAddress, Network, networks } from 'bitcoinjs-lib'; 9 | import * as bip39 from 'bip39'; 10 | import * as bitcoin from 'bitcoinjs-lib'; 11 | import { availableNetworks, isValidBech32mEncodedString } from './wallet'; 12 | import { err, ok, Result } from './result'; 13 | import { addressTypes, getAddressTypes } from '../shapes'; 14 | import { getKeyDerivationPathObject } from './derivation-path'; 15 | import { ECPairFactory, ECPairInterface } from 'ecpair'; 16 | import * as ecc from '@bitcoinerlab/secp256k1'; 17 | import { BIP32Interface } from 'bip32'; 18 | import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371'; 19 | const ECPair = ECPairFactory(ecc); 20 | /** 21 | * Get address for a given scriptPubKey. 22 | * @param scriptPubKey 23 | * @param selectedNetwork 24 | * @returns {string} 25 | */ 26 | export const getAddressFromScriptPubKey = ( 27 | scriptPubKey: string, 28 | selectedNetwork: EAvailableNetworks 29 | ): string => { 30 | const network = networks[selectedNetwork]; 31 | return bitcoin.address.fromOutputScript( 32 | Buffer.from(scriptPubKey, 'hex'), 33 | network 34 | ); 35 | }; 36 | 37 | /** 38 | * Get sha256 hash of a given string. 39 | * @param {string} str 40 | * @returns {string} 41 | */ 42 | export const getSha256 = (str: string): string => { 43 | const buffer = Buffer.from(str, 'utf8'); 44 | const hash = bitcoin.crypto.sha256(buffer); 45 | return hash.toString('hex'); 46 | }; 47 | 48 | /** 49 | * Validate address for a given network. 50 | * If no address is provided, it will attempt to validate the address for all available networks. 51 | * @param {string} address 52 | * @param {EAvailableNetworks} network 53 | * @returns {{isValid: boolean, network: EAvailableNetworks}} 54 | */ 55 | export const validateAddress = ({ 56 | address, 57 | network 58 | }: { 59 | address: string; 60 | network?: EAvailableNetworks; 61 | }): { 62 | isValid: boolean; 63 | network: EAvailableNetworks; 64 | } => { 65 | try { 66 | //Validate address for all available networks 67 | let isValid = false; 68 | const availableNetworksList = availableNetworks(); 69 | 70 | //Validate address for a specific network 71 | if (network !== undefined) { 72 | try { 73 | bitcoinJSAddress.toOutputScript(address, networks[network]); 74 | return { isValid: true, network }; 75 | } catch { 76 | // In the event the normal check fails, determine if this is a taproot address. 77 | const taprootRes = isValidBech32mEncodedString(address); 78 | if (taprootRes.isValid && taprootRes.network === network) { 79 | return { isValid: taprootRes.isValid, network: taprootRes.network }; 80 | } 81 | } 82 | return { isValid: false, network }; 83 | } 84 | 85 | for (let i = 0; i < availableNetworksList.length; i++) { 86 | const validateRes = validateAddress({ 87 | address, 88 | network: availableNetworksList[i] 89 | }); 90 | if (validateRes.isValid) { 91 | isValid = validateRes.isValid; 92 | network = validateRes.network; 93 | break; 94 | } 95 | } 96 | return { isValid, network: network ?? EAvailableNetworks.bitcoin }; 97 | } catch { 98 | return { isValid: false, network: EAvailableNetworks.bitcoin }; 99 | } 100 | }; 101 | 102 | /** 103 | * Returns the derivation path object for the specified addressType and network. 104 | * @param {EAddressType} addressType 105 | * @param {EAvailableNetworks} [selectedNetwork] 106 | * @returns Result 107 | */ 108 | export const getKeyDerivationPath = ({ 109 | addressType, 110 | network 111 | }: { 112 | addressType: EAddressType; 113 | network: EAvailableNetworks; 114 | }): Result => { 115 | try { 116 | const keyDerivationPathResponse = getKeyDerivationPathObject({ 117 | network, 118 | path: addressTypes[addressType].path 119 | }); 120 | if (keyDerivationPathResponse.isErr()) { 121 | return err(keyDerivationPathResponse.error.message); 122 | } 123 | return ok(keyDerivationPathResponse.value); 124 | } catch (e) { 125 | return err(e); 126 | } 127 | }; 128 | 129 | /** 130 | * Get scriptHash for a given address 131 | * @param {string} address 132 | * @param {EAvailableNetworks} network 133 | * @returns {string} 134 | */ 135 | export const getScriptHash = ({ 136 | address, 137 | network 138 | }: { 139 | address: string; 140 | network: EAvailableNetworks; 141 | }): string => { 142 | try { 143 | const _network: Network = bitcoin.networks[network]; 144 | const script = bitcoin.address.toOutputScript(address, _network); 145 | const hash = bitcoin.crypto.sha256(script); 146 | const reversedHash = Buffer.from(hash.reverse()); 147 | return reversedHash.toString('hex'); 148 | } catch { 149 | return ''; 150 | } 151 | }; 152 | 153 | /** 154 | * Extends bip39's generateMnemonic function. 155 | * @param {number} [strength] 156 | * @param {(size: number) => Buffer} [rng] 157 | * @param {string[]} [wordlist] 158 | * @returns {string} 159 | */ 160 | export const generateMnemonic = ( 161 | strength?: number, 162 | rng?: (size: number) => Buffer, 163 | wordlist?: string[] 164 | ): string => { 165 | return bip39.generateMnemonic(strength, rng, wordlist); 166 | }; 167 | 168 | /** 169 | * Attempts to validate the provided mnemonic. 170 | * @param {string} mnemonic 171 | * @returns {boolean} 172 | */ 173 | export const validateMnemonic = (mnemonic = ''): boolean => { 174 | try { 175 | return bip39.validateMnemonic(mnemonic); 176 | } catch { 177 | return false; 178 | } 179 | }; 180 | 181 | /** 182 | * Determines if the two objects passed as params match. 183 | * @param obj1 184 | * @param obj2 185 | * @returns boolean 186 | */ 187 | export const objectsMatch = (obj1, obj2): boolean => { 188 | if (!obj1 || !obj2) { 189 | return false; 190 | } 191 | const obj1Length = Object.keys(obj1).length; 192 | const obj2Length = Object.keys(obj2).length; 193 | 194 | if (obj1Length === obj2Length) { 195 | return Object.keys(obj1).every( 196 | (key) => key in obj2 && obj2[key] === obj1[key] 197 | ); 198 | } else { 199 | return false; 200 | } 201 | }; 202 | 203 | /** 204 | * Get address from key pair. 205 | * @param {BIP32Interface | ECPairInterface} keyPair 206 | * @param {EAddressType} addressType 207 | * @param {Network} network 208 | * @returns {IGetAddressesFromKeyPair} 209 | */ 210 | export const getAddressFromKeyPair = ({ 211 | keyPair, 212 | addressType, 213 | network 214 | }: { 215 | keyPair: BIP32Interface | ECPairInterface; 216 | addressType: EAddressType; 217 | network: Network; 218 | }): Result => { 219 | let address = ''; 220 | switch (addressType) { 221 | case EAddressType.p2wpkh: 222 | //Get Bech32 (bc1) address 223 | address = 224 | bitcoin.payments.p2wpkh({ 225 | pubkey: keyPair.publicKey, 226 | network 227 | }).address ?? ''; 228 | break; 229 | case EAddressType.p2sh: 230 | //Get Segwit P2SH Address (3) 231 | address = 232 | bitcoin.payments.p2sh({ 233 | redeem: bitcoin.payments.p2wpkh({ 234 | pubkey: keyPair.publicKey, 235 | network 236 | }), 237 | network 238 | }).address ?? ''; 239 | break; 240 | //Get Legacy Address (1) 241 | case EAddressType.p2pkh: 242 | address = 243 | bitcoin.payments.p2pkh({ 244 | pubkey: keyPair.publicKey, 245 | network 246 | }).address ?? ''; 247 | break; 248 | case EAddressType.p2tr: 249 | const res = getTapRootAddressFromPublicKey({ 250 | publicKey: keyPair.publicKey, 251 | network 252 | }); 253 | if (res.isOk()) { 254 | address = res.value.address; 255 | } 256 | break; 257 | } 258 | if (!address) return err('Unable to get address from key pair.'); 259 | return ok({ 260 | address, 261 | publicKey: keyPair.publicKey.toString('hex') 262 | }); 263 | }; 264 | 265 | /** 266 | * Returns taproot address information from the provided public key. 267 | * @param {Buffer} publicKey 268 | * @param {Network} network 269 | * @returns {Result<{ address: string; output: Buffer; internalPubkey: Buffer; }>} 270 | */ 271 | export const getTapRootAddressFromPublicKey = ({ 272 | publicKey, 273 | network 274 | }: { 275 | publicKey: Buffer; 276 | network: Network; 277 | }): Result<{ address: string; output: Buffer; internalPubkey: Buffer }> => { 278 | try { 279 | const internalPubkey = toXOnly(publicKey); 280 | const { address, output } = bitcoin.payments.p2tr({ 281 | internalPubkey, 282 | network 283 | }); 284 | if (!address) return err('Unable to get address from key pair.'); 285 | if (!output) return err('Unable to get output from key pair.'); 286 | return ok({ address, output, internalPubkey }); 287 | } catch (e) { 288 | return err(e); 289 | } 290 | }; 291 | 292 | /** 293 | * Get addresses from a private key. 294 | * @param {string} privateKey 295 | * @param {EAddressType[]} [addrTypes] 296 | * @param {Network} [network] 297 | */ 298 | export const getAddressesFromPrivateKey = ({ 299 | privateKey, 300 | addrTypes = getAddressTypes(), 301 | network = bitcoin.networks.bitcoin 302 | }: { 303 | privateKey: string; 304 | addrTypes?: EAddressType[]; 305 | network?: Network; 306 | }): Result => { 307 | try { 308 | if (!privateKey) return err('No private key provided.'); 309 | const keyPair = ECPair.fromWIF(privateKey, network); 310 | const response = addrTypes.map((addressType) => { 311 | const addressInfo = getAddressFromKeyPair({ 312 | keyPair, 313 | addressType, 314 | network 315 | }); 316 | if (addressInfo.isErr()) throw new Error(addressInfo.error.message); 317 | return addressInfo.value; 318 | }); 319 | if (!response) return err('Unable to get addresses from private key.'); 320 | return ok({ 321 | keyPair, 322 | addresses: response 323 | }); 324 | } catch (e) { 325 | return err(e); 326 | } 327 | }; 328 | 329 | export const sleep = (ms): Promise => { 330 | return new Promise((resolve) => { 331 | setTimeout(resolve, ms); 332 | }); 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; 348 | -------------------------------------------------------------------------------- /src/utils/index.ts: -------------------------------------------------------------------------------- 1 | export * from './wallet'; 2 | export * from './helpers'; 3 | export * from './electrum'; 4 | export * from './derivation-path'; 5 | export * from './transaction'; 6 | export * from './result'; 7 | -------------------------------------------------------------------------------- /src/utils/result.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Represents a result that can be successful (Ok) or contain an error (Err). 3 | */ 4 | export type Result = Ok | Err; 5 | 6 | /** 7 | * Represents a successful result containing a value of type T. 8 | */ 9 | class Ok { 10 | /** 11 | * Constructs an Ok result containing the given value. 12 | * @param value - The value contained in the result. 13 | */ 14 | public constructor(public readonly value: T) {} 15 | 16 | /** 17 | * Checks if the result is of type Ok. 18 | * @returns True if the result is of type Ok, otherwise false. 19 | */ 20 | public isOk(): this is Ok { 21 | return true; 22 | } 23 | 24 | /** 25 | * Checks if the result is of type Err. 26 | * @returns False, as the result is of type Ok. 27 | */ 28 | public isErr(): this is Err { 29 | return false; 30 | } 31 | } 32 | 33 | /** 34 | * Represents an error result containing an error message. 35 | */ 36 | class Err { 37 | /** 38 | * Constructs an Err result containing the given error. 39 | * @param error - The error contained in the result. 40 | */ 41 | public constructor(public readonly error: Error) { 42 | console.log(error); 43 | } 44 | 45 | /** 46 | * Checks if the result is of type Ok. 47 | * @returns False, as the result is of type Err. 48 | */ 49 | public isOk(): this is Ok { 50 | return false; 51 | } 52 | 53 | /** 54 | * Checks if the result is of type Err. 55 | * @returns True if the result is of type Err, otherwise false. 56 | */ 57 | public isErr(): this is Err { 58 | return true; 59 | } 60 | } 61 | 62 | /** 63 | * Construct a new Ok result value. 64 | * @param value - The value to be wrapped in an Ok result. 65 | * @returns An Ok result containing the given value. 66 | */ 67 | export const ok = (value: T): Ok => new Ok(value); 68 | 69 | /** 70 | * Construct a new Err result value. 71 | * @param error - The error message or Error object to be wrapped in an Err result. 72 | * @returns An Err result containing the given error. 73 | */ 74 | export const err = (error: Error | string): Err => { 75 | if (typeof error === 'string') { 76 | return new Err(new Error(error)); 77 | } 78 | return new Err(error); 79 | }; 80 | -------------------------------------------------------------------------------- /src/wallet/constants.ts: -------------------------------------------------------------------------------- 1 | import { EAddressType } from '../types'; 2 | 3 | export const BITKIT_WALLET_SEED_HASH_PREFIX = Buffer.from( 4 | '@Bitkit/wallet-uuid' 5 | ); 6 | 7 | export const WALLET_ID_PREFIX = Buffer.from('@Beignet/wallet-id'); 8 | 9 | //How many addresses to generate when more are needed. 10 | export const GENERATE_ADDRESS_AMOUNT = 5; 11 | 12 | // TODO: Add this as a settings for users to adjust when needed. 13 | export const GAP_LIMIT = 20; 14 | export const GAP_LIMIT_CHANGE = 20; 15 | 16 | export const DUST_LIMITS = { 17 | [EAddressType.p2pkh]: 546, 18 | [EAddressType.p2sh]: 546, 19 | [EAddressType.p2wpkh]: 294, 20 | [EAddressType.p2tr]: 294 21 | }; 22 | 23 | export const TRANSACTION_DEFAULTS = { 24 | recommendedBaseFee: 256, // Total recommended tx base fee in sats 25 | dustLimit: 546 // Minimum value in sats for an output. Outputs below the dust limit may not be processed because the fees required to include them in a block would be greater than the value of the transaction itself. 26 | }; 27 | 28 | export const BLOCKTANK_HOST = 'https://api.stag.blocktank.to'; 29 | -------------------------------------------------------------------------------- /tests/boost.test.ts: -------------------------------------------------------------------------------- 1 | import BitcoinJsonRpc from 'bitcoin-json-rpc'; 2 | import { expect } from 'chai'; 3 | import net from 'net'; 4 | import tls from 'tls'; 5 | 6 | import { 7 | EAddressType, 8 | EAvailableNetworks, 9 | EBoostType, 10 | EProtocol, 11 | generateMnemonic, 12 | Wallet 13 | } from '../'; 14 | import { 15 | bitcoinURL, 16 | electrumHost, 17 | electrumPort, 18 | initWaitForElectrumToSync, 19 | TWaitForElectrum 20 | } from './utils'; 21 | 22 | const testTimeout = 60000; 23 | let wallet: Wallet; 24 | let waitForElectrum: TWaitForElectrum; 25 | const rpc = new BitcoinJsonRpc(bitcoinURL); 26 | const failure = { canBoost: false, rbf: false, cpfp: false }; 27 | 28 | describe('Boost', async function () { 29 | this.timeout(testTimeout); 30 | 31 | beforeEach(async function () { 32 | this.timeout(testTimeout); 33 | 34 | let balance = await rpc.getBalance(); 35 | const address = await rpc.getNewAddress(); 36 | await rpc.generateToAddress(1, address); 37 | 38 | while (balance < 10) { 39 | await rpc.generateToAddress(10, address); 40 | balance = await rpc.getBalance(); 41 | } 42 | 43 | waitForElectrum = await initWaitForElectrumToSync( 44 | { host: electrumHost, port: electrumPort }, 45 | bitcoinURL 46 | ); 47 | 48 | await waitForElectrum(); 49 | 50 | const mnemonic = generateMnemonic(); 51 | 52 | const res = await Wallet.create({ 53 | rbf: true, 54 | mnemonic, 55 | // mnemonic: 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about', 56 | network: EAvailableNetworks.regtest, 57 | addressType: EAddressType.p2wpkh, 58 | electrumOptions: { 59 | servers: [ 60 | { 61 | host: '127.0.0.1', 62 | ssl: 60002, 63 | tcp: 60001, 64 | protocol: EProtocol.tcp 65 | } 66 | ], 67 | net, 68 | tls 69 | }, 70 | // reduce gap limit to speed up tests 71 | gapLimitOptions: { 72 | lookAhead: 2, 73 | lookBehind: 2, 74 | lookAheadChange: 2, 75 | lookBehindChange: 2 76 | } 77 | }); 78 | if (res.isErr()) { 79 | throw res.error; 80 | } 81 | wallet = res.value; 82 | await wallet.refreshWallet({}); 83 | }); 84 | 85 | afterEach(async function () { 86 | await wallet?.electrum?.disconnect(); 87 | }); 88 | 89 | it('Should fail in some cases.', async () => { 90 | // tx not found 91 | const b1 = wallet.canBoost('fake-txid'); 92 | expect(b1).to.deep.equal(failure); 93 | 94 | // balance is 0 95 | const r = await wallet.getNextAvailableAddress(); 96 | if (r.isErr()) throw r.error; 97 | const a1 = r.value.addressIndex.address; 98 | await rpc.sendToAddress(a1, '1'); 99 | await rpc.generateToAddress(1, await rpc.getNewAddress()); 100 | await waitForElectrum(); 101 | await wallet.refreshWallet({}); 102 | expect(wallet.data.balance).to.equal(100000000); 103 | const s1 = await wallet.send({ 104 | address: 'bcrt1q6rz28mcfaxtmd6v789l9rrlrusdprr9pz3cppk', 105 | amount: 99999743, 106 | satsPerByte: 1 107 | }); 108 | if (s1.isErr()) throw s1.error; 109 | await wallet.refreshWallet({}); 110 | expect(wallet.data.balance).to.be.below(256); 111 | const b2 = wallet.canBoost(s1.value); 112 | expect(b2).to.deep.equal(failure); 113 | 114 | // tx is already confirmed 115 | await rpc.sendToAddress(a1, '1'); 116 | await rpc.generateToAddress(1, await rpc.getNewAddress()); 117 | await waitForElectrum(); 118 | await wallet.refreshWallet({}); 119 | const s2 = await wallet.send({ 120 | address: 'bcrt1q6rz28mcfaxtmd6v789l9rrlrusdprr9pz3cppk', 121 | amount: 10000000 122 | }); 123 | if (s2.isErr()) throw s2.error; 124 | await rpc.generateToAddress(1, await rpc.getNewAddress()); // confirm tx 125 | await wallet.refreshWallet({}); 126 | const b3 = wallet.canBoost(s2.value); 127 | expect(b3).to.deep.equal(failure); 128 | }); 129 | 130 | it('Should generate CPFP for send transaction', async () => { 131 | const r = await wallet.getNextAvailableAddress(); 132 | if (r.isErr()) throw r.error; 133 | const a1 = r.value.addressIndex.address; 134 | await rpc.sendToAddress(a1, '1'); 135 | await rpc.generateToAddress(1, await rpc.getNewAddress()); 136 | 137 | await waitForElectrum(); 138 | await wallet.refreshWallet({}); 139 | expect(wallet.data.balance).to.equal(100000000); 140 | 141 | const s1 = await wallet.send({ 142 | address: 'bcrt1q6rz28mcfaxtmd6v789l9rrlrusdprr9pz3cppk', 143 | amount: 10000000, 144 | satsPerByte: 1, 145 | rbf: false 146 | }); 147 | if (s1.isErr()) throw s1.error; 148 | const oldTxId = s1.value; 149 | await wallet.refreshWallet({}); 150 | const b1 = wallet.canBoost(oldTxId); 151 | expect(b1).to.deep.equal({ canBoost: true, rbf: false, cpfp: true }); 152 | 153 | const setup = await wallet.transaction.setupCpfp({ txid: oldTxId }); 154 | if (setup.isErr()) throw setup.error; 155 | expect(setup.value.inputs.length).to.equal(1); 156 | expect(setup.value.outputs.length).to.equal(1); 157 | expect(setup.value.boostType).to.equal(EBoostType.cpfp); 158 | expect(setup.value.minFee).to.be.above(1); 159 | expect(setup.value.max).to.equal(true); 160 | // with parent tx at 1 sat/vbyte, and high fee at 4, child tx fee should be around 8 161 | expect(setup.value.satsPerByte).to.be.above(6); 162 | 163 | const createRes = await wallet.transaction.createTransaction(); 164 | if (createRes.isErr()) throw createRes.error; 165 | const newTxId = createRes.value.id; 166 | wallet.electrum.broadcastTransaction({ rawTx: createRes.value.hex }); 167 | 168 | const addBoost = await wallet.addBoostedTransaction({ 169 | oldTxId, 170 | newTxId, 171 | type: EBoostType.cpfp, 172 | fee: setup.value.fee 173 | }); 174 | if (addBoost.isErr()) throw addBoost.error; 175 | const boosted = wallet.getBoostedTransactions(); 176 | expect(boosted).to.deep.equal({ 177 | [oldTxId]: { 178 | parentTransactions: [oldTxId], 179 | childTransaction: newTxId, 180 | type: EBoostType.cpfp, 181 | fee: setup.value.fee 182 | } 183 | }); 184 | 185 | await wallet.refreshWallet({}); 186 | expect(Object.keys(wallet.transactions).length).to.equal(3); 187 | 188 | // FIXME: Broadcasted tx fee and setup fee should be the same 189 | // expect(wallet.transactions[newTxId].satsPerByte).to.equal( 190 | // setup.value.satsPerByte 191 | // ); 192 | }); 193 | 194 | it('Should generate RBF for send transaction', async () => { 195 | const r = await wallet.getNextAvailableAddress(); 196 | if (r.isErr()) throw r.error; 197 | const a1 = r.value.addressIndex.address; 198 | await rpc.sendToAddress(a1, '0.0001'); // 10000 sats 199 | await rpc.generateToAddress(1, await rpc.getNewAddress()); 200 | 201 | await waitForElectrum(); 202 | const r1 = await wallet.refreshWallet({}); 203 | if (r1.isErr()) throw r1.error; 204 | expect(wallet.data.balance).to.equal(10000); 205 | 206 | // create and send original transaction 207 | const s1 = await wallet.send({ 208 | address: 'bcrt1q6rz28mcfaxtmd6v789l9rrlrusdprr9pz3cppk', 209 | amount: 1000, 210 | satsPerByte: 1, 211 | rbf: true 212 | }); 213 | if (s1.isErr()) throw s1.error; 214 | const oldTxId = s1.value; 215 | const r2 = await wallet.refreshWallet({}); 216 | if (r2.isErr()) throw r2.error; 217 | const b1 = wallet.canBoost(oldTxId); 218 | expect(b1).to.deep.equal({ canBoost: true, rbf: true, cpfp: true }); 219 | 220 | // replace original transaction using RBF 221 | const setup = await wallet.transaction.setupRbf({ txid: oldTxId }); 222 | if (setup.isErr()) throw setup.error; 223 | expect(setup.value.boostType).to.equal(EBoostType.rbf); 224 | expect(setup.value.minFee).to.be.above(1); 225 | const createRes = await wallet.transaction.createTransaction(); 226 | if (createRes.isErr()) throw createRes.error; 227 | const newTxId = createRes.value.id; 228 | const broadcastResp = await wallet.electrum.broadcastTransaction({ 229 | rawTx: createRes.value.hex 230 | }); 231 | if (broadcastResp.isErr()) throw broadcastResp.error; 232 | 233 | const addBoost = await wallet.addBoostedTransaction({ 234 | oldTxId, 235 | newTxId, 236 | type: EBoostType.rbf, 237 | fee: setup.value.fee 238 | }); 239 | if (addBoost.isErr()) throw addBoost.error; 240 | const boosted = wallet.getBoostedTransactions(); 241 | expect(boosted).to.deep.equal({ 242 | [oldTxId]: { 243 | parentTransactions: [oldTxId], 244 | childTransaction: newTxId, 245 | type: EBoostType.rbf, 246 | fee: setup.value.fee 247 | } 248 | }); 249 | 250 | const r3 = await wallet.refreshWallet({}); 251 | if (r3.isErr()) throw r3.error; 252 | 253 | expect(Object.keys(wallet.transactions).length).to.equal(2); 254 | expect(wallet.transactions).not.to.have.property(oldTxId); 255 | expect(wallet.transactions).to.have.property(newTxId); 256 | }); 257 | }); 258 | -------------------------------------------------------------------------------- /tests/constants.ts: -------------------------------------------------------------------------------- 1 | // PLEASE DO NOT MODIFY THIS FILE 2 | // PLEASE DO NOT SEND SATS TO THE ADDRESSES GENERATED FROM THE MNEMONICS IN THIS FILE 3 | // PLEASE DO NOT USE THE MNEMONICS IN THIS FILE FOR ANYTHING 4 | // BEIGNET'S TESTS RELY ON THE MNEMONICS IN THIS FILE TO BE CONSTANT AND LEFT ALONE 5 | export const TEST_MNEMONIC = 6 | 'decorate grass round powder swarm syrup identify resemble mass online grunt cruise'; 7 | export const TRANSACTION_TEST_MNEMONIC = 8 | 'magic skull comfort major potato local giggle adjust post very olympic fortune'; 9 | export const EXAMPLE_MNEMONIC = 10 | 'shaft lottery soda estate trade bounce scout acid axis weather pole indicate'; 11 | export const HIGHT_ACTIVITY_MNEMONIC = 12 | 'above diet topic latin van chief load early faith clump alpha truly'; 13 | export const NETWORK = 'testnet'; 14 | -------------------------------------------------------------------------------- /tests/derivation.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai'; 2 | import { 3 | EAddressType, 4 | EAvailableNetworks, 5 | getAddressTypeFromPath, 6 | getKeyDerivationPath, 7 | getKeyDerivationPathObject, 8 | getKeyDerivationPathString 9 | } from '../src'; 10 | 11 | describe('Derivation Methods', () => { 12 | it('Should return default derivation path object for p2wpkh', () => { 13 | const pathRes = getKeyDerivationPath({ 14 | addressType: EAddressType.p2wpkh, 15 | network: EAvailableNetworks.mainnet 16 | }); 17 | if (pathRes.isErr()) throw pathRes.error; 18 | expect(pathRes.value.purpose).to.equal('84'); 19 | expect(pathRes.value.coinType).to.equal('0'); 20 | expect(pathRes.value.account).to.equal('0'); 21 | expect(pathRes.value.change).to.equal('0'); 22 | expect(pathRes.value.index).to.equal('0'); 23 | }); 24 | it('Should return default derivation path object for p2sh', () => { 25 | const pathRes = getKeyDerivationPath({ 26 | addressType: EAddressType.p2sh, 27 | network: EAvailableNetworks.mainnet 28 | }); 29 | if (pathRes.isErr()) throw pathRes.error; 30 | expect(pathRes.value.purpose).to.equal('49'); 31 | expect(pathRes.value.coinType).to.equal('0'); 32 | expect(pathRes.value.account).to.equal('0'); 33 | expect(pathRes.value.change).to.equal('0'); 34 | expect(pathRes.value.index).to.equal('0'); 35 | }); 36 | it('Should return default derivation path object for p2pkh', () => { 37 | const pathRes = getKeyDerivationPath({ 38 | addressType: EAddressType.p2pkh, 39 | network: EAvailableNetworks.mainnet 40 | }); 41 | if (pathRes.isErr()) throw pathRes.error; 42 | expect(pathRes.value.purpose).to.equal('44'); 43 | expect(pathRes.value.coinType).to.equal('0'); 44 | expect(pathRes.value.account).to.equal('0'); 45 | expect(pathRes.value.change).to.equal('0'); 46 | expect(pathRes.value.index).to.equal('0'); 47 | }); 48 | 49 | it('Should return a valid mainnet bech32 change address derivation string at index 0', () => { 50 | const pathRes = getKeyDerivationPathString({ 51 | addressType: EAddressType.p2wpkh, 52 | changeAddress: true, 53 | index: 0, 54 | network: EAvailableNetworks.mainnet 55 | }); 56 | if (pathRes.isErr()) throw pathRes.error; 57 | expect(pathRes.value).to.equal("m/84'/0'/0'/1/0"); 58 | }); 59 | it('Should return a valid testnet p2sh derivation string at index 40', () => { 60 | const pathRes = getKeyDerivationPathString({ 61 | addressType: EAddressType.p2sh, 62 | changeAddress: false, 63 | index: '40', 64 | network: EAvailableNetworks.testnet 65 | }); 66 | if (pathRes.isErr()) throw pathRes.error; 67 | expect(pathRes.value).to.equal("m/49'/1'/0'/0/40"); 68 | }); 69 | it('Should return a valid mainnet p2pkh derivation string at index 8', () => { 70 | const pathRes = getKeyDerivationPathString({ 71 | addressType: EAddressType.p2pkh, 72 | changeAddress: false, 73 | index: 8, 74 | network: EAvailableNetworks.mainnet 75 | }); 76 | if (pathRes.isErr()) throw pathRes.error; 77 | expect(pathRes.value).to.equal("m/44'/0'/0'/0/8"); 78 | }); 79 | 80 | it('Should return a valid mainnet bech32 change address derivation object at index 0', () => { 81 | const pathRes = getKeyDerivationPathObject({ 82 | path: "m/84'/0'/0'/1/0", 83 | network: EAvailableNetworks.mainnet 84 | }); 85 | if (pathRes.isErr()) throw pathRes.error; 86 | expect(pathRes.value.purpose).to.equal('84'); 87 | expect(pathRes.value.coinType).to.equal('0'); 88 | expect(pathRes.value.account).to.equal('0'); 89 | expect(pathRes.value.change).to.equal('1'); 90 | expect(pathRes.value.index).to.equal('0'); 91 | }); 92 | it('Should return a valid testnet p2sh derivation object at index 40', () => { 93 | const pathRes = getKeyDerivationPathObject({ 94 | path: "m/49'/1'/0'/0/40", 95 | network: EAvailableNetworks.testnet 96 | }); 97 | if (pathRes.isErr()) throw pathRes.error; 98 | expect(pathRes.value.purpose).to.equal('49'); 99 | expect(pathRes.value.coinType).to.equal('1'); 100 | expect(pathRes.value.account).to.equal('0'); 101 | expect(pathRes.value.change).to.equal('0'); 102 | expect(pathRes.value.index).to.equal('40'); 103 | }); 104 | it('Should return a valid mainnet p2pkh object at index 8', () => { 105 | const pathRes = getKeyDerivationPathObject({ 106 | path: "m/44'/0'/0'/0/8", 107 | network: EAvailableNetworks.mainnet 108 | }); 109 | if (pathRes.isErr()) throw pathRes.error; 110 | expect(pathRes.value.purpose).to.equal('44'); 111 | expect(pathRes.value.coinType).to.equal('0'); 112 | expect(pathRes.value.account).to.equal('0'); 113 | expect(pathRes.value.change).to.equal('0'); 114 | expect(pathRes.value.index).to.equal('8'); 115 | }); 116 | 117 | it('Should return a valid address type from p2wpkh path', () => { 118 | const pathRes = getAddressTypeFromPath("m/84'/0'/0'/0/0"); 119 | if (pathRes.isErr()) throw pathRes.error; 120 | expect(pathRes.value).to.equal(EAddressType.p2wpkh); 121 | }); 122 | it('Should return a valid address type from p2sh path', () => { 123 | const pathRes = getAddressTypeFromPath("m/49'/0'/0'/0/0"); 124 | if (pathRes.isErr()) throw pathRes.error; 125 | expect(pathRes.value).to.equal(EAddressType.p2sh); 126 | }); 127 | it('Should return a valid address type from p2pkh path', () => { 128 | const pathRes = getAddressTypeFromPath("m/44'/0'/0'/0/0"); 129 | if (pathRes.isErr()) throw pathRes.error; 130 | expect(pathRes.value).to.equal(EAddressType.p2pkh); 131 | }); 132 | }); 133 | -------------------------------------------------------------------------------- /tests/electrum.test.ts: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai'; 2 | import net from 'net'; 3 | import tls from 'tls'; 4 | 5 | import { Wallet } from '../'; 6 | import { servers } from '../example/helpers'; 7 | import { 8 | EAddressType, 9 | EAvailableNetworks, 10 | IGetUtxosResponse, 11 | Result 12 | } from '../src'; 13 | import { TEST_MNEMONIC } from './constants'; 14 | import { EXPECTED_SHARED_RESULTS } from './expected-results'; 15 | 16 | const testTimeout = 60000; 17 | 18 | let wallet: Wallet; 19 | 20 | describe('Electrum Methods', async function (): Promise { 21 | this.timeout(testTimeout); 22 | 23 | before(async function () { 24 | this.timeout(testTimeout); 25 | const res = await Wallet.create({ 26 | mnemonic: TEST_MNEMONIC, 27 | network: EAvailableNetworks.testnet, 28 | addressType: EAddressType.p2wpkh, 29 | electrumOptions: { 30 | servers: servers[EAvailableNetworks.testnet], 31 | net, 32 | tls 33 | } 34 | }); 35 | if (res.isErr()) throw res.error; 36 | wallet = res.value; 37 | await wallet.refreshWallet({}); 38 | }); 39 | 40 | after(async function () { 41 | await wallet?.electrum?.disconnect(); 42 | }); 43 | 44 | it('connectToElectrum: Should connect to a random Electrum server', async () => { 45 | const connectResponse = await wallet.connectToElectrum(); 46 | if (connectResponse.isErr()) throw connectResponse.error; 47 | expect(connectResponse.value).to.equal('Connected to Electrum server.'); 48 | }); 49 | 50 | it('isConnected: Should return true if connected to an Electrum server', async () => { 51 | const isConnected = await wallet.electrum.isConnected(); 52 | expect(isConnected).to.equal(true); 53 | }); 54 | 55 | it('getAddressBalance: Should return the balance (in sats) of the provided address', async () => { 56 | const addressBalance = await wallet.getAddressBalance( 57 | 'tb1qyvc8r7338383xjshqsz38mfn2eql879nhrf8y0' 58 | ); 59 | if (addressBalance.isErr()) throw addressBalance.error; 60 | expect(addressBalance.value.confirmed).to.equal(20000); 61 | }); 62 | 63 | it('getNextAvailableAddress: Should return the next available address/change index and the last used address/change index', async () => { 64 | const r = await wallet.getNextAvailableAddress(); 65 | if (r.isErr()) throw r.error; 66 | expect(r.value).to.deep.equal( 67 | EXPECTED_SHARED_RESULTS.getNextAvailableAddress 68 | ); 69 | }); 70 | 71 | it("Should return available UTXO's", async () => { 72 | const getUtxosRes: Result = await wallet.getUtxos({}); 73 | if (getUtxosRes.isErr()) throw getUtxosRes.error; 74 | expect(Array.isArray(getUtxosRes.value.utxos)).to.equal(true); 75 | expect(getUtxosRes.value.utxos.length).to.equal(3); 76 | expect(getUtxosRes.value.balance).to.equal(5855); 77 | const sortedUtxos = getUtxosRes.value.utxos.sort((a, b) => { 78 | if (a.height !== b.height) { 79 | return a.height - b.height; 80 | } 81 | return a.index - b.index; 82 | }); 83 | expect({ ...getUtxosRes.value, utxos: sortedUtxos }).to.deep.equal( 84 | EXPECTED_SHARED_RESULTS.getUtxos 85 | ); 86 | }); 87 | }); 88 | -------------------------------------------------------------------------------- /tests/expected-results.ts: -------------------------------------------------------------------------------- 1 | export const EXPECTED_WALLET_RESULTS = { 2 | addressHistory: [ 3 | { 4 | height: 2472352, 5 | tx_hash: 6 | 'e12dec55bd19c709ed5cc3213aab814315fd9716afc99dfe914b9190fdcb8452' 7 | }, 8 | { 9 | height: 2539267, 10 | tx_hash: 11 | '01a98e4ad0ce6b3e1eb4a3a5357bdaaadc15b47bcd4349944ea541adfc8f3f39' 12 | }, 13 | { 14 | height: 2638717, 15 | tx_hash: 16 | '3f1ce6216b0c9f4cc8c9466770f3297622a94075351dac0e111df38a035839ad' 17 | } 18 | ], 19 | transactionDetails: { 20 | blockhash: 21 | '0000000000002081fe416979b95a9ae8d8ea325a3f8d6312d042da93f7a0e0fb', 22 | blocktime: 1691862473, 23 | //confirmations: 111366, 24 | hash: '7e771ebf5319ae710aaeeefea2cc1d385e86d4fd65325769fe39362e142679bb', 25 | hex: '02000000000101789f9ab5a8785f96f44e2f0a4bed3daedc0b513e5a7953bb53d6cb829ea5a5230000000000fdffffff02eb641f00000000001600149e329eb9f21c670ed6fad5df00cb818bd61fdd54e803000000000000160014dcba53dacda55e05e612037b34a1e4775103d68c024730440220275de890d1ebfa5c2445bfccbabe79b3ebe3ef27d7cb80133a839c1c97dbd0c50220465ce4e432f44fdce720cb639f2115f09a8a9de222407e3083a40a6b3ef13c44012103caa7816e40f0762ca6ed49fb64b0aca8d427dd314f482c8de5685baae8e1ece89fb92500', 26 | locktime: 2472351, 27 | size: 222, 28 | time: 1691862473, 29 | txid: 'e12dec55bd19c709ed5cc3213aab814315fd9716afc99dfe914b9190fdcb8452', 30 | version: 2, 31 | vin: [ 32 | { 33 | scriptSig: { asm: '', hex: '' }, 34 | sequence: 4294967293, 35 | txid: '23a5a59e82cbd653bb53795a3e510bdcae3ded4b0a2f4ef4965f78a8b59a9f78', 36 | txinwitness: [ 37 | '30440220275de890d1ebfa5c2445bfccbabe79b3ebe3ef27d7cb80133a839c1c97dbd0c50220465ce4e432f44fdce720cb639f2115f09a8a9de222407e3083a40a6b3ef13c4401', 38 | '03caa7816e40f0762ca6ed49fb64b0aca8d427dd314f482c8de5685baae8e1ece8' 39 | ], 40 | vout: 0 41 | } 42 | ], 43 | vout: [ 44 | { 45 | n: 0, 46 | scriptPubKey: { 47 | address: 'tb1qncefaw0jr3nsa4h66h0spjup30tplh25lpavsr', 48 | asm: '0 9e329eb9f21c670ed6fad5df00cb818bd61fdd54', 49 | desc: 'addr(tb1qncefaw0jr3nsa4h66h0spjup30tplh25lpavsr)#lfwshpn4', 50 | hex: '00149e329eb9f21c670ed6fad5df00cb818bd61fdd54', 51 | type: 'witness_v0_keyhash' 52 | }, 53 | value: 0.02057451 54 | }, 55 | { 56 | n: 1, 57 | scriptPubKey: { 58 | address: 'tb1qmja98kkd540qtesjqdanfg0ywags845vehfg66', 59 | asm: '0 dcba53dacda55e05e612037b34a1e4775103d68c', 60 | desc: 'addr(tb1qmja98kkd540qtesjqdanfg0ywags845vehfg66)#4tsskq5x', 61 | hex: '0014dcba53dacda55e05e612037b34a1e4775103d68c', 62 | type: 'witness_v0_keyhash' 63 | }, 64 | value: 0.00001 65 | } 66 | ], 67 | vsize: 141, 68 | weight: 561 69 | } 70 | }; 71 | 72 | export const EXPECTED_TRANSACTION_RESULTS = { 73 | decodeRawTransaction: { 74 | txid: '5afdbcb5ffa6e1104c4a67e80e8fde2280cb615b70b33c99951debc2d5e5f500', 75 | tx_hash: '094e314cbab1a268950a47216293d6ed170133ad265389e8dde7babf5eebed51', 76 | size: 223, 77 | vsize: 141, 78 | weight: 562, 79 | version: 2, 80 | locktime: 0, 81 | vin: [ 82 | { 83 | txid: '8d805dd2088da26440bcd515f04f89a4f7bbb820726fc2d100818ae479d3444b', 84 | vout: 0, 85 | scriptSig: { asm: '', hex: '' }, 86 | txinwitness: [ 87 | '3045022100dd709b656c271c7e2ab4c83e0245b9b8d9096a1c7a33eddc9a32113f436851d9022033f8e5cb016ae4c440badfa34e438ada7bea2cdd36e782c136e516350b502bca01', 88 | '02e86b90924963237c59e5389aab1cc5350c114549d1c5e7186a56ef33aea24ff9' 89 | ], 90 | sequence: 0 91 | } 92 | ], 93 | vout: [ 94 | { 95 | value: 5000, 96 | n: 0, 97 | scriptPubKey: { 98 | asm: 'OP_0 3f1a7a1802e377d01602acf1cad403368ed3bb89', 99 | hex: '00143f1a7a1802e377d01602acf1cad403368ed3bb89', 100 | address: 'tb1q8ud85xqzudmaq9sz4ncu44qrx68d8wuf2cwdqg' 101 | } 102 | }, 103 | { 104 | value: 74170, 105 | n: 1, 106 | scriptPubKey: { 107 | asm: 'OP_0 a6bd95db4dd6979189cad389daad006e236f4ba8', 108 | hex: '0014a6bd95db4dd6979189cad389daad006e236f4ba8', 109 | address: 'tb1q567etk6d66terzw26wya4tgqdc3k7jag0zcw3r' 110 | } 111 | } 112 | ] 113 | }, 114 | decodeRawSendManyTransaction: { 115 | txid: '3fb40fc55d80c46d08f412c2c9a6b18e6b46264a6ae6fd4be8409480d1a53b45', 116 | tx_hash: '6b124dc403f6db7ce9c7967b8b3b5b3223d4df98626ece3b5d253450c47c9b88', 117 | size: 253, 118 | vsize: 172, 119 | weight: 685, 120 | version: 2, 121 | locktime: 0, 122 | vin: [ 123 | { 124 | txid: '8d805dd2088da26440bcd515f04f89a4f7bbb820726fc2d100818ae479d3444b', 125 | vout: 0, 126 | scriptSig: { asm: '', hex: '' }, 127 | txinwitness: [ 128 | '304402207e7b5de41cb9bf33e434c2136390bf40d6b6552b69234a62f6bf48b89f0d44ac022056121c9a9d79d9d84896c9896a6fddb358b48667021ff2832b5c5871d90b701a01', 129 | '02e86b90924963237c59e5389aab1cc5350c114549d1c5e7186a56ef33aea24ff9' 130 | ], 131 | sequence: 0 132 | } 133 | ], 134 | vout: [ 135 | { 136 | value: 5000, 137 | n: 0, 138 | scriptPubKey: { 139 | asm: 'OP_0 a6b760eaa96a9ba91bae9465dfc4eabe711e1d67', 140 | hex: '0014a6b760eaa96a9ba91bae9465dfc4eabe711e1d67', 141 | address: 'tb1q56mkp64fd2d6jxawj3jal382hec3u8t8af83d7' 142 | } 143 | }, 144 | { 145 | value: 6000, 146 | n: 1, 147 | scriptPubKey: { 148 | asm: 'OP_0 6bcf920595e09b5d8f7b8d03b3694ad305757289', 149 | hex: '00146bcf920595e09b5d8f7b8d03b3694ad305757289', 150 | address: 'tb1qd08eypv4uzd4mrmm35pmx6226vzh2u5fqkpeyd' 151 | } 152 | }, 153 | { 154 | value: 68140, 155 | n: 2, 156 | scriptPubKey: { 157 | asm: 'OP_0 a6bd95db4dd6979189cad389daad006e236f4ba8', 158 | hex: '0014a6bd95db4dd6979189cad389daad006e236f4ba8', 159 | address: 'tb1q567etk6d66terzw26wya4tgqdc3k7jag0zcw3r' 160 | } 161 | } 162 | ] 163 | } 164 | }; 165 | 166 | export const EXPECTED_SHARED_RESULTS = { 167 | getNextAvailableAddress: { 168 | addressIndex: { 169 | address: 'tb1qqcmg5vwk736mmr3fnkx5us9hq4czl6cx5w5g0x', 170 | path: "m/84'/1'/0'/0/5", 171 | publicKey: 172 | '0345f71b1a5f9ce1c08ef2dbb1fb1076296b0fdf1f09f6fe7f53ed22383ad9d1c9', 173 | index: 5, 174 | scriptHash: 175 | '448ae601fb40d7a6de824eb34479286a06d41015250fc75544dbb6d2893bd0e5' 176 | }, 177 | lastUsedAddressIndex: { 178 | address: 'tb1qyxugs6zkcj3r4u09qks7khgf7hkktf8mnzz5ze', 179 | path: "m/84'/1'/0'/0/4", 180 | publicKey: 181 | '03f01a817e07ff424f00d6be3b93f7bec658aaf8fbfed5cd2c18f95f3cfd47f7a8', 182 | index: 4, 183 | scriptHash: 184 | '7f07103d4580005b27b856434bba9be63a7e58a83cb456b603f4af3ae88d1023' 185 | }, 186 | changeAddressIndex: { 187 | address: 'tb1q32eaj0c805mry76wa0g6hlcunu7ttu96833072', 188 | path: "m/84'/1'/0'/1/10", 189 | publicKey: 190 | '038813820d10cca28ce1fdb6a8b346a4ab9de6b520adc46e2c4442a7ba94de10a1', 191 | index: 10, 192 | scriptHash: 193 | '3198ad3b2b39efcdeeb6b338c1f28ccede385c2092dbb9854e265b6eec8a0dab' 194 | }, 195 | lastUsedChangeAddressIndex: { 196 | index: 9, 197 | path: "m/84'/1'/0'/1/9", 198 | address: 'tb1q926j5y9mwjc49axf5w25y2jrm0ew8w6uks0vdm', 199 | scriptHash: 200 | '640d69f5b22996bdc95dbac8863e9e94e198f40569c1ec46b6336edd740c0007', 201 | publicKey: 202 | '02e9085f8d23072244620f0549e6f1c6ff04c8c8b1dd238edce106ce6ef54b358e' 203 | } 204 | }, 205 | getUtxos: { 206 | utxos: [ 207 | { 208 | address: 'tb1qy45r5c84eh7tuke772lrvj2q5kqlylp2ghgdlk', 209 | path: "m/84'/1'/0'/0/1", 210 | publicKey: 211 | '03f8c98bf09b3e069714a05a530a735761453d94d1f4355239bfcb6b78c25a2592', 212 | index: 1, 213 | scriptHash: 214 | 'bdb8f18267b816706378c2c9282e0be7b05dcc5a3e63dd2468f145c6431f2002', 215 | tx_hash: 216 | '7a6e9a985de1e5bed1138d1fe1bf2f169a4f838d802ecdf96d1376378391a350', 217 | tx_pos: 0, 218 | height: 2539268, 219 | value: 1000 220 | }, 221 | { 222 | address: 'tb1q926j5y9mwjc49axf5w25y2jrm0ew8w6uks0vdm', 223 | path: "m/84'/1'/0'/1/9", 224 | publicKey: 225 | '02e9085f8d23072244620f0549e6f1c6ff04c8c8b1dd238edce106ce6ef54b358e', 226 | index: 9, 227 | scriptHash: 228 | '640d69f5b22996bdc95dbac8863e9e94e198f40569c1ec46b6336edd740c0007', 229 | tx_hash: 230 | '7a6e9a985de1e5bed1138d1fe1bf2f169a4f838d802ecdf96d1376378391a350', 231 | tx_pos: 1, 232 | height: 2539268, 233 | value: 3855 234 | }, 235 | { 236 | address: 'tb1qmja98kkd540qtesjqdanfg0ywags845vehfg66', 237 | height: 2638717, 238 | index: 0, 239 | path: "m/84'/1'/0'/0/0", 240 | publicKey: 241 | '02189e644b5fe9acf24374b35f01f652e011867568b6e01765cace9b7ef07809cc', 242 | scriptHash: 243 | '1cc3af572e4c847a1adf7ab3658fa7ae36926088c762821930dadc60e41217c2', 244 | tx_hash: 245 | '3f1ce6216b0c9f4cc8c9466770f3297622a94075351dac0e111df38a035839ad', 246 | tx_pos: 3, 247 | value: 1000 248 | } 249 | ], 250 | balance: 5855 251 | } 252 | }; 253 | -------------------------------------------------------------------------------- /tests/receive.test.ts: -------------------------------------------------------------------------------- 1 | import BitcoinJsonRpc from 'bitcoin-json-rpc'; 2 | import { expect } from 'chai'; 3 | import net from 'net'; 4 | import tls from 'tls'; 5 | 6 | import { 7 | EAddressType, 8 | EAvailableNetworks, 9 | EProtocol, 10 | generateMnemonic, 11 | sleep, 12 | Wallet 13 | } from '../'; 14 | import { 15 | bitcoinURL, 16 | electrumHost, 17 | electrumPort, 18 | initWaitForElectrumToSync, 19 | MessageListener, 20 | TWaitForElectrum 21 | } from './utils'; 22 | 23 | const testTimeout = 60000; 24 | let wallet: Wallet; 25 | let waitForElectrum: TWaitForElectrum; 26 | const rpc = new BitcoinJsonRpc(bitcoinURL); 27 | const ml = new MessageListener(); 28 | 29 | describe('Receive', async function () { 30 | this.timeout(testTimeout); 31 | 32 | beforeEach(async function () { 33 | this.timeout(testTimeout); 34 | ml.clear(); 35 | 36 | // Ensure sufficient balance in regtest 37 | let balance = await rpc.getBalance(); 38 | const address = await rpc.getNewAddress(); 39 | await rpc.generateToAddress(1, address); 40 | 41 | while (balance < 10) { 42 | await rpc.generateToAddress(10, address); 43 | balance = await rpc.getBalance(); 44 | } 45 | 46 | waitForElectrum = await initWaitForElectrumToSync( 47 | { host: electrumHost, port: electrumPort }, 48 | bitcoinURL 49 | ); 50 | 51 | await waitForElectrum(); 52 | 53 | const mnemonic = generateMnemonic(); 54 | 55 | const res = await Wallet.create({ 56 | mnemonic, 57 | network: EAvailableNetworks.regtest, 58 | addressType: EAddressType.p2wpkh, 59 | electrumOptions: { 60 | servers: [ 61 | { 62 | host: '127.0.0.1', 63 | ssl: 60002, 64 | tcp: 60001, 65 | protocol: EProtocol.tcp 66 | } 67 | ], 68 | net, 69 | tls 70 | }, 71 | // reduce gap limit to speed up tests 72 | gapLimitOptions: { 73 | lookAhead: 2, 74 | lookBehind: 2, 75 | lookAheadChange: 2, 76 | lookBehindChange: 2 77 | }, 78 | addressTypesToMonitor: [EAddressType.p2wpkh], 79 | onMessage: ml.onMessage 80 | }); 81 | if (res.isErr()) throw res.error; 82 | wallet = res.value; 83 | await wallet.refreshWallet({}); 84 | }); 85 | 86 | afterEach(async function () { 87 | await wallet?.electrum?.disconnect(); 88 | }); 89 | 90 | it('Should generate new receiving address', async () => { 91 | const r = await wallet.getNextAvailableAddress(); 92 | if (r.isErr()) throw r.error; 93 | const address = r.value.addressIndex.address; 94 | expect(address).to.be.a('string'); 95 | expect(address).to.match(/^bcrt1/); // Regtest bech32 prefix 96 | }); 97 | 98 | it('Should receive funds and update balance', async () => { 99 | expect(wallet.data.balance).to.equal(0); 100 | 101 | const r = await wallet.getNextAvailableAddress(); 102 | if (r.isErr()) throw r.error; 103 | const address = r.value.addressIndex.address; 104 | expect(address).to.be.a('string'); 105 | expect(address).to.match(/^bcrt1/); // Regtest bech32 prefix 106 | 107 | const amount = 0.1; 108 | const amountSats = amount * 10e7; 109 | await rpc.sendToAddress(address, amount.toString()); 110 | 111 | await rpc.generateToAddress(1, await rpc.getNewAddress()); 112 | await waitForElectrum(); 113 | 114 | await wallet.refreshWallet({}); 115 | expect(wallet.getBalance()).to.equal(amountSats); 116 | expect(wallet.balance).to.equal(amountSats); 117 | expect(wallet.utxos.length).to.equal(1); 118 | }); 119 | 120 | it('Should track multiple receiving addresses', async () => { 121 | const r1 = await wallet.getNextAvailableAddress(); 122 | if (r1.isErr()) throw r1.error; 123 | const address1 = r1.value.addressIndex.address; 124 | const r2 = await wallet.getNextAvailableAddress(); 125 | if (r2.isErr()) throw r2.error; 126 | const address2 = r2.value.addressIndex.address; 127 | 128 | // Without any transactions addresses should match 129 | expect(address1).to.equal(address2); 130 | 131 | // Send funds, get new address 132 | await rpc.sendToAddress(address1, '0.1'); 133 | await rpc.generateToAddress(1, await rpc.getNewAddress()); 134 | await waitForElectrum(); 135 | const r3 = await wallet.getNextAvailableAddress(); 136 | if (r3.isErr()) throw r3.error; 137 | const address3 = r3.value.addressIndex.address; 138 | 139 | // After a transaction, addresses should differ 140 | expect(address1).to.not.equal(address3); 141 | 142 | // Second transaction 143 | const receivePromise = ml.waitFor('transactionReceived'); 144 | await rpc.sendToAddress(address3, '0.2'); 145 | await receivePromise; 146 | 147 | // unfortinately it is possible that Electrum server still does not 148 | // have second transaction parsed so we need to wait a bit 149 | while (wallet.data.utxos.length === 1) { 150 | await sleep(100); 151 | await wallet.refreshWallet(); 152 | } 153 | 154 | // Check balances 155 | expect(wallet.balance).to.equal(0.3 * 10e7); // 0.3 BTC in sats 156 | 157 | // Test getAddressBalance 158 | const balance1 = await wallet.getAddressBalance(address1); 159 | if (balance1.isErr()) throw balance1.error; 160 | expect(balance1.value.confirmed).to.equal(0.1 * 10e7); 161 | const balance3 = await wallet.getAddressBalance(address3); 162 | if (balance3.isErr()) throw balance3.error; 163 | expect(balance3.value.unconfirmed).to.equal(0.2 * 10e7); 164 | 165 | // Test getAddressesBalance 166 | const combinedBalance = await wallet.getAddressesBalance([ 167 | address1, 168 | address3 169 | ]); 170 | if (combinedBalance.isErr()) throw combinedBalance.error; 171 | expect(combinedBalance.value).to.equal(0.3 * 10e7); 172 | }); 173 | 174 | it('Should handle unconfirmed transactions', async () => { 175 | const r = await wallet.getNextAvailableAddress(); 176 | if (r.isErr()) throw r.error; 177 | const address = r.value.addressIndex.address; 178 | 179 | await rpc.sendToAddress(address, '0.1'); 180 | await waitForElectrum(); 181 | 182 | // Refresh wallet and check unconfirmed transactions 183 | await wallet.refreshWallet({}); 184 | expect(Object.keys(wallet.data.unconfirmedTransactions)).to.have.length(1); 185 | expect(Object.keys(wallet.data.transactions)).to.have.length(1); 186 | 187 | // Generate blocks to confirm transaction 188 | await rpc.generateToAddress(10, await rpc.getNewAddress()); 189 | await waitForElectrum(); 190 | 191 | // Refresh and check confirmed status 192 | await wallet.refreshWallet({}); 193 | expect(Object.keys(wallet.data.unconfirmedTransactions)).to.have.length(0); 194 | expect(Object.keys(wallet.data.transactions)).to.have.length(1); 195 | }); 196 | 197 | it('Should receive transaction and emit correct messages', async () => { 198 | const r = await wallet.getNextAvailableAddress(); 199 | if (r.isErr()) throw r.error; 200 | const address = r.value.addressIndex.address; 201 | 202 | // test transactionReceived message 203 | const receivePromise = ml.waitFor('transactionReceived'); 204 | const amount = 0.1; 205 | await rpc.sendToAddress(address, amount.toString()); 206 | const txReceivedMessage = await receivePromise; 207 | expect(txReceivedMessage.transaction.value).to.equal(0.1); 208 | 209 | // test transactionConfirmed message 210 | const confirmedPromise = ml.waitFor('transactionConfirmed'); 211 | await rpc.generateToAddress(1, await rpc.getNewAddress()); 212 | await waitForElectrum(); 213 | const txConfirmedMessage = await confirmedPromise; 214 | expect(txConfirmedMessage.transaction.height).to.be.greaterThan(0); 215 | }); 216 | }); 217 | -------------------------------------------------------------------------------- /tests/storage.test.ts: -------------------------------------------------------------------------------- 1 | import { validateMnemonic } from 'bip39'; 2 | import { expect } from 'chai'; 3 | import net from 'net'; 4 | import tls from 'tls'; 5 | import sinon from 'sinon'; 6 | 7 | import { Wallet } from '../'; 8 | import { deleteDirectory, getData, servers, setData } from '../example/helpers'; 9 | import { 10 | EAddressType, 11 | EAvailableNetworks, 12 | generateMnemonic, 13 | IGetUtxosResponse, 14 | Result 15 | } from '../src'; 16 | import { TEST_MNEMONIC } from './constants'; 17 | import { EXPECTED_SHARED_RESULTS } from './expected-results'; 18 | 19 | const testTimeout = 60000; 20 | 21 | let wallet: Wallet; 22 | const WALLET_NAME = 'storagetestwallet0'; 23 | 24 | const storage = { getData, setData }; 25 | const storageSpy = sinon.spy(storage, 'setData'); 26 | const messageSpy = sinon.spy(); 27 | 28 | describe('Storage Test', async function (): Promise { 29 | this.timeout(testTimeout); 30 | 31 | before(async function () { 32 | this.timeout(testTimeout); 33 | await deleteDirectory('example/walletData'); // Start test with clean slate. 34 | const res = await Wallet.create({ 35 | mnemonic: TEST_MNEMONIC, 36 | network: EAvailableNetworks.testnet, 37 | name: WALLET_NAME, 38 | addressType: EAddressType.p2wpkh, 39 | storage, 40 | onMessage: messageSpy, 41 | electrumOptions: { 42 | servers: servers[EAvailableNetworks.testnet], 43 | net, 44 | tls 45 | } 46 | }); 47 | if (res.isErr()) throw res.error; 48 | wallet = res.value; 49 | await wallet.refreshWallet({}); 50 | }); 51 | 52 | after(async function () { 53 | await wallet?.electrum?.disconnect(); 54 | }); 55 | 56 | it('Should successfully create a wallet.', () => { 57 | expect(wallet).not.to.be.null; 58 | }); 59 | 60 | it('Should generate a valid, random mnemonic', () => { 61 | const randomMnemonic = generateMnemonic(); 62 | expect(validateMnemonic(randomMnemonic)).to.equal(true); 63 | }); 64 | 65 | it('Should determine that the wallet mnemonic is invalid', () => { 66 | const invalidMnemonic = 67 | 'corn core humor loud lady wealth avoid purse next subject focus dilemma'; 68 | const isValid = wallet.isValid(invalidMnemonic); 69 | expect(isValid).to.equal(false); 70 | }); 71 | 72 | it('Should determine that the current wallet instance is valid', () => { 73 | const isValid = wallet.isValid(TEST_MNEMONIC); 74 | expect(isValid).to.equal(true); 75 | }); 76 | 77 | it('Should generate a bech32 receiving address at index 0', async () => { 78 | const address = await wallet.getAddress({ 79 | addressType: EAddressType.p2wpkh, 80 | changeAddress: false, 81 | index: '0' 82 | }); 83 | expect(address).to.equal('tb1qmja98kkd540qtesjqdanfg0ywags845vehfg66'); 84 | }); 85 | 86 | it('Should generate a segwit change address at index 1', async () => { 87 | const address = await wallet.getAddress({ 88 | addressType: EAddressType.p2sh, 89 | changeAddress: true, 90 | index: '1' 91 | }); 92 | expect(address).to.equal('2NDRG1ZGhWMGGNW7Mp58BKcyBs4Hyat8Law'); 93 | }); 94 | 95 | it('Should generate a legacy receiving address at index 5', async () => { 96 | const address = await wallet.getAddress({ 97 | addressType: EAddressType.p2pkh, 98 | changeAddress: false, 99 | index: '5' 100 | }); 101 | expect(address).to.equal('mohdq3fadTtT4uSH4oNr4F1Dp3YM4pR3VF'); 102 | }); 103 | 104 | it('Should generate a bech32 receiving address at index 0 via its path', async () => { 105 | const address = await wallet.getAddressByPath({ path: "m/84'/1'/0'/0/0" }); 106 | if (address.isErr()) throw address.error; 107 | expect(address.value.address).to.equal( 108 | 'tb1qmja98kkd540qtesjqdanfg0ywags845vehfg66' 109 | ); 110 | }); 111 | 112 | it('Should generate a segwit change address at index 1 via its path', async () => { 113 | const address = await wallet.getAddressByPath({ path: "m/49'/1'/0'/1/1" }); 114 | if (address.isErr()) throw address.error; 115 | expect(address.value.address).to.equal( 116 | '2NDRG1ZGhWMGGNW7Mp58BKcyBs4Hyat8Law' 117 | ); 118 | }); 119 | 120 | it('Should generate a testnet legacy receiving address at index 5 via its path', async () => { 121 | const address = await wallet.getAddressByPath({ path: "m/44'/1'/0'/0/5" }); 122 | if (address.isErr()) throw address.error; 123 | expect(address.value.address).to.equal( 124 | 'mohdq3fadTtT4uSH4oNr4F1Dp3YM4pR3VF' 125 | ); 126 | }); 127 | 128 | it('getNextAvailableAddress: Should return the next available address/change index and the last used address/change index', async () => { 129 | const r = await wallet.getNextAvailableAddress(); 130 | if (r.isErr()) throw r.error; 131 | expect(r.value).to.deep.equal( 132 | EXPECTED_SHARED_RESULTS.getNextAvailableAddress 133 | ); 134 | }); 135 | 136 | it("Should return available UTXO's", async () => { 137 | const getUtxosRes: Result = await wallet.getUtxos({}); 138 | if (getUtxosRes.isErr()) throw getUtxosRes.error; 139 | expect(Array.isArray(getUtxosRes.value.utxos)).to.equal(true); 140 | expect(getUtxosRes.value.utxos.length).to.equal(3); 141 | expect(getUtxosRes.value.balance).to.equal(5855); 142 | const sortedUtxos = getUtxosRes.value.utxos.sort((a, b) => { 143 | if (a.height !== b.height) { 144 | return a.height - b.height; 145 | } 146 | return a.index - b.index; 147 | }); 148 | expect({ ...getUtxosRes.value, utxos: sortedUtxos }).to.deep.equal( 149 | EXPECTED_SHARED_RESULTS.getUtxos 150 | ); 151 | }); 152 | 153 | it('Should successfully stop the wallet', async () => { 154 | wallet.refreshWallet(); // start wallet refresh in the background 155 | const r = await wallet.stop(); 156 | if (r.isErr()) throw r.error; 157 | storageSpy.resetHistory(); 158 | messageSpy.resetHistory(); 159 | // try to force the wallet to update it's data 160 | wallet.feeEstimates.timestamp = 0; 161 | await wallet.updateFeeEstimates(true); 162 | await wallet.refreshWallet(); 163 | // make sure that the wallet did not call setData or onMessage 164 | expect(storageSpy.called).to.equal(false); 165 | expect(messageSpy.called).to.equal(false); 166 | }); 167 | 168 | // it('Attempts to create a new wallet using the same name of an existing wallet in storage.', async () => { 169 | // const createRes = await Wallet.create({ 170 | // mnemonic: generateMnemonic(), 171 | // network: EAvailableNetworks.testnet, 172 | // name: WALLET_NAME, 173 | // addressType: EAddressType.p2wpkh, 174 | // storage: { 175 | // getData, 176 | // setData 177 | // } 178 | // }); 179 | // expect(createRes.isOk()).to.equal(false); 180 | // if (createRes.isOk()) return; 181 | // }); 182 | }); 183 | -------------------------------------------------------------------------------- /tests/utils.ts: -------------------------------------------------------------------------------- 1 | import net from 'net'; 2 | import BitcoinJsonRpc from 'bitcoin-json-rpc'; 3 | import ElectrumClient from 'bw-electrum-client'; 4 | import { 5 | EProtocol, 6 | sleep, 7 | TMessageDataMap, 8 | TMessageKeys, 9 | TOnMessage 10 | } from '../src'; 11 | 12 | export const bitcoinURL = 'http://polaruser:polarpass@127.0.0.1:43782'; 13 | export const electrumHost = '127.0.0.1'; 14 | export const electrumPort = 60001; 15 | 16 | export type TWaitForElectrum = () => Promise; 17 | 18 | /* 19 | * This function is used to wait for Electrum to sync with Bitcoin Core. 20 | */ 21 | export const initWaitForElectrumToSync = async ( 22 | elAddr: { port: number; host: string }, 23 | btcAddr: string, 24 | timeout = 30_000 25 | ): Promise => { 26 | let height = 0; 27 | 28 | const bitcoin = new BitcoinJsonRpc(btcAddr); 29 | const electrum = new ElectrumClient( 30 | net, 31 | false, 32 | elAddr.port, 33 | elAddr.host, 34 | EProtocol.tcp 35 | ); 36 | 37 | electrum.subscribe.on('blockchain.headers.subscribe', (params) => { 38 | // get max height 39 | const h = params 40 | .map(({ height: hh }) => hh) 41 | .sort() 42 | .reverse()[0]; 43 | height = h; 44 | }); 45 | 46 | await electrum.initElectrum({ client: 'wait-for-block', version: '1.4' }); 47 | 48 | const tip = await electrum.blockchainHeaders_subscribe(); 49 | height = tip.height; 50 | 51 | const waitForElectrum = (): Promise => { 52 | return new Promise(async (resolve, reject) => { 53 | let count: number; 54 | let running = true; 55 | 56 | const timer = setTimeout(async () => { 57 | running = false; 58 | // before timeout check block count once again 59 | const b = await bitcoin.getBlockCount(); 60 | const e = await electrum.blockchainHeaders_subscribe(); 61 | if (b === e.height) { 62 | resolve(); 63 | } else { 64 | reject(new Error('Electrum sync Timeout error')); 65 | } 66 | }, timeout); 67 | 68 | try { 69 | count = await bitcoin.getBlockCount(); 70 | } catch (e) { 71 | clearTimeout(timer); 72 | reject(e); 73 | return; 74 | } 75 | 76 | while (running && count !== height) { 77 | await sleep(10); 78 | } 79 | 80 | if (running) { 81 | clearTimeout(timer); 82 | resolve(); 83 | } 84 | }); 85 | }; 86 | 87 | waitForElectrum.close = (): void => electrum?.close(); 88 | 89 | return waitForElectrum; 90 | }; 91 | 92 | type TMessage = { 93 | key: TMessageKeys; 94 | data: TMessageDataMap[keyof TMessageDataMap]; 95 | timestamp: number; 96 | }; 97 | 98 | export class MessageListener { 99 | public messages: TMessage[] = []; 100 | private resolvers: ((message: TMessage) => void)[] = []; 101 | 102 | onMessage: TOnMessage = (key, data) => { 103 | const message: TMessage = { 104 | key, 105 | data, 106 | timestamp: Date.now() 107 | }; 108 | this.messages.push(message); 109 | this.resolvers.forEach((resolve) => resolve(message)); 110 | }; 111 | 112 | waitFor( 113 | messageKey: K, 114 | timeout = 20000 115 | ): Promise { 116 | // Check if message already received 117 | const existingMessage = this.messages.find((msg) => msg.key === messageKey); 118 | if (existingMessage) { 119 | return Promise.resolve(existingMessage.data as TMessageDataMap[K]); 120 | } 121 | 122 | // Wait for new message 123 | return new Promise((resolve, reject) => { 124 | const timer = setTimeout(() => { 125 | reject(new Error('Timeout waiting for message')); 126 | }, timeout); 127 | 128 | const resolver = (msg: TMessage): void => { 129 | if (msg.key === messageKey) { 130 | clearTimeout(timer); 131 | resolve(msg.data as TMessageDataMap[K]); 132 | } 133 | }; 134 | this.resolvers.push(resolver); 135 | }); 136 | } 137 | 138 | clear(): void { 139 | this.messages = []; 140 | this.resolvers = []; 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "esModuleInterop": true, 5 | "target": "es2017", 6 | "moduleResolution": "node", 7 | "sourceMap": true, 8 | "declarationDir": "./dist/types", 9 | "outDir": "./dist", 10 | "removeComments": true, 11 | "allowSyntheticDefaultImports": true, 12 | "isolatedModules": false, 13 | "resolveJsonModule": true, 14 | "noImplicitAny": false, 15 | "declaration": true, 16 | "strict": true, 17 | "allowJs": true, 18 | "strictNullChecks": true, 19 | "strictFunctionTypes": true, 20 | "strictPropertyInitialization": true, 21 | "noImplicitThis": true, 22 | "alwaysStrict": true, 23 | "noUnusedLocals": true, 24 | "skipLibCheck": true, 25 | "useUnknownInCatchVariables": false 26 | }, 27 | "lib": ["es2015.promise", "es5"], 28 | "include": [ 29 | "src/**/*.ts" 30 | ], 31 | "exclude": ["./tests/", "node_modules", "./dist/"] 32 | } 33 | -------------------------------------------------------------------------------- /typedoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "entryPoints": ["src"], 3 | "out": "docs", 4 | "readme": "none" 5 | } 6 | --------------------------------------------------------------------------------