beignet 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +4 -0
- package/.eslintrc +40 -0
- package/.prettierrc +9 -0
- package/LICENSE +21 -0
- package/README.md +166 -0
- package/dist/electrum/constants.js +31 -0
- package/dist/electrum/constants.js.map +1 -0
- package/dist/electrum/index.js +552 -0
- package/dist/electrum/index.js.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/shapes/electrum.js +14 -0
- package/dist/shapes/electrum.js.map +1 -0
- package/dist/shapes/index.js +19 -0
- package/dist/shapes/index.js.map +1 -0
- package/dist/shapes/wallet.js +115 -0
- package/dist/shapes/wallet.js.map +1 -0
- package/dist/transaction/index.js +692 -0
- package/dist/transaction/index.js.map +1 -0
- package/dist/types/electrum/constants.d.ts +7 -0
- package/dist/types/electrum/index.d.ts +85 -0
- package/dist/types/electrum.js +9 -0
- package/dist/types/electrum.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.js +20 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/shapes/electrum.d.ts +5 -0
- package/dist/types/shapes/index.d.ts +2 -0
- package/dist/types/shapes/wallet.d.ts +10 -0
- package/dist/types/transaction/index.d.ts +92 -0
- package/dist/types/transaction.js +12 -0
- package/dist/types/transaction.js.map +1 -0
- package/dist/types/types/electrum.d.ts +113 -0
- package/dist/types/types/index.d.ts +3 -0
- package/dist/types/types/transaction.d.ts +51 -0
- package/dist/types/types/wallet.d.ts +400 -0
- package/dist/types/utils/conversion.d.ts +10 -0
- package/dist/types/utils/derivation-path.d.ts +19 -0
- package/dist/types/utils/electrum.d.ts +10 -0
- package/dist/types/utils/exchange-rate.d.ts +30 -0
- package/dist/types/utils/helpers.d.ts +23 -0
- package/dist/types/utils/index.d.ts +7 -0
- package/dist/types/utils/result.d.ts +16 -0
- package/dist/types/utils/transaction.d.ts +21 -0
- package/dist/types/utils/wallet.d.ts +47 -0
- package/dist/types/wallet/constants.d.ts +12 -0
- package/dist/types/wallet/index.d.ts +214 -0
- package/dist/types/wallet.js +36 -0
- package/dist/types/wallet.js.map +1 -0
- package/dist/utils/conversion.js +52 -0
- package/dist/utils/conversion.js.map +1 -0
- package/dist/utils/derivation-path.js +104 -0
- package/dist/utils/derivation-path.js.map +1 -0
- package/dist/utils/electrum.js +149 -0
- package/dist/utils/electrum.js.map +1 -0
- package/dist/utils/exchange-rate.js +49 -0
- package/dist/utils/exchange-rate.js.map +1 -0
- package/dist/utils/helpers.js +137 -0
- package/dist/utils/helpers.js.map +1 -0
- package/dist/utils/index.js +24 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/result.js +36 -0
- package/dist/utils/result.js.map +1 -0
- package/dist/utils/transaction.js +327 -0
- package/dist/utils/transaction.js.map +1 -0
- package/dist/utils/wallet.js +227 -0
- package/dist/utils/wallet.js.map +1 -0
- package/dist/wallet/constants.js +15 -0
- package/dist/wallet/constants.js.map +1 -0
- package/dist/wallet/index.js +2113 -0
- package/dist/wallet/index.js.map +1 -0
- package/docs/html/.nojekyll +1 -0
- package/docs/html/assets/highlight.css +22 -0
- package/docs/html/assets/main.js +58 -0
- package/docs/html/assets/search.js +1 -0
- package/docs/html/assets/style.css +1367 -0
- package/docs/html/classes/Electrum.html +812 -0
- package/docs/html/classes/Transaction.html +687 -0
- package/docs/html/classes/Wallet.html +2030 -0
- package/docs/html/enums/EAddressType.html +227 -0
- package/docs/html/enums/EAvailableNetworks.html +255 -0
- package/docs/html/enums/EBoostType.html +220 -0
- package/docs/html/enums/EFeeId.html +241 -0
- package/docs/html/enums/EPaymentType.html +220 -0
- package/docs/html/enums/EProtocol.html +220 -0
- package/docs/html/enums/EUnit.html +227 -0
- package/docs/html/functions/availableNetworks.html +200 -0
- package/docs/html/functions/constructByteCountParam.html +210 -0
- package/docs/html/functions/decodeOpReturnMessage.html +202 -0
- package/docs/html/functions/decodeRawTransaction.html +210 -0
- package/docs/html/functions/err.html +214 -0
- package/docs/html/functions/formatKeyDerivationPath.html +219 -0
- package/docs/html/functions/formatPeerData.html +207 -0
- package/docs/html/functions/generateMnemonic.html +223 -0
- package/docs/html/functions/generateWalletId.html +202 -0
- package/docs/html/functions/getAddressFromScriptPubKey.html +209 -0
- package/docs/html/functions/getAddressTypeFromPath.html +206 -0
- package/docs/html/functions/getByteCount.html +206 -0
- package/docs/html/functions/getDataFallback.html +207 -0
- package/docs/html/functions/getDefaultPort.html +209 -0
- package/docs/html/functions/getDefaultWalletData.html +200 -0
- package/docs/html/functions/getDefaultWalletDataKeys.html +200 -0
- package/docs/html/functions/getExchangeRates.html +200 -0
- package/docs/html/functions/getHighestUsedIndexFromTxHashes.html +216 -0
- package/docs/html/functions/getKeyDerivationPath.html +211 -0
- package/docs/html/functions/getKeyDerivationPathObject.html +216 -0
- package/docs/html/functions/getKeyDerivationPathString.html +220 -0
- package/docs/html/functions/getKeyValue.html +206 -0
- package/docs/html/functions/getPeers.html +211 -0
- package/docs/html/functions/getProtocolForPort.html +209 -0
- package/docs/html/functions/getScriptHash.html +210 -0
- package/docs/html/functions/getSeed.html +209 -0
- package/docs/html/functions/getSeedHash.html +206 -0
- package/docs/html/functions/getSha256.html +206 -0
- package/docs/html/functions/getStorageKeyValues.html +209 -0
- package/docs/html/functions/getTxFee.html +210 -0
- package/docs/html/functions/getWalletDataStorageKey.html +206 -0
- package/docs/html/functions/isValidBech32mEncodedString.html +211 -0
- package/docs/html/functions/objectKeys-1.html +211 -0
- package/docs/html/functions/objectsMatch.html +210 -0
- package/docs/html/functions/ok.html +214 -0
- package/docs/html/functions/parseOnChainPaymentRequest.html +204 -0
- package/docs/html/functions/reduceValue.html +215 -0
- package/docs/html/functions/removeDustOutputs.html +206 -0
- package/docs/html/functions/setReplaceByFee.html +210 -0
- package/docs/html/functions/shuffleArray.html +211 -0
- package/docs/html/functions/validateAddress.html +216 -0
- package/docs/html/functions/validateMnemonic.html +206 -0
- package/docs/html/functions/validateTransaction.html +206 -0
- package/docs/html/index.html +360 -0
- package/docs/html/interfaces/IAddInput.html +231 -0
- package/docs/html/interfaces/IAddress.html +247 -0
- package/docs/html/interfaces/IAddressData.html +231 -0
- package/docs/html/interfaces/IAddressType.html +199 -0
- package/docs/html/interfaces/IAddressTypeData.html +252 -0
- package/docs/html/interfaces/IAddresses.html +199 -0
- package/docs/html/interfaces/IBoostedTransaction.html +238 -0
- package/docs/html/interfaces/IBoostedTransactions.html +199 -0
- package/docs/html/interfaces/ICreateTransaction.html +224 -0
- package/docs/html/interfaces/ICustomGetAddress.html +231 -0
- package/docs/html/interfaces/ICustomGetScriptHash.html +224 -0
- package/docs/html/interfaces/IElectrumGetAddressBalanceRes.html +235 -0
- package/docs/html/interfaces/IExchangeRates.html +210 -0
- package/docs/html/interfaces/IFormattedPeerData.html +245 -0
- package/docs/html/interfaces/IFormattedTransaction.html +343 -0
- package/docs/html/interfaces/IFormattedTransactions.html +199 -0
- package/docs/html/interfaces/IGenerateAddresses.html +252 -0
- package/docs/html/interfaces/IGenerateAddressesResponse.html +224 -0
- package/docs/html/interfaces/IGetAddress.html +231 -0
- package/docs/html/interfaces/IGetAddressBalanceRes.html +226 -0
- package/docs/html/interfaces/IGetAddressByPath.html +224 -0
- package/docs/html/interfaces/IGetAddressHistoryResponse.html +269 -0
- package/docs/html/interfaces/IGetAddressResponse.html +231 -0
- package/docs/html/interfaces/IGetAddressScriptHashesHistoryResponse.html +245 -0
- package/docs/html/interfaces/IGetDerivationPath.html +259 -0
- package/docs/html/interfaces/IGetFeeEstimatesResponse.html +238 -0
- package/docs/html/interfaces/IGetHeaderResponse.html +245 -0
- package/docs/html/interfaces/IGetNextAvailableAddressResponse.html +238 -0
- package/docs/html/interfaces/IGetTransactions.html +245 -0
- package/docs/html/interfaces/IGetTransactionsFromInputs.html +245 -0
- package/docs/html/interfaces/IGetUtxosResponse.html +224 -0
- package/docs/html/interfaces/IHeader.html +231 -0
- package/docs/html/interfaces/IIndexes.html +238 -0
- package/docs/html/interfaces/IKeyDerivationPath.html +247 -0
- package/docs/html/interfaces/IKeyDerivationPathData.html +224 -0
- package/docs/html/interfaces/INewBlock.html +224 -0
- package/docs/html/interfaces/IOnchainFees.html +245 -0
- package/docs/html/interfaces/IOutput.html +231 -0
- package/docs/html/interfaces/IPeerData.html +231 -0
- package/docs/html/interfaces/IRbfData.html +252 -0
- package/docs/html/interfaces/ISend.html +224 -0
- package/docs/html/interfaces/ISendTransaction.html +322 -0
- package/docs/html/interfaces/ISendTx.html +231 -0
- package/docs/html/interfaces/ISetupTransaction.html +238 -0
- package/docs/html/interfaces/ISubscribeToAddress.html +247 -0
- package/docs/html/interfaces/ISubscribeToHeader.html +245 -0
- package/docs/html/interfaces/ITargets.html +238 -0
- package/docs/html/interfaces/ITransaction.html +281 -0
- package/docs/html/interfaces/ITxHash.html +217 -0
- package/docs/html/interfaces/ITxHashes.html +235 -0
- package/docs/html/interfaces/IUtxo.html +275 -0
- package/docs/html/interfaces/IVin.html +252 -0
- package/docs/html/interfaces/IVout.html +246 -0
- package/docs/html/interfaces/IWallet.html +350 -0
- package/docs/html/interfaces/IWalletData.html +343 -0
- package/docs/html/types/ElectrumConnectionPubSub.html +233 -0
- package/docs/html/types/ElectrumConnectionSubscription.html +204 -0
- package/docs/html/types/InputData.html +203 -0
- package/docs/html/types/ObjectKeys.html +198 -0
- package/docs/html/types/Result.html +201 -0
- package/docs/html/types/TAddressIndexInfo.html +204 -0
- package/docs/html/types/TAddressLabel.html +193 -0
- package/docs/html/types/TAddressType.html +193 -0
- package/docs/html/types/TAddressTypeContent.html +198 -0
- package/docs/html/types/TAddressTypes.html +193 -0
- package/docs/html/types/TAvailableNetworks.html +193 -0
- package/docs/html/types/TConnectToElectrumRes.html +193 -0
- package/docs/html/types/TDecodeRawTx.html +214 -0
- package/docs/html/types/TElectrumNetworks.html +193 -0
- package/docs/html/types/TGetAddressHistory.html +200 -0
- package/docs/html/types/TGetByteCountInput.html +193 -0
- package/docs/html/types/TGetByteCountInputs.html +193 -0
- package/docs/html/types/TGetByteCountOutput.html +193 -0
- package/docs/html/types/TGetByteCountOutputs.html +193 -0
- package/docs/html/types/TGetData.html +211 -0
- package/docs/html/types/TGetTotalFeeObj.html +204 -0
- package/docs/html/types/TKeyDerivationAccount.html +193 -0
- package/docs/html/types/TKeyDerivationChange.html +193 -0
- package/docs/html/types/TKeyDerivationCoinType.html +193 -0
- package/docs/html/types/TKeyDerivationIndex.html +193 -0
- package/docs/html/types/TKeyDerivationPurpose.html +193 -0
- package/docs/html/types/TMessageDataMap.html +210 -0
- package/docs/html/types/TMessageKeys.html +193 -0
- package/docs/html/types/TOnMessage.html +213 -0
- package/docs/html/types/TProcessUnconfirmedTransactions.html +202 -0
- package/docs/html/types/TProtocol.html +193 -0
- package/docs/html/types/TServer.html +204 -0
- package/docs/html/types/TSetData.html +213 -0
- package/docs/html/types/TSetupTransactionResponse.html +193 -0
- package/docs/html/types/TStorage.html +200 -0
- package/docs/html/types/TSubscribedReceive.html +193 -0
- package/docs/html/types/TTransactionMessage.html +198 -0
- package/docs/html/types/TTxResponse.html +206 -0
- package/docs/html/types/TTxResult.html +200 -0
- package/docs/html/types/TUnspentAddressScriptHashData.html +198 -0
- package/docs/html/types/TWalletDataKeys.html +193 -0
- package/docs/html/variables/defaultElectrumPorts.html +193 -0
- package/docs/html/variables/electrumConnection.html +199 -0
- package/docs/html/variables/mostUsedExchangeTickers.html +241 -0
- package/docs/markdown/.nojekyll +1 -0
- package/docs/markdown/README.md +1875 -0
- package/docs/markdown/classes/Electrum.md +718 -0
- package/docs/markdown/classes/Transaction.md +536 -0
- package/docs/markdown/classes/Wallet.md +2189 -0
- package/docs/markdown/enums/EAddressType.md +41 -0
- package/docs/markdown/enums/EAvailableNetworks.md +85 -0
- package/docs/markdown/enums/EBoostType.md +30 -0
- package/docs/markdown/enums/EFeeId.md +63 -0
- package/docs/markdown/enums/EPaymentType.md +30 -0
- package/docs/markdown/enums/EProtocol.md +30 -0
- package/docs/markdown/enums/EUnit.md +41 -0
- package/docs/markdown/interfaces/IAddInput.md +41 -0
- package/docs/markdown/interfaces/IAddress.md +69 -0
- package/docs/markdown/interfaces/IAddressData.md +41 -0
- package/docs/markdown/interfaces/IAddressType.md +7 -0
- package/docs/markdown/interfaces/IAddressTypeData.md +74 -0
- package/docs/markdown/interfaces/IAddresses.md +7 -0
- package/docs/markdown/interfaces/IBoostedTransaction.md +52 -0
- package/docs/markdown/interfaces/IBoostedTransactions.md +7 -0
- package/docs/markdown/interfaces/ICreateTransaction.md +30 -0
- package/docs/markdown/interfaces/ICustomGetAddress.md +41 -0
- package/docs/markdown/interfaces/ICustomGetScriptHash.md +30 -0
- package/docs/markdown/interfaces/IElectrumGetAddressBalanceRes.md +55 -0
- package/docs/markdown/interfaces/IExchangeRates.md +7 -0
- package/docs/markdown/interfaces/IFormattedPeerData.md +63 -0
- package/docs/markdown/interfaces/IFormattedTransaction.md +217 -0
- package/docs/markdown/interfaces/IFormattedTransactions.md +7 -0
- package/docs/markdown/interfaces/IGenerateAddresses.md +74 -0
- package/docs/markdown/interfaces/IGenerateAddressesResponse.md +30 -0
- package/docs/markdown/interfaces/IGetAddress.md +41 -0
- package/docs/markdown/interfaces/IGetAddressBalanceRes.md +36 -0
- package/docs/markdown/interfaces/IGetAddressByPath.md +30 -0
- package/docs/markdown/interfaces/IGetAddressHistoryResponse.md +121 -0
- package/docs/markdown/interfaces/IGetAddressResponse.md +41 -0
- package/docs/markdown/interfaces/IGetAddressScriptHashesHistoryResponse.md +63 -0
- package/docs/markdown/interfaces/IGetDerivationPath.md +100 -0
- package/docs/markdown/interfaces/IGetFeeEstimatesResponse.md +52 -0
- package/docs/markdown/interfaces/IGetHeaderResponse.md +63 -0
- package/docs/markdown/interfaces/IGetNextAvailableAddressResponse.md +52 -0
- package/docs/markdown/interfaces/IGetTransactions.md +63 -0
- package/docs/markdown/interfaces/IGetTransactionsFromInputs.md +63 -0
- package/docs/markdown/interfaces/IGetUtxosResponse.md +30 -0
- package/docs/markdown/interfaces/IHeader.md +41 -0
- package/docs/markdown/interfaces/IIndexes.md +52 -0
- package/docs/markdown/interfaces/IKeyDerivationPath.md +69 -0
- package/docs/markdown/interfaces/IKeyDerivationPathData.md +30 -0
- package/docs/markdown/interfaces/INewBlock.md +30 -0
- package/docs/markdown/interfaces/IOnchainFees.md +63 -0
- package/docs/markdown/interfaces/IOutput.md +41 -0
- package/docs/markdown/interfaces/IPeerData.md +41 -0
- package/docs/markdown/interfaces/IRbfData.md +74 -0
- package/docs/markdown/interfaces/ISend.md +30 -0
- package/docs/markdown/interfaces/ISendTransaction.md +184 -0
- package/docs/markdown/interfaces/ISendTx.md +41 -0
- package/docs/markdown/interfaces/ISetupTransaction.md +52 -0
- package/docs/markdown/interfaces/ISubscribeToAddress.md +60 -0
- package/docs/markdown/interfaces/ISubscribeToHeader.md +59 -0
- package/docs/markdown/interfaces/ITargets.md +52 -0
- package/docs/markdown/interfaces/ITransaction.md +88 -0
- package/docs/markdown/interfaces/ITxHash.md +19 -0
- package/docs/markdown/interfaces/ITxHashes.md +55 -0
- package/docs/markdown/interfaces/IUtxo.md +112 -0
- package/docs/markdown/interfaces/IVin.md +70 -0
- package/docs/markdown/interfaces/IVout.md +52 -0
- package/docs/markdown/interfaces/IWallet.md +209 -0
- package/docs/markdown/interfaces/IWalletData.md +217 -0
- package/example/helpers.ts +76 -0
- package/example/index.ts +77 -0
- package/package.json +69 -0
- package/src/electrum/constants.ts +28 -0
- package/src/electrum/index.ts +838 -0
- package/src/index.ts +6 -0
- package/src/shapes/electrum.ts +13 -0
- package/src/shapes/index.ts +2 -0
- package/src/shapes/wallet.ts +133 -0
- package/src/transaction/index.ts +1078 -0
- package/src/types/electrum.ts +139 -0
- package/src/types/index.ts +3 -0
- package/src/types/transaction.ts +58 -0
- package/src/types/wallet.ts +503 -0
- package/src/utils/conversion.ts +88 -0
- package/src/utils/derivation-path.ts +171 -0
- package/src/utils/electrum.ts +188 -0
- package/src/utils/exchange-rate.ts +70 -0
- package/src/utils/helpers.ts +191 -0
- package/src/utils/index.ts +7 -0
- package/src/utils/result.ts +79 -0
- package/src/utils/transaction.ts +417 -0
- package/src/utils/wallet.ts +351 -0
- package/src/wallet/constants.ts +24 -0
- package/src/wallet/index.ts +3304 -0
- package/tests/constants.ts +9 -0
- package/tests/derivation.test.ts +146 -0
- package/tests/electrum.test.ts +137 -0
- package/tests/storage.test.ts +222 -0
- package/tests/transaction.test.ts +187 -0
- package/tests/wallet.test.ts +307 -0
- package/tsconfig.json +32 -0
- package/typedoc.json +5 -0
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Result } from '../utils';
|
|
4
|
+
import { IHeader, INewBlock, TElectrumNetworks, TServer, TTxResult } from './electrum';
|
|
5
|
+
import { EFeeId } from './transaction';
|
|
6
|
+
import { TLSSocket } from 'tls';
|
|
7
|
+
import { Server } from 'net';
|
|
8
|
+
export type TAvailableNetworks = 'bitcoin' | 'testnet' | 'regtest';
|
|
9
|
+
export type TAddressType = 'p2wpkh' | 'p2sh' | 'p2pkh';
|
|
10
|
+
export type TAddressLabel = 'bech32' | 'segwit' | 'legacy';
|
|
11
|
+
export type TKeyDerivationPurpose = '84' | '49' | '44' | string;
|
|
12
|
+
export type TKeyDerivationCoinType = '0' | '1' | string;
|
|
13
|
+
export type TKeyDerivationAccount = '0' | string;
|
|
14
|
+
export type TKeyDerivationChange = '0' | '1';
|
|
15
|
+
export type TKeyDerivationIndex = string;
|
|
16
|
+
export type TAddressTypes = {
|
|
17
|
+
[key in EAddressType]: Readonly<IAddressTypeData>;
|
|
18
|
+
};
|
|
19
|
+
export declare enum EAvailableNetworks {
|
|
20
|
+
bitcoin = "bitcoin",
|
|
21
|
+
mainnet = "bitcoin",
|
|
22
|
+
bitcoinMainnet = "bitcoin",
|
|
23
|
+
testnet = "testnet",
|
|
24
|
+
bitcoinTestnet = "testnet",
|
|
25
|
+
regtest = "regtest",
|
|
26
|
+
bitcoinRegtest = "regtest"
|
|
27
|
+
}
|
|
28
|
+
export declare enum EAddressType {
|
|
29
|
+
p2wpkh = "p2wpkh",
|
|
30
|
+
p2sh = "p2sh",
|
|
31
|
+
p2pkh = "p2pkh"
|
|
32
|
+
}
|
|
33
|
+
export declare enum EPaymentType {
|
|
34
|
+
sent = "sent",
|
|
35
|
+
received = "received"
|
|
36
|
+
}
|
|
37
|
+
export type TAddressTypeContent<T> = {
|
|
38
|
+
[key in EAddressType]: T;
|
|
39
|
+
};
|
|
40
|
+
export interface IAddressTypeData {
|
|
41
|
+
type: EAddressType;
|
|
42
|
+
path: string;
|
|
43
|
+
name: string;
|
|
44
|
+
shortName: string;
|
|
45
|
+
description: string;
|
|
46
|
+
example: string;
|
|
47
|
+
}
|
|
48
|
+
export interface IUtxo {
|
|
49
|
+
address: string;
|
|
50
|
+
index: number;
|
|
51
|
+
path: string;
|
|
52
|
+
scriptHash: string;
|
|
53
|
+
height: number;
|
|
54
|
+
tx_hash: string;
|
|
55
|
+
tx_pos: number;
|
|
56
|
+
value: number;
|
|
57
|
+
}
|
|
58
|
+
export interface IVin {
|
|
59
|
+
scriptSig: {
|
|
60
|
+
asm: string;
|
|
61
|
+
hex: string;
|
|
62
|
+
};
|
|
63
|
+
sequence: number;
|
|
64
|
+
txid: string;
|
|
65
|
+
txinwitness: string[];
|
|
66
|
+
vout: number;
|
|
67
|
+
}
|
|
68
|
+
export interface IFormattedTransaction {
|
|
69
|
+
address: string;
|
|
70
|
+
height: number;
|
|
71
|
+
scriptHash: string;
|
|
72
|
+
totalInputValue: number;
|
|
73
|
+
matchedInputValue: number;
|
|
74
|
+
totalOutputValue: number;
|
|
75
|
+
matchedOutputValue: number;
|
|
76
|
+
fee: number;
|
|
77
|
+
satsPerByte: number;
|
|
78
|
+
type: EPaymentType;
|
|
79
|
+
value: number;
|
|
80
|
+
txid: string;
|
|
81
|
+
messages: string[];
|
|
82
|
+
vin: IVin[];
|
|
83
|
+
timestamp: number;
|
|
84
|
+
confirmTimestamp?: number;
|
|
85
|
+
exists?: boolean;
|
|
86
|
+
rbf?: boolean;
|
|
87
|
+
vsize: number;
|
|
88
|
+
}
|
|
89
|
+
export interface IFormattedTransactions {
|
|
90
|
+
[key: string]: IFormattedTransaction;
|
|
91
|
+
}
|
|
92
|
+
export interface IOutput {
|
|
93
|
+
address: string;
|
|
94
|
+
value: number;
|
|
95
|
+
index: number;
|
|
96
|
+
}
|
|
97
|
+
export declare enum EBoostType {
|
|
98
|
+
rbf = "rbf",
|
|
99
|
+
cpfp = "cpfp"
|
|
100
|
+
}
|
|
101
|
+
export interface ISendTransaction {
|
|
102
|
+
outputs: IOutput[];
|
|
103
|
+
inputs: IUtxo[];
|
|
104
|
+
changeAddress: string;
|
|
105
|
+
fiatAmount: number;
|
|
106
|
+
fee: number;
|
|
107
|
+
satsPerByte: number;
|
|
108
|
+
selectedFeeId: EFeeId;
|
|
109
|
+
message: string;
|
|
110
|
+
label: string;
|
|
111
|
+
rbf: boolean;
|
|
112
|
+
boostType: EBoostType;
|
|
113
|
+
minFee: number;
|
|
114
|
+
max: boolean;
|
|
115
|
+
tags: string[];
|
|
116
|
+
slashTagsUrl?: string;
|
|
117
|
+
lightningInvoice?: string;
|
|
118
|
+
}
|
|
119
|
+
export interface IAddresses {
|
|
120
|
+
[scriptHash: string]: IAddress;
|
|
121
|
+
}
|
|
122
|
+
export interface IAddress {
|
|
123
|
+
index: number;
|
|
124
|
+
path: string;
|
|
125
|
+
address: string;
|
|
126
|
+
scriptHash: string;
|
|
127
|
+
publicKey: string;
|
|
128
|
+
}
|
|
129
|
+
export interface IWalletData {
|
|
130
|
+
id: string;
|
|
131
|
+
addressType: EAddressType;
|
|
132
|
+
header: IHeader;
|
|
133
|
+
addresses: TAddressTypeContent<IAddresses>;
|
|
134
|
+
changeAddresses: TAddressTypeContent<IAddresses>;
|
|
135
|
+
addressIndex: TAddressTypeContent<IAddress>;
|
|
136
|
+
changeAddressIndex: TAddressTypeContent<IAddress>;
|
|
137
|
+
lastUsedAddressIndex: TAddressTypeContent<IAddress>;
|
|
138
|
+
lastUsedChangeAddressIndex: TAddressTypeContent<IAddress>;
|
|
139
|
+
utxos: IUtxo[];
|
|
140
|
+
blacklistedUtxos: IUtxo[];
|
|
141
|
+
unconfirmedTransactions: IFormattedTransactions;
|
|
142
|
+
transactions: IFormattedTransactions;
|
|
143
|
+
boostedTransactions: IBoostedTransactions;
|
|
144
|
+
transaction: ISendTransaction;
|
|
145
|
+
balance: number;
|
|
146
|
+
selectedFeeId: EFeeId;
|
|
147
|
+
exchangeRates: IExchangeRates;
|
|
148
|
+
feeEstimates: IOnchainFees;
|
|
149
|
+
}
|
|
150
|
+
export type TWalletDataKeys = keyof IWalletData;
|
|
151
|
+
export type TGetData = <K extends keyof IWalletData>(key: string) => Promise<Result<IWalletData[K]>>;
|
|
152
|
+
export type TSetData = <K extends keyof IWalletData>(key: string, value: IWalletData[K]) => Promise<Result<boolean>>;
|
|
153
|
+
export interface IWallet {
|
|
154
|
+
mnemonic: string;
|
|
155
|
+
id?: string;
|
|
156
|
+
name?: string;
|
|
157
|
+
passphrase?: string;
|
|
158
|
+
network?: EAvailableNetworks;
|
|
159
|
+
addressType?: EAddressType;
|
|
160
|
+
data?: IWalletData;
|
|
161
|
+
storage?: TStorage;
|
|
162
|
+
electrumOptions?: {
|
|
163
|
+
servers?: TServer | TServer[];
|
|
164
|
+
tls?: TLSSocket;
|
|
165
|
+
net?: Server;
|
|
166
|
+
};
|
|
167
|
+
remainOffline?: boolean;
|
|
168
|
+
onMessage?: TOnMessage;
|
|
169
|
+
customGetAddress?: (data: ICustomGetAddress) => Promise<Result<IGetAddressResponse>>;
|
|
170
|
+
customGetScriptHash?: (data: ICustomGetScriptHash) => Promise<string>;
|
|
171
|
+
rbf?: boolean;
|
|
172
|
+
selectedFeeId?: EFeeId;
|
|
173
|
+
}
|
|
174
|
+
export interface IAddressData {
|
|
175
|
+
path: string;
|
|
176
|
+
type: 'p2wpkh' | 'p2sh' | 'p2pkh';
|
|
177
|
+
label: string;
|
|
178
|
+
}
|
|
179
|
+
export interface IAddressType {
|
|
180
|
+
[key: string]: IAddressData;
|
|
181
|
+
}
|
|
182
|
+
export interface IKeyDerivationPath {
|
|
183
|
+
purpose?: TKeyDerivationPurpose;
|
|
184
|
+
coinType?: TKeyDerivationCoinType;
|
|
185
|
+
account?: TKeyDerivationAccount;
|
|
186
|
+
change?: TKeyDerivationChange;
|
|
187
|
+
index?: TKeyDerivationIndex;
|
|
188
|
+
}
|
|
189
|
+
export interface IGetDerivationPath extends IKeyDerivationPath {
|
|
190
|
+
addressType?: EAddressType;
|
|
191
|
+
}
|
|
192
|
+
export interface IGetAddress {
|
|
193
|
+
index?: TKeyDerivationIndex;
|
|
194
|
+
changeAddress?: boolean;
|
|
195
|
+
addressType?: EAddressType;
|
|
196
|
+
}
|
|
197
|
+
export interface ICustomGetAddress {
|
|
198
|
+
path: string;
|
|
199
|
+
type: EAddressType;
|
|
200
|
+
selectedNetwork?: TElectrumNetworks;
|
|
201
|
+
}
|
|
202
|
+
export interface ICustomGetScriptHash {
|
|
203
|
+
address: string;
|
|
204
|
+
selectedNetwork?: TElectrumNetworks;
|
|
205
|
+
}
|
|
206
|
+
export interface IGetAddressByPath {
|
|
207
|
+
path: string;
|
|
208
|
+
addressType?: EAddressType;
|
|
209
|
+
}
|
|
210
|
+
export interface IGetAddressBalanceRes {
|
|
211
|
+
confirmed: number;
|
|
212
|
+
unconfirmed: number;
|
|
213
|
+
}
|
|
214
|
+
export interface IUtxo {
|
|
215
|
+
address: string;
|
|
216
|
+
index: number;
|
|
217
|
+
path: string;
|
|
218
|
+
scriptHash: string;
|
|
219
|
+
height: number;
|
|
220
|
+
tx_hash: string;
|
|
221
|
+
tx_pos: number;
|
|
222
|
+
value: number;
|
|
223
|
+
}
|
|
224
|
+
export interface IGenerateAddresses {
|
|
225
|
+
addressAmount?: number;
|
|
226
|
+
changeAddressAmount?: number;
|
|
227
|
+
addressIndex?: number;
|
|
228
|
+
changeAddressIndex?: number;
|
|
229
|
+
keyDerivationPath?: IKeyDerivationPath;
|
|
230
|
+
addressType?: EAddressType;
|
|
231
|
+
}
|
|
232
|
+
export interface IKeyDerivationPathData {
|
|
233
|
+
pathString: string;
|
|
234
|
+
pathObject: IKeyDerivationPath;
|
|
235
|
+
}
|
|
236
|
+
export interface IGenerateAddressesResponse {
|
|
237
|
+
addresses: IAddresses;
|
|
238
|
+
changeAddresses: IAddresses;
|
|
239
|
+
}
|
|
240
|
+
export interface IGetAddressResponse {
|
|
241
|
+
address: string;
|
|
242
|
+
path: string;
|
|
243
|
+
publicKey: string;
|
|
244
|
+
}
|
|
245
|
+
export interface IGetNextAvailableAddressResponse {
|
|
246
|
+
addressIndex: IAddress;
|
|
247
|
+
lastUsedAddressIndex: IAddress;
|
|
248
|
+
changeAddressIndex: IAddress;
|
|
249
|
+
lastUsedChangeAddressIndex: IAddress;
|
|
250
|
+
}
|
|
251
|
+
export interface ITxHashes extends TTxResult {
|
|
252
|
+
scriptHash: string;
|
|
253
|
+
}
|
|
254
|
+
export interface IIndexes {
|
|
255
|
+
addressIndex: IAddress;
|
|
256
|
+
changeAddressIndex: IAddress;
|
|
257
|
+
foundAddressIndex: boolean;
|
|
258
|
+
foundChangeAddressIndex: boolean;
|
|
259
|
+
}
|
|
260
|
+
export interface ITxHash {
|
|
261
|
+
tx_hash: string;
|
|
262
|
+
}
|
|
263
|
+
export interface IGetTransactions {
|
|
264
|
+
error: boolean;
|
|
265
|
+
id: number;
|
|
266
|
+
method: string;
|
|
267
|
+
network: string;
|
|
268
|
+
data: ITransaction<IUtxo>[];
|
|
269
|
+
}
|
|
270
|
+
export interface ITransaction<T> {
|
|
271
|
+
id: number;
|
|
272
|
+
jsonrpc: string;
|
|
273
|
+
param: string;
|
|
274
|
+
data: T;
|
|
275
|
+
result: {
|
|
276
|
+
blockhash: string;
|
|
277
|
+
confirmations: number;
|
|
278
|
+
hash: string;
|
|
279
|
+
hex: string;
|
|
280
|
+
locktime: number;
|
|
281
|
+
size: number;
|
|
282
|
+
txid: string;
|
|
283
|
+
version: number;
|
|
284
|
+
vin: IVin[];
|
|
285
|
+
vout: IVout[];
|
|
286
|
+
vsize: number;
|
|
287
|
+
weight: number;
|
|
288
|
+
blocktime?: number;
|
|
289
|
+
time?: number;
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
export interface IVout {
|
|
293
|
+
n: number;
|
|
294
|
+
scriptPubKey: {
|
|
295
|
+
addresses?: string[];
|
|
296
|
+
address?: string;
|
|
297
|
+
asm: string;
|
|
298
|
+
hex: string;
|
|
299
|
+
reqSigs?: number;
|
|
300
|
+
type?: string;
|
|
301
|
+
};
|
|
302
|
+
value: number;
|
|
303
|
+
}
|
|
304
|
+
export type TProcessUnconfirmedTransactions = {
|
|
305
|
+
unconfirmedTxs: IFormattedTransactions;
|
|
306
|
+
outdatedTxs: IUtxo[];
|
|
307
|
+
ghostTxs: string[];
|
|
308
|
+
};
|
|
309
|
+
export declare enum EUnit {
|
|
310
|
+
satoshi = "satoshi",
|
|
311
|
+
BTC = "BTC",
|
|
312
|
+
fiat = "fiat"
|
|
313
|
+
}
|
|
314
|
+
export interface IExchangeRates {
|
|
315
|
+
[key: string]: {
|
|
316
|
+
currencySymbol: string;
|
|
317
|
+
quote: string;
|
|
318
|
+
quoteName: string;
|
|
319
|
+
rate: number;
|
|
320
|
+
lastUpdatedAt: number;
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
export type InputData = {
|
|
324
|
+
[key: string]: {
|
|
325
|
+
addresses: string[];
|
|
326
|
+
value: number;
|
|
327
|
+
};
|
|
328
|
+
};
|
|
329
|
+
export type TGetByteCountInputs = {
|
|
330
|
+
[key in TGetByteCountInput]?: number;
|
|
331
|
+
};
|
|
332
|
+
export type TGetByteCountOutputs = {
|
|
333
|
+
[key in TGetByteCountOutput]?: number;
|
|
334
|
+
};
|
|
335
|
+
export type TGetByteCountInput = `MULTISIG-P2SH:${number}-${number}` | `MULTISIG-P2WSH:${number}-${number}` | `MULTISIG-P2SH-P2WSH:${number}-${number}` | 'P2SH-P2WPKH' | 'P2PKH' | 'p2pkh' | 'P2WPKH' | 'p2wpkh' | 'P2SH' | 'p2sh' | 'P2TR' | 'p2tr';
|
|
336
|
+
export type TGetByteCountOutput = 'P2SH' | 'P2PKH' | 'P2WPKH' | 'P2WSH' | 'p2wpkh' | 'p2sh' | 'p2pkh' | 'P2TR' | 'p2tr';
|
|
337
|
+
export interface IGetFeeEstimatesResponse {
|
|
338
|
+
fastestFee: number;
|
|
339
|
+
halfHourFee: number;
|
|
340
|
+
hourFee: number;
|
|
341
|
+
minimumFee: number;
|
|
342
|
+
}
|
|
343
|
+
export interface IOnchainFees {
|
|
344
|
+
fast: number;
|
|
345
|
+
normal: number;
|
|
346
|
+
slow: number;
|
|
347
|
+
minimum: number;
|
|
348
|
+
timestamp: number;
|
|
349
|
+
}
|
|
350
|
+
export type TMessageDataMap = {
|
|
351
|
+
newBlock: INewBlock;
|
|
352
|
+
transactionReceived: TTransactionMessage;
|
|
353
|
+
transactionConfirmed: TTransactionMessage;
|
|
354
|
+
transactionSent: TTransactionMessage;
|
|
355
|
+
reorg: IUtxo[];
|
|
356
|
+
rbf: string[];
|
|
357
|
+
connectedToElectrum: boolean;
|
|
358
|
+
};
|
|
359
|
+
export type TTransactionMessage = {
|
|
360
|
+
transaction: IFormattedTransaction;
|
|
361
|
+
};
|
|
362
|
+
export type ObjectKeys<T extends object> = `${Exclude<keyof T, symbol>}`;
|
|
363
|
+
export type TOnMessage = <K extends keyof TMessageDataMap>(key: K, data: TMessageDataMap[K]) => void;
|
|
364
|
+
export type TMessageKeys = keyof TMessageDataMap;
|
|
365
|
+
export interface ISendTx {
|
|
366
|
+
address: string;
|
|
367
|
+
amount: number;
|
|
368
|
+
message?: string;
|
|
369
|
+
}
|
|
370
|
+
export interface ISend {
|
|
371
|
+
txs: ISendTx | ISendTx[];
|
|
372
|
+
satsPerByte?: number;
|
|
373
|
+
}
|
|
374
|
+
export type TAddressIndexInfo = {
|
|
375
|
+
addressIndex: IAddress;
|
|
376
|
+
changeAddressIndex: IAddress;
|
|
377
|
+
lastUsedAddressIndex: IAddress;
|
|
378
|
+
lastUsedChangeAddressIndex: IAddress;
|
|
379
|
+
};
|
|
380
|
+
export type TStorage = {
|
|
381
|
+
getData?: TGetData;
|
|
382
|
+
setData?: TSetData;
|
|
383
|
+
};
|
|
384
|
+
export interface IRbfData {
|
|
385
|
+
outputs: IOutput[];
|
|
386
|
+
balance: number;
|
|
387
|
+
addressType: EAddressType;
|
|
388
|
+
fee: number;
|
|
389
|
+
inputs: IUtxo[];
|
|
390
|
+
message: string;
|
|
391
|
+
}
|
|
392
|
+
export interface IBoostedTransaction {
|
|
393
|
+
parentTransactions: string[];
|
|
394
|
+
childTransaction: string;
|
|
395
|
+
type: EBoostType;
|
|
396
|
+
fee: number;
|
|
397
|
+
}
|
|
398
|
+
export interface IBoostedTransactions {
|
|
399
|
+
[txId: string]: IBoostedTransaction;
|
|
400
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EUnit } from '../types';
|
|
2
|
+
export declare const btcToSats: (value: number) => number;
|
|
3
|
+
export declare const satsToBtc: (value: number) => number;
|
|
4
|
+
export declare const convertToSats: (value: number | string, unit: EUnit, exchangeRate: number, currency?: string) => number;
|
|
5
|
+
export declare const fiatToBitcoinUnit: ({ fiatValue, exchangeRate, currency, unit }: {
|
|
6
|
+
fiatValue: string | number;
|
|
7
|
+
exchangeRate: number;
|
|
8
|
+
currency: string;
|
|
9
|
+
unit: EUnit;
|
|
10
|
+
}) => number;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { EAddressType, EAvailableNetworks, IKeyDerivationPath, TKeyDerivationPurpose } from '../types';
|
|
2
|
+
import { Result } from './result';
|
|
3
|
+
export declare const getKeyDerivationPathObject: ({ path, purpose, changeAddress, index, network }: {
|
|
4
|
+
path: string;
|
|
5
|
+
purpose?: string | undefined;
|
|
6
|
+
changeAddress?: boolean | undefined;
|
|
7
|
+
index?: string | undefined;
|
|
8
|
+
network: EAvailableNetworks;
|
|
9
|
+
}) => Result<IKeyDerivationPath>;
|
|
10
|
+
export declare const getKeyDerivationPathString: ({ addressType, path, purpose, accountType, changeAddress, index, network }: {
|
|
11
|
+
addressType: EAddressType;
|
|
12
|
+
path?: IKeyDerivationPath | undefined;
|
|
13
|
+
purpose?: string | undefined;
|
|
14
|
+
accountType?: string | number | undefined;
|
|
15
|
+
changeAddress?: boolean | undefined;
|
|
16
|
+
index?: string | number | undefined;
|
|
17
|
+
network: EAvailableNetworks;
|
|
18
|
+
}) => Result<string>;
|
|
19
|
+
export declare const getAddressTypeFromPath: (path: string | IKeyDerivationPath) => Result<EAddressType>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Result } from './result';
|
|
2
|
+
import { EAvailableNetworks, ElectrumConnectionPubSub, IFormattedPeerData, TProtocol } from '../types';
|
|
3
|
+
export declare const defaultElectrumPorts: string[];
|
|
4
|
+
export declare const getDefaultPort: (selectedNetwork: EAvailableNetworks, protocol: TProtocol) => number;
|
|
5
|
+
export declare const getProtocolForPort: (port: string, network: EAvailableNetworks) => TProtocol | undefined;
|
|
6
|
+
export declare const formatPeerData: (data: [string, string, [string, string, string]]) => Result<IFormattedPeerData>;
|
|
7
|
+
export declare const getPeers: ({ selectedNetwork }: {
|
|
8
|
+
selectedNetwork: EAvailableNetworks;
|
|
9
|
+
}) => Promise<Result<IFormattedPeerData[]>>;
|
|
10
|
+
export declare const electrumConnection: ElectrumConnectionPubSub;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Result } from './result';
|
|
2
|
+
import { IExchangeRates } from '../types';
|
|
3
|
+
export declare const mostUsedExchangeTickers: {
|
|
4
|
+
USD: {
|
|
5
|
+
currencySymbol: string;
|
|
6
|
+
quote: string;
|
|
7
|
+
quoteName: string;
|
|
8
|
+
};
|
|
9
|
+
GBP: {
|
|
10
|
+
currencySymbol: string;
|
|
11
|
+
quote: string;
|
|
12
|
+
quoteName: string;
|
|
13
|
+
};
|
|
14
|
+
CAD: {
|
|
15
|
+
currencySymbol: string;
|
|
16
|
+
quote: string;
|
|
17
|
+
quoteName: string;
|
|
18
|
+
};
|
|
19
|
+
CNY: {
|
|
20
|
+
currencySymbol: string;
|
|
21
|
+
quote: string;
|
|
22
|
+
quoteName: string;
|
|
23
|
+
};
|
|
24
|
+
EUR: {
|
|
25
|
+
currencySymbol: string;
|
|
26
|
+
quote: string;
|
|
27
|
+
quoteName: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export declare const getExchangeRates: () => Promise<Result<IExchangeRates>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EAddressType, EAvailableNetworks, IKeyDerivationPath } from '../types';
|
|
3
|
+
import { Result } from './result';
|
|
4
|
+
export declare const getAddressFromScriptPubKey: (scriptPubKey: string, selectedNetwork: EAvailableNetworks) => string;
|
|
5
|
+
export declare const getSha256: (str: string) => string;
|
|
6
|
+
export declare const validateAddress: ({ address, network }: {
|
|
7
|
+
address: string;
|
|
8
|
+
network?: EAvailableNetworks | undefined;
|
|
9
|
+
}) => {
|
|
10
|
+
isValid: boolean;
|
|
11
|
+
network: EAvailableNetworks;
|
|
12
|
+
};
|
|
13
|
+
export declare const getKeyDerivationPath: ({ addressType, network }: {
|
|
14
|
+
addressType: EAddressType;
|
|
15
|
+
network: EAvailableNetworks;
|
|
16
|
+
}) => Result<IKeyDerivationPath>;
|
|
17
|
+
export declare const getScriptHash: ({ address, network }: {
|
|
18
|
+
address: string;
|
|
19
|
+
network: EAvailableNetworks;
|
|
20
|
+
}) => string;
|
|
21
|
+
export declare const generateMnemonic: (strength?: number, rng?: ((size: number) => Buffer) | undefined, wordlist?: string[]) => string;
|
|
22
|
+
export declare const validateMnemonic: (mnemonic?: string) => boolean;
|
|
23
|
+
export declare const objectsMatch: (obj1: any, obj2: any) => boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type Result<T> = Ok<T> | Err<T>;
|
|
2
|
+
declare class Ok<T> {
|
|
3
|
+
readonly value: T;
|
|
4
|
+
constructor(value: T);
|
|
5
|
+
isOk(): this is Ok<T>;
|
|
6
|
+
isErr(): this is Err<T>;
|
|
7
|
+
}
|
|
8
|
+
declare class Err<T> {
|
|
9
|
+
readonly error: Error;
|
|
10
|
+
constructor(error: Error);
|
|
11
|
+
isOk(): this is Ok<T>;
|
|
12
|
+
isErr(): this is Err<T>;
|
|
13
|
+
}
|
|
14
|
+
export declare const ok: <T>(value: T) => Ok<T>;
|
|
15
|
+
export declare const err: <T>(error: Error | string) => Err<T>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Psbt } from 'bitcoinjs-lib';
|
|
2
|
+
import { Result } from './result';
|
|
3
|
+
import { EAddressType, EAvailableNetworks, IOutput, ISendTransaction, TDecodeRawTx, TGetByteCountInputs, TGetByteCountOutputs } from '../types';
|
|
4
|
+
export declare const setReplaceByFee: ({ psbt, setRbf }: {
|
|
5
|
+
psbt: Psbt;
|
|
6
|
+
setRbf: boolean;
|
|
7
|
+
}) => void;
|
|
8
|
+
export declare const parseOnChainPaymentRequest: (data: string, network?: EAvailableNetworks) => Result<{
|
|
9
|
+
address: string;
|
|
10
|
+
network: EAvailableNetworks;
|
|
11
|
+
sats: number;
|
|
12
|
+
message: string;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const constructByteCountParam: (addresses: string[], increaseAddressCount?: {
|
|
15
|
+
addrType: EAddressType;
|
|
16
|
+
count: number;
|
|
17
|
+
}[]) => TGetByteCountInputs | TGetByteCountOutputs;
|
|
18
|
+
export declare const getByteCount: (inputs: TGetByteCountInputs, outputs: TGetByteCountOutputs, message?: string) => number;
|
|
19
|
+
export declare const removeDustOutputs: (outputs: IOutput[]) => IOutput[];
|
|
20
|
+
export declare const validateTransaction: (transaction: ISendTransaction) => Result<string>;
|
|
21
|
+
export declare const decodeRawTransaction: (hex: string, _network: EAvailableNetworks) => Result<TDecodeRawTx>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EAddressType, EAvailableNetworks, IAddress, IAddresses, IIndexes, IKeyDerivationPath, IKeyDerivationPathData, ITxHashes, IWalletData, ObjectKeys, TGetData, TKeyDerivationPurpose } from '../types';
|
|
3
|
+
import { Result } from './result';
|
|
4
|
+
export declare const getDefaultWalletData: () => IWalletData;
|
|
5
|
+
export declare const getDefaultWalletDataKeys: () => (keyof IWalletData)[];
|
|
6
|
+
export declare const getKeyValue: (key: string) => string;
|
|
7
|
+
export declare const objectKeys: <Type extends object>(value: Type) => `${Exclude<keyof Type, symbol>}`[];
|
|
8
|
+
export declare const formatKeyDerivationPath: ({ path, purpose, network, changeAddress, index, addressType }: {
|
|
9
|
+
path: IKeyDerivationPath | string;
|
|
10
|
+
purpose?: string | undefined;
|
|
11
|
+
network: EAvailableNetworks;
|
|
12
|
+
changeAddress?: boolean | undefined;
|
|
13
|
+
index?: string | undefined;
|
|
14
|
+
addressType?: EAddressType | undefined;
|
|
15
|
+
}) => Result<IKeyDerivationPathData>;
|
|
16
|
+
export declare const getHighestUsedIndexFromTxHashes: ({ txHashes, addresses, changeAddresses, addressIndex, changeAddressIndex }: {
|
|
17
|
+
txHashes: ITxHashes[];
|
|
18
|
+
addresses: IAddresses;
|
|
19
|
+
changeAddresses: IAddresses;
|
|
20
|
+
addressIndex: IAddress;
|
|
21
|
+
changeAddressIndex: IAddress;
|
|
22
|
+
}) => Result<IIndexes>;
|
|
23
|
+
export declare const isValidBech32mEncodedString: (address: string) => {
|
|
24
|
+
isValid: boolean;
|
|
25
|
+
network: EAvailableNetworks;
|
|
26
|
+
};
|
|
27
|
+
export declare const availableNetworks: () => EAvailableNetworks[];
|
|
28
|
+
export declare const reduceValue: <T>({ arr, value }: {
|
|
29
|
+
arr: T[];
|
|
30
|
+
value: keyof T;
|
|
31
|
+
}) => Result<number>;
|
|
32
|
+
export declare const shuffleArray: <T>(array: T[]) => T[];
|
|
33
|
+
export declare const getDataFallback: TGetData;
|
|
34
|
+
export declare const decodeOpReturnMessage: (opReturn?: string) => string[];
|
|
35
|
+
export declare const getSeed: (mnemonic: any, bip39Passphrase: any) => Buffer;
|
|
36
|
+
export declare const getSeedHash: (seed: Buffer) => string;
|
|
37
|
+
export declare const generateWalletId: (seed: Buffer) => string;
|
|
38
|
+
export declare const getWalletDataStorageKey: (name: string, network: EAvailableNetworks, key: keyof IWalletData) => string;
|
|
39
|
+
export declare const getStorageKeyValues: (storageKey: string) => {
|
|
40
|
+
walletName: string;
|
|
41
|
+
network: EAvailableNetworks;
|
|
42
|
+
value: keyof IWalletData;
|
|
43
|
+
};
|
|
44
|
+
export declare const getTxFee: ({ satsPerByte, transactionByteCount }: {
|
|
45
|
+
satsPerByte: number;
|
|
46
|
+
transactionByteCount: number;
|
|
47
|
+
}) => number;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare const BITKIT_WALLET_SEED_HASH_PREFIX: Buffer;
|
|
3
|
+
export declare const WALLET_ID_PREFIX: Buffer;
|
|
4
|
+
export declare const GENERATE_ADDRESS_AMOUNT = 5;
|
|
5
|
+
export declare const GAP_LIMIT = 20;
|
|
6
|
+
export declare const CHUNK_LIMIT = 15;
|
|
7
|
+
export declare const SPENDING_LIMIT_RATIO = 0.8;
|
|
8
|
+
export declare const TRANSACTION_DEFAULTS: {
|
|
9
|
+
recommendedBaseFee: number;
|
|
10
|
+
dustLimit: number;
|
|
11
|
+
};
|
|
12
|
+
export declare const BLOCKTANK_HOST = "https://api.stag.blocktank.to";
|