@avalabs/core-wallets-sdk 2.8.0-alpha.197
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/LICENSE +9 -0
- package/README.md +9 -0
- package/dist/index.d.ts +1794 -0
- package/dist/index.js +1 -0
- package/esm/Avalanche/index.d.ts +41 -0
- package/esm/Avalanche/index.js +1 -0
- package/esm/Avalanche/models.d.ts +173 -0
- package/esm/Avalanche/models.js +1 -0
- package/esm/Avalanche/providers/AbstractProvider.d.ts +39 -0
- package/esm/Avalanche/providers/AbstractProvider.js +1 -0
- package/esm/Avalanche/providers/JsonRpcProvider.d.ts +11 -0
- package/esm/Avalanche/providers/JsonRpcProvider.js +1 -0
- package/esm/Avalanche/providers/constants.d.ts +12 -0
- package/esm/Avalanche/providers/constants.js +1 -0
- package/esm/Avalanche/utils/addSignaturesToAvalancheTx.d.ts +16 -0
- package/esm/Avalanche/utils/addSignaturesToAvalancheTx.js +1 -0
- package/esm/Avalanche/utils/convertGlacierUtxo.d.ts +7 -0
- package/esm/Avalanche/utils/convertGlacierUtxo.js +1 -0
- package/esm/Avalanche/utils/createAvalancheEvmUnsignedTx.d.ts +11 -0
- package/esm/Avalanche/utils/createAvalancheEvmUnsignedTx.js +1 -0
- package/esm/Avalanche/utils/createAvalancheUnsignedTx.d.ts +13 -0
- package/esm/Avalanche/utils/createAvalancheUnsignedTx.js +1 -0
- package/esm/Avalanche/utils/digestMessage.d.ts +3 -0
- package/esm/Avalanche/utils/digestMessage.js +1 -0
- package/esm/Avalanche/utils/getAddressFromXpub.d.ts +14 -0
- package/esm/Avalanche/utils/getAddressFromXpub.js +1 -0
- package/esm/Avalanche/utils/getAddressPublicKeyFromXpub.d.ts +9 -0
- package/esm/Avalanche/utils/getAddressPublicKeyFromXpub.js +1 -0
- package/esm/Avalanche/utils/getAllUTXOs.d.ts +17 -0
- package/esm/Avalanche/utils/getAllUTXOs.js +1 -0
- package/esm/Avalanche/utils/getAssetBalance.d.ts +29 -0
- package/esm/Avalanche/utils/getAssetBalance.js +1 -0
- package/esm/Avalanche/utils/getChainAliasByChainId.js +1 -0
- package/esm/Avalanche/utils/getPchainUnixNow.d.ts +6 -0
- package/esm/Avalanche/utils/getPchainUnixNow.js +1 -0
- package/esm/Avalanche/utils/getStakeForAddresses.d.ts +5 -0
- package/esm/Avalanche/utils/getStakeForAddresses.js +1 -0
- package/esm/Avalanche/utils/getStakedAssetBalance.d.ts +16 -0
- package/esm/Avalanche/utils/getStakedAssetBalance.js +1 -0
- package/esm/Avalanche/utils/getTxOutputAddresses.js +1 -0
- package/esm/Avalanche/utils/getUnixNow.d.ts +6 -0
- package/esm/Avalanche/utils/getUnixNow.js +1 -0
- package/esm/Avalanche/utils/getUtxoInfo.d.ts +13 -0
- package/esm/Avalanche/utils/getUtxoInfo.js +1 -0
- package/esm/Avalanche/utils/getUtxosByTxFromGlacier.d.ts +13 -0
- package/esm/Avalanche/utils/getUtxosByTxFromGlacier.js +1 -0
- package/esm/Avalanche/utils/getVmByChainAlias.d.ts +3 -0
- package/esm/Avalanche/utils/getVmByChainAlias.js +1 -0
- package/esm/Avalanche/utils/getXpubFromMnemonic.d.ts +7 -0
- package/esm/Avalanche/utils/getXpubFromMnemonic.js +1 -0
- package/esm/Avalanche/utils/handleSubnetAuth.js +1 -0
- package/esm/Avalanche/utils/isBech32Address.d.ts +8 -0
- package/esm/Avalanche/utils/isBech32Address.js +1 -0
- package/esm/Avalanche/utils/parseAvalancheTx.d.ts +10 -0
- package/esm/Avalanche/utils/parseAvalancheTx.js +1 -0
- package/esm/Avalanche/utils/parsers/index.js +1 -0
- package/esm/Avalanche/utils/parsers/parseAddDelegatorTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseAddPermissionlessDelegatorTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseAddPermissionlessValidatorTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseAddSubnetValidorTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseAddValidatorTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseBaseTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseCreateChainTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseCreateSubnetTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseExportTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseImportTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseRemoveSubnetValidatorTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseTransferSubnetOwnershipTx.js +1 -0
- package/esm/Avalanche/utils/parsers/parseTransformSubnetTx.js +1 -0
- package/esm/Avalanche/utils/parsers/utils/chainIdToVm.js +1 -0
- package/esm/Avalanche/utils/parsers/utils/getTransferableAmount.js +1 -0
- package/esm/Avalanche/utils/populateCredential.d.ts +9 -0
- package/esm/Avalanche/utils/populateCredential.js +1 -0
- package/esm/Avalanche/utils/signedTxToHex.d.ts +5 -0
- package/esm/Avalanche/utils/signedTxToHex.js +1 -0
- package/esm/Avalanche/utils/sortUTXOs.d.ts +14 -0
- package/esm/Avalanche/utils/sortUTXOs.js +1 -0
- package/esm/Avalanche/utils/txSizeLimits.d.ts +34 -0
- package/esm/Avalanche/utils/txSizeLimits.js +1 -0
- package/esm/Avalanche/utils/verifyDerivationPath.d.ts +7 -0
- package/esm/Avalanche/utils/verifyDerivationPath.js +1 -0
- package/esm/Avalanche/wallets/AddressWallet.d.ts +45 -0
- package/esm/Avalanche/wallets/AddressWallet.js +1 -0
- package/esm/Avalanche/wallets/SimpleSigner.d.ts +62 -0
- package/esm/Avalanche/wallets/SimpleSigner.js +1 -0
- package/esm/Avalanche/wallets/StaticSigner.d.ts +39 -0
- package/esm/Avalanche/wallets/StaticSigner.js +1 -0
- package/esm/Avalanche/wallets/WalletAbstract.d.ts +131 -0
- package/esm/Avalanche/wallets/WalletAbstract.js +1 -0
- package/esm/Avalanche/wallets/WalletVoid.d.ts +40 -0
- package/esm/Avalanche/wallets/WalletVoid.js +1 -0
- package/esm/Avalanche/wallets/ledger/LedgerSigner.d.ts +49 -0
- package/esm/Avalanche/wallets/ledger/LedgerSigner.js +1 -0
- package/esm/Avalanche/wallets/ledger/SimpleLedgerSigner.d.ts +32 -0
- package/esm/Avalanche/wallets/ledger/SimpleLedgerSigner.js +1 -0
- package/esm/Avalanche/wallets/ledger/ZondaxProvider.js +1 -0
- package/esm/Avalanche/wallets/ledger/constants.js +1 -0
- package/esm/Avalanche/wallets/ledger/getLedgerProvider.d.ts +10 -0
- package/esm/Avalanche/wallets/ledger/getLedgerProvider.js +1 -0
- package/esm/Avalanche/wallets/ledger/isObsidianApp.d.ts +5 -0
- package/esm/Avalanche/wallets/ledger/isObsidianApp.js +1 -0
- package/esm/Avalanche/wallets/ledger/models.d.ts +37 -0
- package/esm/Avalanche/wallets/legacy/LedgerWallet.d.ts +41 -0
- package/esm/Avalanche/wallets/legacy/LedgerWallet.js +1 -0
- package/esm/Avalanche/wallets/legacy/MnemonicWallet.d.ts +30 -0
- package/esm/Avalanche/wallets/legacy/MnemonicWallet.js +1 -0
- package/esm/Avalanche/wallets/legacy/MnemonicWalletVoid.d.ts +83 -0
- package/esm/Avalanche/wallets/legacy/MnemonicWalletVoid.js +1 -0
- package/esm/Avalanche/wallets/models.d.ts +35 -0
- package/esm/BitcoinVM/models.d.ts +77 -0
- package/esm/BitcoinVM/providers/BitcoinProvider.d.ts +42 -0
- package/esm/BitcoinVM/providers/BitcoinProvider.js +1 -0
- package/esm/BitcoinVM/providers/BitcoinProviderAbstract.d.ts +63 -0
- package/esm/BitcoinVM/providers/BitcoinProviderAbstract.js +1 -0
- package/esm/BitcoinVM/providers/models.js +1 -0
- package/esm/BitcoinVM/providers/utils/parseAddressFullTx.js +1 -0
- package/esm/BitcoinVM/utils/addEncodedSigToPsbt.d.ts +5 -0
- package/esm/BitcoinVM/utils/addEncodedSigToPsbt.js +1 -0
- package/esm/BitcoinVM/utils/createPSBTV2.d.ts +10 -0
- package/esm/BitcoinVM/utils/createPSBTV2.js +1 -0
- package/esm/BitcoinVM/utils/createPsbt.d.ts +12 -0
- package/esm/BitcoinVM/utils/createPsbt.js +1 -0
- package/esm/BitcoinVM/utils/createTransferTx.d.ts +20 -0
- package/esm/BitcoinVM/utils/createTransferTx.js +1 -0
- package/esm/BitcoinVM/utils/createWalletPolicy.d.ts +5 -0
- package/esm/BitcoinVM/utils/createWalletPolicy.js +1 -0
- package/esm/BitcoinVM/utils/filterDuplicateUTXOs.js +1 -0
- package/esm/BitcoinVM/utils/formatAddressForNetworkBech32.d.ts +10 -0
- package/esm/BitcoinVM/utils/formatAddressForNetworkBech32.js +1 -0
- package/esm/BitcoinVM/utils/getBech32Address.d.ts +10 -0
- package/esm/BitcoinVM/utils/getBech32Address.js +1 -0
- package/esm/BitcoinVM/utils/getBech32AddressFromXPub.d.ts +11 -0
- package/esm/BitcoinVM/utils/getBech32AddressFromXPub.js +1 -0
- package/esm/BitcoinVM/utils/getMaxTransferAmount.d.ts +13 -0
- package/esm/BitcoinVM/utils/getMaxTransferAmount.js +1 -0
- package/esm/BitcoinVM/utils/getTransferTxDetails.d.ts +17 -0
- package/esm/BitcoinVM/utils/getTransferTxDetails.js +1 -0
- package/esm/BitcoinVM/utils/psbt2ToPsbt0.d.ts +15 -0
- package/esm/BitcoinVM/utils/psbt2ToPsbt0.js +1 -0
- package/esm/BitcoinVM/utils/selectUtxos.d.ts +22 -0
- package/esm/BitcoinVM/utils/selectUtxos.js +1 -0
- package/esm/BitcoinVM/utils/sumUTXOs.js +1 -0
- package/esm/BitcoinVM/wallets/BitcoinWallet.d.ts +44 -0
- package/esm/BitcoinVM/wallets/BitcoinWallet.js +1 -0
- package/esm/BitcoinVM/wallets/BitcoinWalletAbstract.d.ts +72 -0
- package/esm/BitcoinVM/wallets/BitcoinWalletAbstract.js +1 -0
- package/esm/BitcoinVM/wallets/BitcoinWalletLedger.d.ts +34 -0
- package/esm/BitcoinVM/wallets/BitcoinWalletLedger.js +1 -0
- package/esm/BitcoinVM/wallets/BitcoinWalletVoid.d.ts +12 -0
- package/esm/BitcoinVM/wallets/BitcoinWalletVoid.js +1 -0
- package/esm/BitcoinVM/wallets/models.d.ts +8 -0
- package/esm/EVM/LedgerSigner.d.ts +23 -0
- package/esm/EVM/LedgerSigner.js +1 -0
- package/esm/EVM/constants.d.ts +8 -0
- package/esm/EVM/constants.js +1 -0
- package/esm/EVM/utils/blockPolling.d.ts +12 -0
- package/esm/EVM/utils/blockPolling.js +1 -0
- package/esm/EVM/utils/getAddressFromXPub.d.ts +9 -0
- package/esm/EVM/utils/getAddressFromXPub.js +1 -0
- package/esm/EVM/utils/getAddressPrivateKeyFromXPriv.d.ts +9 -0
- package/esm/EVM/utils/getAddressPrivateKeyFromXPriv.js +1 -0
- package/esm/EVM/utils/getAddressPublicKeyFromXPub.d.ts +9 -0
- package/esm/EVM/utils/getAddressPublicKeyFromXPub.js +1 -0
- package/esm/EVM/utils/getAppEth.d.ts +10 -0
- package/esm/EVM/utils/getAppEth.js +1 -0
- package/esm/EVM/utils/getBtcAddressFromPubKey.d.ts +10 -0
- package/esm/EVM/utils/getBtcAddressFromPubKey.js +1 -0
- package/esm/EVM/utils/getEvmAddressFromPubKey.d.ts +3 -0
- package/esm/EVM/utils/getEvmAddressFromPubKey.js +1 -0
- package/esm/EVM/utils/getVoidSigner.d.ts +10 -0
- package/esm/EVM/utils/getVoidSigner.js +1 -0
- package/esm/EVM/utils/getWalletFromMnemonic.d.ts +13 -0
- package/esm/EVM/utils/getWalletFromMnemonic.js +1 -0
- package/esm/EVM/utils/getXpubFromMnemonic.d.ts +7 -0
- package/esm/EVM/utils/getXpubFromMnemonic.js +1 -0
- package/esm/EVM/utils/jsonRpcBatchProvider.d.ts +31 -0
- package/esm/EVM/utils/jsonRpcBatchProvider.js +1 -0
- package/esm/EVM/utils/multicallABI.js +1 -0
- package/esm/index.d.ts +43 -0
- package/esm/index.js +1 -0
- package/esm/utils/binarySearch.js +1 -0
- package/esm/utils/getAddressDerivationPath.d.ts +11 -0
- package/esm/utils/getAddressDerivationPath.js +1 -0
- package/esm/utils/getLedgerAppInfo.d.ts +13 -0
- package/esm/utils/getLedgerAppInfo.js +1 -0
- package/esm/utils/getLedgerExtendedPublicKey.d.ts +12 -0
- package/esm/utils/getLedgerExtendedPublicKey.js +1 -0
- package/esm/utils/getPubKeyFromTransport.d.ts +7 -0
- package/esm/utils/getPubKeyFromTransport.js +1 -0
- package/esm/utils/getPublicKeyFromPrivateKey.d.ts +8 -0
- package/esm/utils/getPublicKeyFromPrivateKey.js +1 -0
- package/esm/utils/omitUndefinedKeys.d.ts +3 -0
- package/esm/utils/omitUndefinedKeys.js +1 -0
- package/esm/utils/openLedgerApp.d.ts +9 -0
- package/esm/utils/openLedgerApp.js +1 -0
- package/esm/utils/quitLedgerApp.d.ts +10 -0
- package/esm/utils/quitLedgerApp.js +1 -0
- package/package.json +58 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1794 @@
|
|
|
1
|
+
import { Transaction } from '@ledgerhq/hw-app-btc/lib/types';
|
|
2
|
+
import * as bitcoinjs_lib from 'bitcoinjs-lib';
|
|
3
|
+
import { Network, Psbt, ECPairInterface, Transaction as Transaction$1 } from 'bitcoinjs-lib';
|
|
4
|
+
export { networks as BtcNetworks } from 'bitcoinjs-lib';
|
|
5
|
+
import { WalletPolicy, PsbtV2 } from 'ledger-bitcoin';
|
|
6
|
+
import * as ethers from 'ethers';
|
|
7
|
+
import { Provider, VoidSigner, HDNodeWallet, TransactionResponse, JsonRpcProvider as JsonRpcProvider$1, FetchRequest, Network as Network$1, Contract, AbstractSigner, BytesLike, TransactionRequest, TypedDataDomain, TypedDataField } from 'ethers';
|
|
8
|
+
import Transport from '@ledgerhq/hw-transport';
|
|
9
|
+
import Eth from '@ledgerhq/hw-app-eth';
|
|
10
|
+
import * as _avalabs_avalanchejs from '@avalabs/avalanchejs';
|
|
11
|
+
import { VM, Common, OutputOwners, TransferableOutput, pvmSerial, Context, avm, pvm, evm, avaxSerial, utils, UnsignedTx, EVMUnsignedTx, Utxo, Credential, Signature } from '@avalabs/avalanchejs';
|
|
12
|
+
import * as _avalabs_avalanchejs_dist_vms_common from '@avalabs/avalanchejs/dist/vms/common';
|
|
13
|
+
import { Bip32Path } from 'bip32-path';
|
|
14
|
+
import AppZondax, { ResponseBase } from '@avalabs/hw-app-avalanche';
|
|
15
|
+
import { BIP32Interface } from 'bip32';
|
|
16
|
+
import { Utxo as Utxo$1, PChainUtxo } from '@avalabs/glacier-sdk';
|
|
17
|
+
import { WalletAbstract as WalletAbstract$1 } from 'Avalanche/wallets';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Custom Bitcoin UTXO interface.
|
|
21
|
+
*/
|
|
22
|
+
interface BitcoinInputUTXO {
|
|
23
|
+
txHash: string;
|
|
24
|
+
txHex?: string;
|
|
25
|
+
index: number;
|
|
26
|
+
value: number;
|
|
27
|
+
script: string;
|
|
28
|
+
blockHeight: number;
|
|
29
|
+
confirmations: number;
|
|
30
|
+
confirmedTime?: string;
|
|
31
|
+
}
|
|
32
|
+
interface BitcoinInputUTXOWithOptionalScript extends Omit<BitcoinInputUTXO, 'script'> {
|
|
33
|
+
script?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Used for defining outputs when creating a transaction.
|
|
37
|
+
*/
|
|
38
|
+
interface BitcoinOutputUTXO {
|
|
39
|
+
address: string;
|
|
40
|
+
value: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Ledger needs UTXOs organized like this when signing.
|
|
44
|
+
*/
|
|
45
|
+
type BitcoinLedgerInputUTXO = [
|
|
46
|
+
tx: Transaction,
|
|
47
|
+
outputIndex: number,
|
|
48
|
+
script: string | null | undefined,
|
|
49
|
+
sequence: number | null | undefined
|
|
50
|
+
];
|
|
51
|
+
/**
|
|
52
|
+
* An interface to simplify historic BTC transactions.
|
|
53
|
+
*/
|
|
54
|
+
interface BitcoinHistoryTx {
|
|
55
|
+
hash: string;
|
|
56
|
+
isSender: boolean;
|
|
57
|
+
addresses: string[];
|
|
58
|
+
fee: number;
|
|
59
|
+
block: number;
|
|
60
|
+
amount: number;
|
|
61
|
+
confirmations: number;
|
|
62
|
+
containsMultisig: boolean;
|
|
63
|
+
receivedTime: number;
|
|
64
|
+
confirmedTime?: number;
|
|
65
|
+
}
|
|
66
|
+
interface BitcoinTx {
|
|
67
|
+
hash: string;
|
|
68
|
+
fees: number;
|
|
69
|
+
block: number;
|
|
70
|
+
amount: number;
|
|
71
|
+
confirmations: number;
|
|
72
|
+
blockTime: number;
|
|
73
|
+
addresses: string[];
|
|
74
|
+
inputs: {
|
|
75
|
+
txid: string;
|
|
76
|
+
vout: number;
|
|
77
|
+
sequence: number;
|
|
78
|
+
n: number;
|
|
79
|
+
addresses: string[];
|
|
80
|
+
isAddress: boolean;
|
|
81
|
+
value: number;
|
|
82
|
+
}[];
|
|
83
|
+
outputs: {
|
|
84
|
+
addresses: string[];
|
|
85
|
+
value: number;
|
|
86
|
+
n: number;
|
|
87
|
+
spent: boolean;
|
|
88
|
+
hex: string;
|
|
89
|
+
isAddress: boolean;
|
|
90
|
+
}[];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
declare abstract class BitcoinProviderAbstract {
|
|
94
|
+
/**
|
|
95
|
+
* Returns the UTXOs owned by the given address.
|
|
96
|
+
* @param address
|
|
97
|
+
*/
|
|
98
|
+
abstract getUTXOs(address: string, withScripts: boolean): Promise<{
|
|
99
|
+
confirmed: BitcoinInputUTXOWithOptionalScript[];
|
|
100
|
+
unconfirmed: BitcoinInputUTXOWithOptionalScript[];
|
|
101
|
+
}>;
|
|
102
|
+
/**
|
|
103
|
+
* Returns the connected network.
|
|
104
|
+
*/
|
|
105
|
+
abstract getNetwork(): Network;
|
|
106
|
+
/**
|
|
107
|
+
* Get the current chain height.
|
|
108
|
+
*/
|
|
109
|
+
abstract getChainHeight(): Promise<number>;
|
|
110
|
+
/**
|
|
111
|
+
* Returns the available balance for the user in satoshis.
|
|
112
|
+
*/
|
|
113
|
+
abstract getBalances(address: string): Promise<{
|
|
114
|
+
available: bigint;
|
|
115
|
+
pending: bigint;
|
|
116
|
+
final: bigint;
|
|
117
|
+
}>;
|
|
118
|
+
/**
|
|
119
|
+
* Returns available (confirmed) UTXOs and their total balance for the given address.
|
|
120
|
+
* @address Address to get UTXOs of.
|
|
121
|
+
*/
|
|
122
|
+
getUtxoBalance(address: string, withScripts?: boolean): Promise<{
|
|
123
|
+
balance: number;
|
|
124
|
+
balanceUnconfirmed: number;
|
|
125
|
+
utxos: BitcoinInputUTXOWithOptionalScript[];
|
|
126
|
+
utxosUnconfirmed: BitcoinInputUTXOWithOptionalScript[];
|
|
127
|
+
}>;
|
|
128
|
+
/**
|
|
129
|
+
* Given a transaction hash, return the base information of the transaction
|
|
130
|
+
*/
|
|
131
|
+
abstract getTransaction(hash: string): Promise<BitcoinTx>;
|
|
132
|
+
/**
|
|
133
|
+
* Given a transaction hash, return the whole transaction in hex format.
|
|
134
|
+
* @param txHash
|
|
135
|
+
*/
|
|
136
|
+
abstract getTxHex(txHash: string): Promise<string>;
|
|
137
|
+
/**
|
|
138
|
+
* Issues the given transaction to the bitcoin network
|
|
139
|
+
* @param tx
|
|
140
|
+
*/
|
|
141
|
+
abstract issueRawTx(tx: string): Promise<string>;
|
|
142
|
+
/**
|
|
143
|
+
* Returns the suggested fee rate in satoshis per byte.
|
|
144
|
+
*/
|
|
145
|
+
abstract getFeeRates(): Promise<{
|
|
146
|
+
high: number;
|
|
147
|
+
medium: number;
|
|
148
|
+
low: number;
|
|
149
|
+
}>;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
declare class BitcoinProvider extends BitcoinProviderAbstract {
|
|
153
|
+
#private;
|
|
154
|
+
private readonly isMainnet;
|
|
155
|
+
private readonly extraParams?;
|
|
156
|
+
constructor(isMainnet?: boolean, apiKey?: string, explorerUrl?: string, nodeUrl?: string, extraParams?: Record<string, string> | undefined);
|
|
157
|
+
getTxHex(txHash: string): Promise<string>;
|
|
158
|
+
getUTXOs(address: string, withScripts?: boolean): Promise<{
|
|
159
|
+
confirmed: BitcoinInputUTXOWithOptionalScript[];
|
|
160
|
+
unconfirmed: BitcoinInputUTXOWithOptionalScript[];
|
|
161
|
+
}>;
|
|
162
|
+
getScriptsForUtxos(utxos: BitcoinInputUTXOWithOptionalScript[]): Promise<BitcoinInputUTXO[]>;
|
|
163
|
+
private _parseUtxo;
|
|
164
|
+
getBalances(address: string): Promise<{
|
|
165
|
+
available: bigint;
|
|
166
|
+
pending: bigint;
|
|
167
|
+
final: bigint;
|
|
168
|
+
}>;
|
|
169
|
+
getChainHeight(): Promise<number>;
|
|
170
|
+
getFeeRates(): Promise<{
|
|
171
|
+
low: number;
|
|
172
|
+
medium: number;
|
|
173
|
+
high: number;
|
|
174
|
+
}>;
|
|
175
|
+
getNetwork(): Network;
|
|
176
|
+
issueRawTx(tx: string): Promise<string>;
|
|
177
|
+
getTransaction(hash: string): Promise<BitcoinTx>;
|
|
178
|
+
/**
|
|
179
|
+
* Returns the last 25 transactions
|
|
180
|
+
*/
|
|
181
|
+
getTxHistory(address: string): Promise<BitcoinHistoryTx[]>;
|
|
182
|
+
waitForTx(txHash: string, { maxAttempts, attempt, pollInterval, }?: {
|
|
183
|
+
maxAttempts?: number;
|
|
184
|
+
attempt?: number;
|
|
185
|
+
pollInterval?: number;
|
|
186
|
+
}): Promise<BitcoinTx>;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
declare function addEncodedSigToPsbt(sig: Buffer, pubkey: Buffer, psbt: Psbt, index: number): void;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Create an unsigned transaction.
|
|
193
|
+
* @param inputs The input UTXOs for the transaction.
|
|
194
|
+
* @param outputs The output UTXOs for the transaction.
|
|
195
|
+
* @param provider The provider for the tx network.
|
|
196
|
+
*/
|
|
197
|
+
declare function createPsbt(inputs: BitcoinInputUTXO[], outputs: BitcoinOutputUTXO[], network: Network): Psbt;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Create an unsigned bitcoin transfer transaction.
|
|
201
|
+
* @param to Destination address.
|
|
202
|
+
* @param changeAddress Change address.
|
|
203
|
+
* @param amount Amount to send.
|
|
204
|
+
* @param feeRate Satoshis per byte.
|
|
205
|
+
* @param sourceUtxos UTXOs to construct the transaction from.
|
|
206
|
+
* @param network The network the transaction will be on.
|
|
207
|
+
*/
|
|
208
|
+
declare function createTransferTx(to: string, changeAddress: string, amount: number, feeRate: number, sourceUtxos: BitcoinInputUTXO[], network: Network): {
|
|
209
|
+
fee: number;
|
|
210
|
+
inputs?: BitcoinInputUTXO[];
|
|
211
|
+
outputs?: BitcoinOutputUTXO[];
|
|
212
|
+
psbt?: Psbt;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Format the given address for the given network
|
|
217
|
+
* @param address Bech32 address to format
|
|
218
|
+
* @param network Network the new bech32 address will belong to
|
|
219
|
+
*/
|
|
220
|
+
declare function formatAddressForNetworkBech32(address: string, network: Network): string;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Return the bech32 address of a given public key.
|
|
224
|
+
* @param pubkey
|
|
225
|
+
* @param network
|
|
226
|
+
*/
|
|
227
|
+
declare function getBech32Address(pubkey: Buffer, network: Network): string;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Return the Bech32 address of the given address index from an xpub.
|
|
231
|
+
* @param xpub The extended public key of `m/44'/60'/0'`
|
|
232
|
+
* @param accountIndex The target address index.
|
|
233
|
+
* @param network Which network should the address be on.
|
|
234
|
+
*/
|
|
235
|
+
declare function getBech32AddressFromXPub(xpub: string, accountIndex: number, network: Network): string;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Calculate the maximum amount that can be sent in satoshis using the given UTXO set and parameters.
|
|
239
|
+
* @param ins UTXOs that can be consumed.
|
|
240
|
+
* @param to Destination address.
|
|
241
|
+
* @param changeAddress Change address.
|
|
242
|
+
* @param feeRate Fee rate in satoshis per byte.
|
|
243
|
+
* @returns Maximum transferable amount in satoshis.
|
|
244
|
+
*/
|
|
245
|
+
declare function getMaxTransferAmount(ins: BitcoinInputUTXOWithOptionalScript[], to: string, changeAddress: string, feeRate: number): number;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Uses coinselect to select the input and output utxos for the given information.
|
|
249
|
+
* Returns undefined if the transaction can not be completed.
|
|
250
|
+
* @param to Destination address.
|
|
251
|
+
* @param changeAddress Change address.
|
|
252
|
+
* @param amount Amount to send in satoshis.
|
|
253
|
+
* @param feeRate Satoshis per byte.
|
|
254
|
+
* @param sourceUtxos UTXOs to pick from to construct the transaction.
|
|
255
|
+
*/
|
|
256
|
+
declare function selectUtxos<InputUtxo extends BitcoinInputUTXO | BitcoinInputUTXOWithOptionalScript = BitcoinInputUTXO>(to: string, changeAddress: string, amount: number, feeRate: number, sourceUtxos: InputUtxo[]): {
|
|
257
|
+
fee: any;
|
|
258
|
+
inputs?: undefined;
|
|
259
|
+
outputs?: undefined;
|
|
260
|
+
} | {
|
|
261
|
+
inputs: InputUtxo[];
|
|
262
|
+
outputs: BitcoinOutputUTXO[];
|
|
263
|
+
fee: any;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
declare function createWalletPolicy(masterFingerprint: string, accountIndex: number, accountXPUB: string, policyName: string): WalletPolicy;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Used with the new BTC Ledger app.
|
|
270
|
+
*/
|
|
271
|
+
declare function createPSBTV2(ins: BitcoinInputUTXO[], outs: BitcoinOutputUTXO[], network: Network, masterFingerprint: Buffer, signerPubkey: Buffer, signerPath: string): PsbtV2;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Convert the given PSBTV2 object to bitcoinjs PSBT object. This is not a full feature
|
|
275
|
+
* conversion and only focuses on P2WPKH input conversion, which are the input types supported by
|
|
276
|
+
* the core wallets.
|
|
277
|
+
* @param psbt2
|
|
278
|
+
* @param network
|
|
279
|
+
* @param signerPub
|
|
280
|
+
* @param signerPath
|
|
281
|
+
*/
|
|
282
|
+
declare function psbt2ToPsbt0(psbt2: PsbtV2, network: Network, signerPub: Buffer, signerPath: string): Psbt;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Create an unsigned bitcoin transfer transaction.
|
|
286
|
+
* @param to Destination address.
|
|
287
|
+
* @param changeAddress Change address.
|
|
288
|
+
* @param amount Amount to send.
|
|
289
|
+
* @param feeRate Satoshis per byte.
|
|
290
|
+
* @param sourceUtxos UTXOs to construct the transaction from.
|
|
291
|
+
*/
|
|
292
|
+
declare function getTransferTxDetails<InputUtxo extends BitcoinInputUTXO | BitcoinInputUTXOWithOptionalScript = BitcoinInputUTXO>(to: string, changeAddress: string, amount: number, feeRate: number, sourceUtxos: InputUtxo[]): {
|
|
293
|
+
fee: number;
|
|
294
|
+
inputs?: InputUtxo[];
|
|
295
|
+
outputs?: BitcoinOutputUTXO[];
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
declare abstract class BitcoinWalletAbstract {
|
|
299
|
+
protected pubkey: Buffer;
|
|
300
|
+
protected provider: BitcoinProviderAbstract;
|
|
301
|
+
ecPair: ECPairInterface;
|
|
302
|
+
abstract signTx(ins: BitcoinInputUTXO[], outs: BitcoinOutputUTXO[]): Promise<Transaction$1>;
|
|
303
|
+
/**
|
|
304
|
+
* Return legacy P2PKH address.
|
|
305
|
+
*/
|
|
306
|
+
getAddressP2PKH(): string | undefined;
|
|
307
|
+
/**
|
|
308
|
+
* Get the Bech32 address.
|
|
309
|
+
* @link https://allprivatekeys.com/bitcoin-address-format
|
|
310
|
+
*/
|
|
311
|
+
getAddressBech32(): string;
|
|
312
|
+
protected constructor(pubkey: Buffer, provider: BitcoinProviderAbstract);
|
|
313
|
+
/**
|
|
314
|
+
* Returns the UTXOs owned by this address
|
|
315
|
+
*/
|
|
316
|
+
getUTXOs(): Promise<{
|
|
317
|
+
confirmed: BitcoinInputUTXOWithOptionalScript[];
|
|
318
|
+
unconfirmed: BitcoinInputUTXOWithOptionalScript[];
|
|
319
|
+
}>;
|
|
320
|
+
/**
|
|
321
|
+
* Returns the available balance in satoshis.
|
|
322
|
+
* @remarks Returned balances might not match the sum of available UTXOs if the wallet has pending transactions.
|
|
323
|
+
* Use `getUTXOBalance` to get the balance from available UTXOs.
|
|
324
|
+
*/
|
|
325
|
+
getBalances(): Promise<{
|
|
326
|
+
available: bigint;
|
|
327
|
+
pending: bigint;
|
|
328
|
+
final: bigint;
|
|
329
|
+
}>;
|
|
330
|
+
/**
|
|
331
|
+
* Returns available UTXOs and their total balance.
|
|
332
|
+
*/
|
|
333
|
+
getUtxoBalance(): Promise<{
|
|
334
|
+
balance: number;
|
|
335
|
+
balanceUnconfirmed: number;
|
|
336
|
+
utxos: BitcoinInputUTXOWithOptionalScript[];
|
|
337
|
+
utxosUnconfirmed: BitcoinInputUTXOWithOptionalScript[];
|
|
338
|
+
}>;
|
|
339
|
+
/**
|
|
340
|
+
* Connects the wallet to the given provider.
|
|
341
|
+
* @param provider
|
|
342
|
+
*/
|
|
343
|
+
connect(provider: BitcoinProviderAbstract): void;
|
|
344
|
+
/**
|
|
345
|
+
* Returns the current connected provider.
|
|
346
|
+
*/
|
|
347
|
+
getProvider(): BitcoinProviderAbstract;
|
|
348
|
+
getPublicKey(): Buffer;
|
|
349
|
+
/**
|
|
350
|
+
* Create an unsigned transaction. Change will be returned to this wallet.
|
|
351
|
+
* @param to
|
|
352
|
+
* @param amount
|
|
353
|
+
* @param feeRate
|
|
354
|
+
* @param sourceUTXOs
|
|
355
|
+
*/
|
|
356
|
+
createTransferTx(to: string, amount: number, feeRate: number, sourceUTXOs: BitcoinInputUTXO[]): {
|
|
357
|
+
fee: number;
|
|
358
|
+
inputs?: BitcoinInputUTXO[] | undefined;
|
|
359
|
+
outputs?: BitcoinOutputUTXO[] | undefined;
|
|
360
|
+
psbt?: bitcoinjs_lib.Psbt | undefined;
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Returns hw-app-eth for the given transport
|
|
366
|
+
* @param transport
|
|
367
|
+
*/
|
|
368
|
+
declare function getAppEth(transport: Transport): Eth;
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Returns a readonly, void signer class from ethers.
|
|
372
|
+
* @param address
|
|
373
|
+
* @param provider
|
|
374
|
+
*/
|
|
375
|
+
declare function getVoidSigner(address: string, provider?: Provider): VoidSigner;
|
|
376
|
+
|
|
377
|
+
declare const ETH_COIN_PATH = "m/44'/60'";
|
|
378
|
+
declare const ETH_ACCOUNT_PATH: string;
|
|
379
|
+
declare enum DerivationPath {
|
|
380
|
+
BIP44 = "bip44",
|
|
381
|
+
LedgerLive = "ledger_live"
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Returns a wallet instance given a mnemonic and the account index.
|
|
386
|
+
* @remarks Uses the fixed
|
|
387
|
+
* @param mnemonic
|
|
388
|
+
* @param accountIndex
|
|
389
|
+
* @param pathSpec Either BIP44 or Ledger Live
|
|
390
|
+
*/
|
|
391
|
+
declare function getWalletFromMnemonic(mnemonic: string, accountIndex: number, pathSpec: DerivationPath): HDNodeWallet;
|
|
392
|
+
|
|
393
|
+
declare const onBalanceChange: (walletAddresses: string[], erc20Addresses: string[], provider: Provider, callback: (txn: TransactionResponse, eventData: {
|
|
394
|
+
type: 'native' | 'erc20';
|
|
395
|
+
contractAddress?: string;
|
|
396
|
+
}) => void) => Promise<{
|
|
397
|
+
unsubscribe: () => Promise<Provider>;
|
|
398
|
+
}>;
|
|
399
|
+
declare const isNativeTxn: (txn: TransactionResponse, walletAddressSet: Set<string>) => boolean;
|
|
400
|
+
declare const isERC20Transfer: (txn: TransactionResponse, walletAddressSet: Set<string>) => boolean;
|
|
401
|
+
|
|
402
|
+
type PendingBatch = null | Array<{
|
|
403
|
+
request: {
|
|
404
|
+
method: string;
|
|
405
|
+
params: Array<any>;
|
|
406
|
+
id: number;
|
|
407
|
+
jsonrpc: '2.0';
|
|
408
|
+
};
|
|
409
|
+
resolve: (result: any) => void;
|
|
410
|
+
reject: (error: Error) => void;
|
|
411
|
+
}>;
|
|
412
|
+
declare class JsonRpcBatchInternal extends JsonRpcProvider$1 {
|
|
413
|
+
#private;
|
|
414
|
+
private url?;
|
|
415
|
+
constructor(config: {
|
|
416
|
+
maxCalls: number;
|
|
417
|
+
multiContractAddress?: string;
|
|
418
|
+
} | number, urlOrFetchRequest?: string | FetchRequest, network?: Network$1);
|
|
419
|
+
_pendingBatchAggregator: NodeJS.Timer | null;
|
|
420
|
+
_pendingBatch: PendingBatch;
|
|
421
|
+
_maxCalls: number;
|
|
422
|
+
_parentProvider?: JsonRpcProvider$1;
|
|
423
|
+
_multicallContract?: Contract;
|
|
424
|
+
send(method: string, params: Array<any>): Promise<any>;
|
|
425
|
+
flush: () => void;
|
|
426
|
+
batchSend: (batch: PendingBatch) => Promise<any>;
|
|
427
|
+
batchSendMultiCall: (batch: PendingBatch) => Promise<any>;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Returns the public key for an address given the account extended pubic key.
|
|
432
|
+
* @param xpriv Extended private key for m/44'/60'/0'
|
|
433
|
+
* @param accountIndex Index of the address
|
|
434
|
+
* @returns Public key for m/44'/60'/0'/0/n where `n` is the address index
|
|
435
|
+
*/
|
|
436
|
+
declare function getAddressPrivateKeyFromXPriv(xpriv: string, accountIndex: number): Buffer;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Returns the public key for an address given the account extended pubic key.
|
|
440
|
+
* @param xpub Extended public key for m/44'/60'/0'
|
|
441
|
+
* @param accountIndex Index of the address
|
|
442
|
+
* @returns Public key for m/44'/60'/0'/0/n where `n` is the address index
|
|
443
|
+
*/
|
|
444
|
+
declare function getAddressPublicKeyFromXPub(xpub: string, accountIndex: number): Buffer;
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Returns the address given a XPUB and account index.
|
|
448
|
+
* @returns Address of path `m/44'/60'/0'/0/n` where n is the index
|
|
449
|
+
* @param xpub XPUB for m/44'/60'/0'
|
|
450
|
+
* @param index Account index to get the address of.
|
|
451
|
+
*/
|
|
452
|
+
declare function getAddressFromXPub(xpub: string, index: number): string;
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Returns the extended public key of `m/44'/60'/0'`
|
|
456
|
+
* @param mnemonic
|
|
457
|
+
*/
|
|
458
|
+
declare function getXpubFromMnemonic$1(mnemonic: string): Promise<string>;
|
|
459
|
+
|
|
460
|
+
declare function getEvmAddressFromPubKey(pubKey: Buffer): string;
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Given a public key, return the Bech32 bitcoin address.
|
|
464
|
+
* @param pubKey
|
|
465
|
+
* @param network BTC network to use for the address
|
|
466
|
+
*/
|
|
467
|
+
declare function getBtcAddressFromPubKey(pubKey: Buffer, network: Network): string;
|
|
468
|
+
|
|
469
|
+
declare class LedgerSigner$1 extends AbstractSigner {
|
|
470
|
+
readonly type: string;
|
|
471
|
+
readonly path: string;
|
|
472
|
+
readonly provider: Provider | null;
|
|
473
|
+
readonly accountIndex: number;
|
|
474
|
+
readonly derivationSpec: DerivationPath;
|
|
475
|
+
transport: Transport;
|
|
476
|
+
_eth: Eth;
|
|
477
|
+
constructor(accountIndex: number | undefined, transport: Transport, derivationSpec: DerivationPath, provider?: Provider);
|
|
478
|
+
setTransport(t: Transport): void;
|
|
479
|
+
getAddress(): Promise<string>;
|
|
480
|
+
signMessage(message: BytesLike | string): Promise<string>;
|
|
481
|
+
signTransaction(transaction: TransactionRequest): Promise<string>;
|
|
482
|
+
connect(provider: Provider): LedgerSigner$1;
|
|
483
|
+
signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>): Promise<string>;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* A wallet instance for the given private key. Can sign transactions.
|
|
488
|
+
*/
|
|
489
|
+
declare class BitcoinWallet extends BitcoinWalletAbstract {
|
|
490
|
+
keypair: ECPairInterface;
|
|
491
|
+
constructor(privKey: Buffer, provider: BitcoinProviderAbstract);
|
|
492
|
+
/**
|
|
493
|
+
*
|
|
494
|
+
* @param mnemonic The mnemonic phrase to derive the wallet from.
|
|
495
|
+
* @param accountIndex Used when deriving the private key from mnemonic. The path used is `m/44'/60'/0'/0/n` where `n` is the account index.
|
|
496
|
+
* @param provider
|
|
497
|
+
* @param derivationSpec Sets how account paths are generated. BIP44 (Default) or LedgerLive.
|
|
498
|
+
*/
|
|
499
|
+
static fromMnemonic(mnemonic: string, accountIndex: number, provider: BitcoinProviderAbstract, derivationSpec?: DerivationPath): Promise<BitcoinWallet>;
|
|
500
|
+
/**
|
|
501
|
+
* Create a transaction from the given inputs and outputs, and sign it.
|
|
502
|
+
* @remarks Signs all inputs.
|
|
503
|
+
* @param ins Array of input UTXOs to consume
|
|
504
|
+
* @param outs Array of output UTXOs to create.
|
|
505
|
+
*/
|
|
506
|
+
signTx(ins: BitcoinInputUTXO[], outs: BitcoinOutputUTXO[]): Promise<bitcoinjs_lib.Transaction>;
|
|
507
|
+
/**
|
|
508
|
+
* Create a bitcoin wallet using the private key of an Ethers wallet.
|
|
509
|
+
* @param wallet An Ethers wallet instance that has a private key.
|
|
510
|
+
* @param prov Bitcoin provider.
|
|
511
|
+
*/
|
|
512
|
+
static fromEthersWallet(wallet: HDNodeWallet, prov: BitcoinProviderAbstract): BitcoinWallet;
|
|
513
|
+
/**
|
|
514
|
+
* Sings a given PSBT and returns the transaction.
|
|
515
|
+
* @remarks Signs all inputs.
|
|
516
|
+
* @param tx
|
|
517
|
+
*/
|
|
518
|
+
signPsbt(tx: Psbt): bitcoinjs_lib.Transaction;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
interface WalletPolicyDetails {
|
|
522
|
+
policy: WalletPolicy;
|
|
523
|
+
hmac: Buffer;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
declare class BitcoinLedgerWallet extends BitcoinWalletAbstract {
|
|
527
|
+
private derivationPath;
|
|
528
|
+
protected transport: Transport;
|
|
529
|
+
private walletPolicyDetails;
|
|
530
|
+
/**
|
|
531
|
+
*
|
|
532
|
+
* @param publicKey Public key of the address
|
|
533
|
+
* @param derivationPath BIP44 derivation path of the publickey/address
|
|
534
|
+
* @param provider
|
|
535
|
+
* @param transport Ledger transport instance.
|
|
536
|
+
*/
|
|
537
|
+
constructor(publicKey: Buffer, derivationPath: string, provider: BitcoinProviderAbstract, transport: Transport, walletPolicyDetails: WalletPolicyDetails);
|
|
538
|
+
/**
|
|
539
|
+
* Update the ledger transport used by this wallet.
|
|
540
|
+
* @param t
|
|
541
|
+
*/
|
|
542
|
+
setTransport(t: Transport): void;
|
|
543
|
+
/**
|
|
544
|
+
* Creates a transaction with the given inputs & outputs and signs using the ledger.
|
|
545
|
+
* @param ins Input UTXOs for this transaction. Must be P2WPKH.
|
|
546
|
+
* @param outs Output UTXOs for this transaction.
|
|
547
|
+
* @param ledgerConfig
|
|
548
|
+
*/
|
|
549
|
+
signTx(ins: BitcoinInputUTXO[], outs: BitcoinOutputUTXO[]): Promise<bitcoinjs_lib.Transaction>;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* A wallet class for readonly wallet instances.
|
|
554
|
+
*/
|
|
555
|
+
declare class BitcoinWalletVoid extends BitcoinWalletAbstract {
|
|
556
|
+
constructor(publicKey: Buffer, provider: BitcoinProviderAbstract);
|
|
557
|
+
signTx(tx: any): any;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
type ChainIDAlias = 'X' | 'P' | 'C';
|
|
561
|
+
/**
|
|
562
|
+
* Types for parsed transaction
|
|
563
|
+
*/
|
|
564
|
+
type Tx = AddValidatorTx | AddDelegatorTx | ExportTx | ImportTx | BaseTx | CreateSubnetTx | CreateChainTx | AddSubnetValidatorTx | RemoveSubnetValidatorTx | AddPermissionlessValidatorTx | AddPermissionlessDelegatorTx | TransformSubnetTx | TransferSubnetOwnershipTx | UnknownTx;
|
|
565
|
+
interface FeeData {
|
|
566
|
+
totalAvaxBurned: bigint;
|
|
567
|
+
totalAvaxOutput: bigint;
|
|
568
|
+
totalAvaxInput: bigint;
|
|
569
|
+
isValidAvaxBurnedAmount: boolean;
|
|
570
|
+
txFee: bigint;
|
|
571
|
+
}
|
|
572
|
+
interface TxBase extends FeeData {
|
|
573
|
+
type: string;
|
|
574
|
+
chain: VM;
|
|
575
|
+
}
|
|
576
|
+
declare enum TxType {
|
|
577
|
+
Base = "base",
|
|
578
|
+
AddValidator = "add_validator",
|
|
579
|
+
AddDelegator = "add_delegator",
|
|
580
|
+
Export = "export",
|
|
581
|
+
Import = "import",
|
|
582
|
+
CreateSubnet = "create_subnet",
|
|
583
|
+
CreateChain = "create_chain",
|
|
584
|
+
AddSubnetValidator = "add_subnet_validator",
|
|
585
|
+
RemoveSubnetValidator = "remove_subnet_validator",
|
|
586
|
+
AddPermissionlessValidator = "add_permissionless_validator",
|
|
587
|
+
AddPermissionlessDelegator = "add_permissionless_delegator",
|
|
588
|
+
TransformSubnet = "transform_subnet",
|
|
589
|
+
TransferSubnetOwnership = "transfer_subnet_ownership",
|
|
590
|
+
Unknown = "unknown"
|
|
591
|
+
}
|
|
592
|
+
interface BaseTx extends TxBase {
|
|
593
|
+
type: TxType.Base;
|
|
594
|
+
chain: VM;
|
|
595
|
+
outputs: {
|
|
596
|
+
assetId: string;
|
|
597
|
+
locktime: bigint;
|
|
598
|
+
threshold: bigint;
|
|
599
|
+
amount: bigint;
|
|
600
|
+
assetDescription?: Common.GetAssetDescriptionResponse;
|
|
601
|
+
owners: string[];
|
|
602
|
+
isAvax: boolean;
|
|
603
|
+
}[];
|
|
604
|
+
memo?: string;
|
|
605
|
+
}
|
|
606
|
+
interface AddValidatorTx extends TxBase {
|
|
607
|
+
type: TxType.AddValidator;
|
|
608
|
+
nodeID: string;
|
|
609
|
+
delegationFee: number;
|
|
610
|
+
start: string;
|
|
611
|
+
end: string;
|
|
612
|
+
rewardOwner: OutputOwners;
|
|
613
|
+
stake: bigint;
|
|
614
|
+
stakeOuts: TransferableOutput[];
|
|
615
|
+
}
|
|
616
|
+
interface AddDelegatorTx extends TxBase {
|
|
617
|
+
type: TxType.AddDelegator;
|
|
618
|
+
nodeID: string;
|
|
619
|
+
start: string;
|
|
620
|
+
end: string;
|
|
621
|
+
rewardOwner: OutputOwners;
|
|
622
|
+
stake: bigint;
|
|
623
|
+
stakeOuts: TransferableOutput[];
|
|
624
|
+
}
|
|
625
|
+
interface ExportTx extends TxBase {
|
|
626
|
+
type: TxType.Export;
|
|
627
|
+
destination: VM;
|
|
628
|
+
amount: bigint;
|
|
629
|
+
}
|
|
630
|
+
interface ImportTx extends TxBase {
|
|
631
|
+
type: TxType.Import;
|
|
632
|
+
source: VM;
|
|
633
|
+
amount: bigint;
|
|
634
|
+
}
|
|
635
|
+
interface CreateSubnetTx extends TxBase {
|
|
636
|
+
type: TxType.CreateSubnet;
|
|
637
|
+
threshold: number;
|
|
638
|
+
controlKeys: string[];
|
|
639
|
+
}
|
|
640
|
+
interface CreateChainTx extends TxBase {
|
|
641
|
+
type: TxType.CreateChain;
|
|
642
|
+
subnetID: string;
|
|
643
|
+
chainName: string;
|
|
644
|
+
chainID: string;
|
|
645
|
+
vmID: string;
|
|
646
|
+
fxIDs: string[];
|
|
647
|
+
genesisData: string;
|
|
648
|
+
}
|
|
649
|
+
interface AddSubnetValidatorTx extends TxBase {
|
|
650
|
+
type: TxType.AddSubnetValidator;
|
|
651
|
+
nodeID: string;
|
|
652
|
+
start: string;
|
|
653
|
+
end: string;
|
|
654
|
+
subnetID: string;
|
|
655
|
+
stake: bigint;
|
|
656
|
+
}
|
|
657
|
+
interface RemoveSubnetValidatorTx extends TxBase {
|
|
658
|
+
type: TxType.RemoveSubnetValidator;
|
|
659
|
+
nodeID: string;
|
|
660
|
+
subnetID: string;
|
|
661
|
+
}
|
|
662
|
+
interface AddPermissionlessValidatorTx extends TxBase {
|
|
663
|
+
type: TxType.AddPermissionlessValidator;
|
|
664
|
+
nodeID: string;
|
|
665
|
+
delegationFee: number;
|
|
666
|
+
start: string;
|
|
667
|
+
end: string;
|
|
668
|
+
rewardOwner: OutputOwners;
|
|
669
|
+
delegationRewardOwner: OutputOwners;
|
|
670
|
+
stake: bigint;
|
|
671
|
+
stakeOuts: TransferableOutput[];
|
|
672
|
+
subnetID: string;
|
|
673
|
+
publicKey: undefined | string;
|
|
674
|
+
signature: undefined | string;
|
|
675
|
+
signer: pvmSerial.Signer | pvmSerial.SignerEmpty;
|
|
676
|
+
}
|
|
677
|
+
interface AddPermissionlessDelegatorTx extends TxBase {
|
|
678
|
+
type: TxType.AddPermissionlessDelegator;
|
|
679
|
+
nodeID: string;
|
|
680
|
+
start: string;
|
|
681
|
+
end: string;
|
|
682
|
+
stake: bigint;
|
|
683
|
+
subnetID: string;
|
|
684
|
+
delegatorRewardsOwner: OutputOwners;
|
|
685
|
+
stakeOuts: TransferableOutput[];
|
|
686
|
+
}
|
|
687
|
+
interface TransformSubnetTx extends TxBase {
|
|
688
|
+
type: TxType.TransformSubnet;
|
|
689
|
+
subnetID: string;
|
|
690
|
+
assetID: string;
|
|
691
|
+
initialSupply: bigint;
|
|
692
|
+
maximumSupply: bigint;
|
|
693
|
+
minConsumptionRate: bigint;
|
|
694
|
+
maxConsumptionRate: bigint;
|
|
695
|
+
minValidatorStake: bigint;
|
|
696
|
+
maxValidatorStake: bigint;
|
|
697
|
+
minStakeDuration: number;
|
|
698
|
+
maxStakeDuration: number;
|
|
699
|
+
minDelegationFee: number;
|
|
700
|
+
minDelegatorStake: number;
|
|
701
|
+
maxValidatorWeightFactor: number;
|
|
702
|
+
uptimeRequirement: number;
|
|
703
|
+
}
|
|
704
|
+
interface TransferSubnetOwnershipTx extends TxBase {
|
|
705
|
+
type: TxType.TransferSubnetOwnership;
|
|
706
|
+
subnetID: string;
|
|
707
|
+
threshold: number;
|
|
708
|
+
controlKeys: string[];
|
|
709
|
+
}
|
|
710
|
+
interface UnknownTx extends TxBase {
|
|
711
|
+
type: TxType.Unknown;
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Type Guards
|
|
715
|
+
*/
|
|
716
|
+
declare function isAddValidatorTx(tx: Tx): tx is AddValidatorTx;
|
|
717
|
+
declare function isAddDelegatorTx(tx: Tx): tx is AddDelegatorTx;
|
|
718
|
+
declare function isExportTx(tx: Tx): tx is ExportTx;
|
|
719
|
+
declare function isImportTx(tx: Tx): tx is ImportTx;
|
|
720
|
+
declare function isBaseTx(tx: Tx): tx is BaseTx;
|
|
721
|
+
declare function isCreateSubnetTx(tx: Tx): tx is CreateSubnetTx;
|
|
722
|
+
declare function isCreateChainTx(tx: Tx): tx is CreateChainTx;
|
|
723
|
+
declare function isAddSubnetValidatorTx(tx: Tx): tx is AddSubnetValidatorTx;
|
|
724
|
+
declare function isRemoveSubnetValidatorTx(tx: Tx): tx is RemoveSubnetValidatorTx;
|
|
725
|
+
declare function isAddPermissionlessValidatorTx(tx: Tx): tx is AddPermissionlessValidatorTx;
|
|
726
|
+
declare function isAddPermissionlessDelegatorTx(tx: Tx): tx is AddPermissionlessDelegatorTx;
|
|
727
|
+
declare function isTransformSubnetTx(tx: Tx): tx is TransformSubnetTx;
|
|
728
|
+
declare function isTransferSubnetOwnershipTx(tx: Tx): tx is TransferSubnetOwnershipTx;
|
|
729
|
+
|
|
730
|
+
declare class AbstractProvider {
|
|
731
|
+
protected baseUrl: string;
|
|
732
|
+
protected context: Context.Context;
|
|
733
|
+
evmRpc: JsonRpcProvider$1;
|
|
734
|
+
constructor(baseUrl: string, context: Context.Context);
|
|
735
|
+
/**
|
|
736
|
+
* @link https://docs.ethers.io/v5/api/providers/provider/#Provider-getFeeData
|
|
737
|
+
*/
|
|
738
|
+
getEvmFeeData(): Promise<ethers.FeeData>;
|
|
739
|
+
getContext(): Context.Context;
|
|
740
|
+
getChainID(chainAlias: ChainIDAlias): string;
|
|
741
|
+
getNetworkID(): number;
|
|
742
|
+
getHrp(): string;
|
|
743
|
+
getApiX(): avm.AVMApi;
|
|
744
|
+
getApiP(): pvm.PVMApi;
|
|
745
|
+
getApiC(): evm.EVMApi;
|
|
746
|
+
getApi(chain: ChainIDAlias): avm.AVMApi | pvm.PVMApi | evm.EVMApi;
|
|
747
|
+
getAvaxID(): string;
|
|
748
|
+
getAddress(publicKey: Buffer, chain: ChainIDAlias): string;
|
|
749
|
+
getAddressFromBuffer(address: Buffer, chain: ChainIDAlias): string;
|
|
750
|
+
/**
|
|
751
|
+
* Format an existing address to match the current network and given chain alias
|
|
752
|
+
* @param address an Avalanche bech32 address without chain prefix
|
|
753
|
+
* @param chain Target chain
|
|
754
|
+
*/
|
|
755
|
+
formatAddress(address: string, chain: ChainIDAlias): string;
|
|
756
|
+
getApiByVM(vm: VM): avm.AVMApi | pvm.PVMApi | evm.EVMApi;
|
|
757
|
+
getApiByChainID(chainID: string): avm.AVMApi | pvm.PVMApi | evm.EVMApi | undefined;
|
|
758
|
+
issueTx(tx: avaxSerial.SignedTx): Promise<_avalabs_avalanchejs_dist_vms_common.IssueTxResponse>;
|
|
759
|
+
issueTxHex(txHex: string, vm: VM): Promise<_avalabs_avalanchejs_dist_vms_common.IssueTxResponse>;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
declare class JsonRpcProvider extends AbstractProvider {
|
|
763
|
+
constructor(baseUrl: string, context: Context.Context);
|
|
764
|
+
static fromBaseURL(url: string): Promise<JsonRpcProvider>;
|
|
765
|
+
static getDefaultMainnetProvider(): JsonRpcProvider;
|
|
766
|
+
static getDefaultFujiProvider(): JsonRpcProvider;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* Avalanche Mainnet context
|
|
771
|
+
*/
|
|
772
|
+
declare const MainnetContext: Context.Context;
|
|
773
|
+
/**
|
|
774
|
+
* Avalanche Fuji testnet context
|
|
775
|
+
*/
|
|
776
|
+
declare const FujiContext: Context.Context;
|
|
777
|
+
|
|
778
|
+
/**
|
|
779
|
+
* An abstract class that that is shared by all wallet classes.
|
|
780
|
+
*/
|
|
781
|
+
declare abstract class WalletAbstract {
|
|
782
|
+
protected provider: AbstractProvider;
|
|
783
|
+
/**
|
|
784
|
+
* Returns all addresses used by this wallet for the given chain.
|
|
785
|
+
* @param chain
|
|
786
|
+
*/
|
|
787
|
+
abstract getAddresses(chain: ChainIDAlias): string[];
|
|
788
|
+
/**
|
|
789
|
+
* Returns the C chain EVM address (hex).
|
|
790
|
+
*/
|
|
791
|
+
abstract getAddressEVM(): string;
|
|
792
|
+
/**
|
|
793
|
+
* Get the address used by this wallet to receive funds.
|
|
794
|
+
* @param chain
|
|
795
|
+
*/
|
|
796
|
+
abstract getCurrentAddress(chain: ChainIDAlias): string;
|
|
797
|
+
/**
|
|
798
|
+
* Get the address that will receive the "change" after transactions
|
|
799
|
+
* @param chain
|
|
800
|
+
*/
|
|
801
|
+
abstract getChangeAddress(chain: ChainIDAlias): string;
|
|
802
|
+
/**
|
|
803
|
+
* Set the provider used by this wallet.
|
|
804
|
+
* @param provider
|
|
805
|
+
*/
|
|
806
|
+
setProvider(provider: AbstractProvider): void;
|
|
807
|
+
/**
|
|
808
|
+
* Get the provider used by this wallet.
|
|
809
|
+
*/
|
|
810
|
+
getProvider(): AbstractProvider;
|
|
811
|
+
/**
|
|
812
|
+
* Get UTXOs owned by the wallet's addresses for the given chain
|
|
813
|
+
* @param chain
|
|
814
|
+
*/
|
|
815
|
+
getUTXOs(chain: 'X' | 'P'): Promise<utils.UtxoSet>;
|
|
816
|
+
getStake(): Promise<pvm.GetStakeResponse>;
|
|
817
|
+
/**
|
|
818
|
+
* Get atomic UTXOs for the given chain
|
|
819
|
+
* @param chain Which chain are the atomic UTXOs are on
|
|
820
|
+
* @param source What is the source chain of the atomic UTXOs
|
|
821
|
+
*/
|
|
822
|
+
getAtomicUTXOs(chain: ChainIDAlias, source: ChainIDAlias): Promise<utils.UtxoSet>;
|
|
823
|
+
exportX(amount: bigint, utxoSet: utils.UtxoSet, destination: 'P' | 'C', toAddress?: string): Common.UnsignedTx;
|
|
824
|
+
importP(utxos: utils.UtxoSet, sourceChain: 'X' | 'C', toAddress?: string): Common.UnsignedTx;
|
|
825
|
+
importX(utxos: utils.UtxoSet, sourceChain: 'P' | 'C', toAddress?: string): Common.UnsignedTx;
|
|
826
|
+
/**
|
|
827
|
+
*
|
|
828
|
+
* @param utxos
|
|
829
|
+
* @param sourceChain
|
|
830
|
+
* @param baseFee in nAvax (EVM base fee)
|
|
831
|
+
* @param feeAssetId
|
|
832
|
+
* @param toAddress Must be hex EVM address.
|
|
833
|
+
*/
|
|
834
|
+
importC(utxos: utils.UtxoSet, sourceChain: 'P' | 'X', baseFee: bigint, feeAssetId?: string, toAddress?: string): Common.UnsignedTx;
|
|
835
|
+
/**
|
|
836
|
+
*
|
|
837
|
+
* @param amount
|
|
838
|
+
* @param destination
|
|
839
|
+
* @param nonce
|
|
840
|
+
* @param baseFee Given in WEI
|
|
841
|
+
* @param toAddress
|
|
842
|
+
*/
|
|
843
|
+
exportC(amount: bigint, destination: 'X' | 'P', nonce: bigint, baseFee: bigint, toAddress?: string): _avalabs_avalanchejs.EVMUnsignedTx;
|
|
844
|
+
/**
|
|
845
|
+
* Get the nonce of this wallet's C chain address
|
|
846
|
+
*/
|
|
847
|
+
getNonce(): Promise<number>;
|
|
848
|
+
/**
|
|
849
|
+
* Export the given amount of AVAX from the P chain. Export fee is automatically added.
|
|
850
|
+
* @param amount
|
|
851
|
+
* @param utxoSet
|
|
852
|
+
* @param destination
|
|
853
|
+
* @param toAddress
|
|
854
|
+
*/
|
|
855
|
+
exportP(amount: bigint, utxoSet: utils.UtxoSet, destination: 'X' | 'C', toAddress?: string): Common.UnsignedTx;
|
|
856
|
+
addValidator(utxos: utils.UtxoSet, nodeID: string, stakeAmount: bigint, startDate: bigint, endDate: bigint, delegationFee: number, config?: {
|
|
857
|
+
rewardAddress?: string;
|
|
858
|
+
}): Common.UnsignedTx;
|
|
859
|
+
addDelegator(utxos: utils.UtxoSet, nodeID: string, stakeAmount: bigint, startDate: bigint, endDate: bigint, config?: {
|
|
860
|
+
rewardAddress?: string;
|
|
861
|
+
}): Common.UnsignedTx;
|
|
862
|
+
consolidateP(utxoSet: utils.UtxoSet, amount: bigint, toAddress?: string, options?: Common.SpendOptions): Common.UnsignedTx;
|
|
863
|
+
baseTX(utxoSet: utils.UtxoSet, chain: 'X' | 'P', toAddress: string, amountsPerAsset: Record<string, bigint>, options?: Common.SpendOptions, fromAddresses?: string[]): Common.UnsignedTx;
|
|
864
|
+
createBlockchain(utxoSet: utils.UtxoSet, subnetId: string, chainName: string, vmID: string, fxIds: string[], genesisData: Record<string, unknown>, subnetAuth: number[], options?: Common.SpendOptions, fromAddresses?: string[]): Common.UnsignedTx;
|
|
865
|
+
createSubnet(utxoSet: utils.UtxoSet, rewardAddresses: string[], fromAddresses?: string[], options?: Common.SpendOptions, threshold?: number, locktime?: bigint): Common.UnsignedTx;
|
|
866
|
+
addSubnetValidator(utxoSet: utils.UtxoSet, nodeId: string, start: bigint, end: bigint, weight: bigint, subnetId: string, subnetAuth: number[], fromAddresses?: string[], options?: Common.SpendOptions): Common.UnsignedTx;
|
|
867
|
+
/**
|
|
868
|
+
*
|
|
869
|
+
* @param utxoSet The transaction will be constructed from these UTXOs.
|
|
870
|
+
* @param nodeId The validating node id
|
|
871
|
+
* @param start Start date of the validation period in UNIX time
|
|
872
|
+
* @param end End date of the validation period in UNIX time
|
|
873
|
+
* @param weight Stake amount given in nAVAX
|
|
874
|
+
* @param subnetId The subnet id as a hexadecimal string
|
|
875
|
+
* @param shares The fee this validator charges delegators as a percentage, times 10,000. Ex. a value of 300,000 means they take 30% of rewards from delegators.
|
|
876
|
+
* @param fromAddresses Only utxos from these addresses will be used
|
|
877
|
+
* @param rewardAddresses Will use active address if not provided. Given addresses will share the reward UTXO.
|
|
878
|
+
* @param delegatorRewardAddresses Will use active address if not provided. Given addresses will share the delegator fee UTXO.
|
|
879
|
+
* @param publicKey the BLS public key, If the subnet is the primary network. Can be found in the Node on startup.
|
|
880
|
+
* @param signature the BLS signature, If the subnet is the primary network. Can be found in the Node on startup.
|
|
881
|
+
* @param options
|
|
882
|
+
*/
|
|
883
|
+
addPermissionlessValidator(utxoSet: utils.UtxoSet, nodeId: string, start: bigint, end: bigint, weight: bigint, subnetId: string, shares: number, fromAddresses?: string[], rewardAddresses?: string[], delegatorRewardAddresses?: string[], publicKey?: Buffer, signature?: Buffer, options?: Common.SpendOptions): Common.UnsignedTx;
|
|
884
|
+
/**
|
|
885
|
+
*
|
|
886
|
+
* @param utxoSet The transaction will be constructed from these UTXOs.
|
|
887
|
+
* @param nodeId The validating node id
|
|
888
|
+
* @param start Start date of the validation period in UNIX time
|
|
889
|
+
* @param end End date of the validation period in UNIX time
|
|
890
|
+
* @param weight Stake amount given in nAVAX
|
|
891
|
+
* @param subnetId The subnet id as a hexadecimal string
|
|
892
|
+
* @param fromAddresses Only utxos from these addresses will be used
|
|
893
|
+
* @param rewardAddresses Will use active address if not provided. Given addresses will share the reward UTXO.
|
|
894
|
+
* @param options
|
|
895
|
+
*/
|
|
896
|
+
addPermissionlessDelegator(utxoSet: utils.UtxoSet, nodeId: string, start: bigint, end: bigint, weight: bigint, subnetId: string, fromAddresses?: string[], rewardAddresses?: string[], options?: Common.SpendOptions): Common.UnsignedTx;
|
|
897
|
+
removeSubnetValidator(utxoSet: utils.UtxoSet, nodeId: string, subnetId: string, subnetAuth: number[], fromAddresses?: string[], options?: Common.SpendOptions): Common.UnsignedTx;
|
|
898
|
+
transferSubnetOwnershipTx(utxoSet: utils.UtxoSet, subnetId: string, subnetAuth: number[], subnetOwners: string[], fromAddresses?: string[], options?: Common.SpendOptions, threshold?: number, locktime?: bigint): Common.UnsignedTx;
|
|
899
|
+
transformSubnetTx(utxoSet: utils.UtxoSet, subnetId: string, assetId: string, initialSupply: bigint, maximumSupply: bigint, minConsumptionRate: bigint, maxConsumptionRate: bigint, minValidatorStake: bigint, maxValidatorStake: bigint, minStakeDuration: number, maxStakeDuration: number, minDelegationFee: number, minDelegatorStake: number, maxValidatorWeightFactor: number, uptimeRequirement: number, subnetAuth: number[], fromAddresses?: string[], options?: Common.SpendOptions): Common.UnsignedTx;
|
|
900
|
+
protected constructor(provider: AbstractProvider);
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* A wallet class that has the same static address for X/P/C chains.
|
|
905
|
+
*/
|
|
906
|
+
declare class WalletVoid extends WalletAbstract {
|
|
907
|
+
protected pubkeyXP: Buffer;
|
|
908
|
+
protected pubkeyC: Buffer;
|
|
909
|
+
/**
|
|
910
|
+
*
|
|
911
|
+
* @param pubkeyXP Public key of the X/P Chain address
|
|
912
|
+
* @param pubkeyC Public key of the C Chain address
|
|
913
|
+
* @param prov
|
|
914
|
+
*/
|
|
915
|
+
constructor(pubkeyXP: Buffer, pubkeyC: Buffer, prov: AbstractProvider);
|
|
916
|
+
/**
|
|
917
|
+
* Creates a readonly wallet with the given public keys.
|
|
918
|
+
* @param pubkeyXP
|
|
919
|
+
* @param pubkeyC
|
|
920
|
+
* @param prov
|
|
921
|
+
*/
|
|
922
|
+
static fromPublicKey(pubkeyXP: Buffer, pubkeyC: Buffer, prov: AbstractProvider): WalletVoid;
|
|
923
|
+
static fromMnemonic(mnemonic: string, pathXP: string, pathC: string, provider: AbstractProvider): WalletVoid;
|
|
924
|
+
/**
|
|
925
|
+
* Returns the address as a X, P, or C chain Bech32 address
|
|
926
|
+
* @param chainIdAlias X, P, or C
|
|
927
|
+
*/
|
|
928
|
+
getAddress(chainIdAlias: ChainIDAlias): string;
|
|
929
|
+
/**
|
|
930
|
+
* Return the EVM address (hex) used by the C chain.
|
|
931
|
+
*/
|
|
932
|
+
getAddressEVM(): string;
|
|
933
|
+
getAddresses(chain: ChainIDAlias): string[];
|
|
934
|
+
getChangeAddress(chain: ChainIDAlias): string;
|
|
935
|
+
getCurrentAddress(chain: ChainIDAlias): string;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
declare function isObsidianApp(t: Transport): Promise<boolean>;
|
|
939
|
+
|
|
940
|
+
interface LedgerProvider {
|
|
941
|
+
type: LedgerProviderType;
|
|
942
|
+
getApp(t: Transport): AppZondax;
|
|
943
|
+
getAddress(t: Transport, path: Bip32Path, config: {
|
|
944
|
+
show: boolean;
|
|
945
|
+
hrp: string;
|
|
946
|
+
}): Promise<{
|
|
947
|
+
publicKey: Buffer;
|
|
948
|
+
}>;
|
|
949
|
+
getXPUB(t: Transport, path: string): Promise<{
|
|
950
|
+
pubKey: Buffer;
|
|
951
|
+
chainCode: Buffer;
|
|
952
|
+
}>;
|
|
953
|
+
signHash(t: Transport, hash: Buffer, accountPath: Bip32Path, signers: Bip32Path[]): Promise<{
|
|
954
|
+
hash: Buffer;
|
|
955
|
+
signatures: Map<string, Buffer>;
|
|
956
|
+
}>;
|
|
957
|
+
/**
|
|
958
|
+
*
|
|
959
|
+
* @param t Ledger transport instance
|
|
960
|
+
* @param tx
|
|
961
|
+
* @param accountPath eg. m/44'/9000'/0'
|
|
962
|
+
* @param signers eg. [0/0, 1/0]
|
|
963
|
+
* @param changePaths eg. [0/0, 1/0]
|
|
964
|
+
*/
|
|
965
|
+
signTx(t: Transport, tx: Buffer, accountPath: Bip32Path, signers: Bip32Path[], changePaths?: Bip32Path[]): Promise<{
|
|
966
|
+
signatures: Map<string, Buffer>;
|
|
967
|
+
} & Partial<ResponseBase>>;
|
|
968
|
+
getVersion(t: Transport): Promise<string>;
|
|
969
|
+
}
|
|
970
|
+
type LedgerProviderType = 'obsidian' | 'zondax';
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
* Get the correct ledger provider given a transport instance.
|
|
974
|
+
* @param t
|
|
975
|
+
*/
|
|
976
|
+
declare function getLedgerProvider(t: Transport): Promise<LedgerProvider>;
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* A keyless wallet that cannot sign transactions.
|
|
980
|
+
* It is used to fetch UTXOs and construct transactions for a list of addresses.
|
|
981
|
+
*/
|
|
982
|
+
declare class AddressWallet extends WalletAbstract {
|
|
983
|
+
protected addressC: string;
|
|
984
|
+
protected addressCoreEth: string;
|
|
985
|
+
protected xpAddresses: string[];
|
|
986
|
+
protected xpChangeAddress: string;
|
|
987
|
+
/**
|
|
988
|
+
*
|
|
989
|
+
* @param addressC the EVM address (hex) used by the C chain.
|
|
990
|
+
* @param addressCoreEth the CoreEth address used by the C chain.
|
|
991
|
+
* @param xpAddresses a list of XP addresses. The first in the list is the primary address.
|
|
992
|
+
* @param xpChangeAddress change address to use for X/P chain transactions
|
|
993
|
+
* @param prov
|
|
994
|
+
*/
|
|
995
|
+
constructor(addressC: string, addressCoreEth: string, xpAddresses: string[], xpChangeAddress: string, prov: AbstractProvider);
|
|
996
|
+
/**
|
|
997
|
+
* Set the change address to use with X/P chain transactions
|
|
998
|
+
* @param address
|
|
999
|
+
*/
|
|
1000
|
+
setChangeAddress(address: string): void;
|
|
1001
|
+
/**
|
|
1002
|
+
* Return the EVM address (hex) used by the C chain.
|
|
1003
|
+
*/
|
|
1004
|
+
getAddressEVM(): string;
|
|
1005
|
+
/**
|
|
1006
|
+
* Return the addresses used by this wallet for the given chain alias.
|
|
1007
|
+
* @param chain X/P/C chain alias
|
|
1008
|
+
*/
|
|
1009
|
+
getAddresses(chain: ChainIDAlias): string[];
|
|
1010
|
+
getChangeAddress(chain: ChainIDAlias): string;
|
|
1011
|
+
/**
|
|
1012
|
+
* For X and P, returns the 1st address in the XP Addresses array. For C, returns the CoreEth address.
|
|
1013
|
+
* @param chain Which chain to get the address for
|
|
1014
|
+
*/
|
|
1015
|
+
getCurrentAddress(chain: ChainIDAlias): string;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
interface PubKeyCache {
|
|
1019
|
+
[path: string]: Buffer;
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* This wallet class uses dynamic address for X/P chains and static for C chain. It replicates the wallet logic used in the Web Wallet.
|
|
1023
|
+
*/
|
|
1024
|
+
declare class MnemonicWalletVoid extends WalletAbstract {
|
|
1025
|
+
protected readonly avmXpub: string;
|
|
1026
|
+
/**
|
|
1027
|
+
* Node for m/44'/9000'/0'
|
|
1028
|
+
* @private
|
|
1029
|
+
*/
|
|
1030
|
+
protected accountNode: BIP32Interface;
|
|
1031
|
+
/**
|
|
1032
|
+
* EVM Wallet instance of m/44'/60'/0'/0/0
|
|
1033
|
+
* @private
|
|
1034
|
+
*/
|
|
1035
|
+
private evmWallet;
|
|
1036
|
+
/**
|
|
1037
|
+
* Index of the current external address
|
|
1038
|
+
*/
|
|
1039
|
+
protected externalIndex: number;
|
|
1040
|
+
/**
|
|
1041
|
+
* Index of the current internal (change) address
|
|
1042
|
+
*/
|
|
1043
|
+
protected internalIndex: number;
|
|
1044
|
+
/**
|
|
1045
|
+
* Derived pubkeys will be stored here.
|
|
1046
|
+
* @protected
|
|
1047
|
+
*/
|
|
1048
|
+
protected pubkeyCache: PubKeyCache;
|
|
1049
|
+
/**
|
|
1050
|
+
*
|
|
1051
|
+
* @param avmXpub XPUB of m/44'/9000'/0'
|
|
1052
|
+
* @param evmPubKey Public Key of m/44'/60'/0'/0/0
|
|
1053
|
+
* @param provider
|
|
1054
|
+
*/
|
|
1055
|
+
constructor(avmXpub: string, evmPubKey: Buffer, provider: AbstractProvider);
|
|
1056
|
+
static fromMnemonic(mnemonic: string, provider: AbstractProvider): MnemonicWalletVoid;
|
|
1057
|
+
/**
|
|
1058
|
+
* Set the current external index of this wallet.
|
|
1059
|
+
* @param index
|
|
1060
|
+
*/
|
|
1061
|
+
setExternalIndex(index: number): void;
|
|
1062
|
+
/**
|
|
1063
|
+
* Set the current internal index of this wallet.
|
|
1064
|
+
* @param index
|
|
1065
|
+
*/
|
|
1066
|
+
setInternalIndex(index: number): void;
|
|
1067
|
+
/**
|
|
1068
|
+
* Returns the public key for the given index. Used for X/P addresses. Results are cached.
|
|
1069
|
+
* @param index
|
|
1070
|
+
* @param isChange
|
|
1071
|
+
* @private
|
|
1072
|
+
*/
|
|
1073
|
+
private getPubKeyAtIndex;
|
|
1074
|
+
getAddressAtIndex(index: number, isChange: boolean | undefined, chain: 'X' | 'P'): string;
|
|
1075
|
+
getExternalAddresses(chain: 'X' | 'P'): string[];
|
|
1076
|
+
getInternalAddresses(chain: 'X'): string[];
|
|
1077
|
+
getAddresses(chain: ChainIDAlias): string[];
|
|
1078
|
+
getChangeAddress(chain: ChainIDAlias): string;
|
|
1079
|
+
getCurrentAddress(chain: ChainIDAlias): string;
|
|
1080
|
+
/**
|
|
1081
|
+
* Increment the current index used for internal/external addresses.
|
|
1082
|
+
* @param external
|
|
1083
|
+
*/
|
|
1084
|
+
incrementIndex(external: boolean): void;
|
|
1085
|
+
getAddressEVM(): string;
|
|
1086
|
+
getActiveIndices(): {
|
|
1087
|
+
external: number;
|
|
1088
|
+
internal: number;
|
|
1089
|
+
};
|
|
1090
|
+
getInternalRawAddresses(): Buffer[];
|
|
1091
|
+
getExternalRawAddresses(): Buffer[];
|
|
1092
|
+
getRawAddressC(): Buffer;
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
interface SignTxRequest {
|
|
1096
|
+
tx: UnsignedTx | EVMUnsignedTx;
|
|
1097
|
+
transport?: Transport;
|
|
1098
|
+
externalIndices?: number[];
|
|
1099
|
+
internalIndices?: number[];
|
|
1100
|
+
}
|
|
1101
|
+
interface SignTxBufferRequest {
|
|
1102
|
+
buffer: Buffer;
|
|
1103
|
+
chain: ChainIDAlias;
|
|
1104
|
+
transport?: Transport;
|
|
1105
|
+
signers?: Bip32Path[];
|
|
1106
|
+
change?: Bip32Path[];
|
|
1107
|
+
}
|
|
1108
|
+
interface SignMessageRequest {
|
|
1109
|
+
message: string;
|
|
1110
|
+
chain: ChainIDAlias;
|
|
1111
|
+
transport?: Transport;
|
|
1112
|
+
signer?: Bip32Path;
|
|
1113
|
+
}
|
|
1114
|
+
interface Signer {
|
|
1115
|
+
signTx(txRequest: SignTxRequest): Promise<UnsignedTx>;
|
|
1116
|
+
signTxBuffer(txRequest: SignTxBufferRequest): Promise<Buffer[]>;
|
|
1117
|
+
signMessage(request: SignMessageRequest): Promise<Buffer>;
|
|
1118
|
+
}
|
|
1119
|
+
interface LedgerGetXpubResponse {
|
|
1120
|
+
public_key: Buffer;
|
|
1121
|
+
chain_code: Buffer;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
/**
|
|
1125
|
+
* Ledger wallet class used by the legacy Web Wallet.
|
|
1126
|
+
* Uses dynamic addresses for X and P Chains.
|
|
1127
|
+
*/
|
|
1128
|
+
declare class LedgerWallet extends MnemonicWalletVoid implements Signer {
|
|
1129
|
+
/**
|
|
1130
|
+
*
|
|
1131
|
+
* @param xpub xpub of m/44'/9000'/0'
|
|
1132
|
+
* @param evmPubKey of m/44'/60'/0'/0/0
|
|
1133
|
+
* @param provider
|
|
1134
|
+
*/
|
|
1135
|
+
constructor(xpub: string, evmPubKey: Buffer, provider: AbstractProvider);
|
|
1136
|
+
private getAdditionalAddressesByIndices;
|
|
1137
|
+
/**
|
|
1138
|
+
* Create a ledger wallet from an active transport.
|
|
1139
|
+
* @param t
|
|
1140
|
+
* @param provider
|
|
1141
|
+
*/
|
|
1142
|
+
static fromTransport(t: Transport, provider: AbstractProvider): Promise<LedgerWallet>;
|
|
1143
|
+
static getAccountPath(chain: ChainIDAlias): "m/44'/9000'/0'" | "m/44'/60'/0'";
|
|
1144
|
+
signMessage(request: SignMessageRequest): Promise<Buffer>;
|
|
1145
|
+
/**
|
|
1146
|
+
* Only returns the owned addresses and their derivation path
|
|
1147
|
+
* @param addresses An array of address buffers
|
|
1148
|
+
* @param additionalExternalAddresses Optional array of external account indices
|
|
1149
|
+
* @param additionalInternalAddresses Optional array of internal account indices
|
|
1150
|
+
* @return Map of addressHex to derivationPath
|
|
1151
|
+
*/
|
|
1152
|
+
filterOwnedAddresses(addresses: Buffer[], additionalExternalAddresses?: string[], additionalInternalAddresses?: string[]): Set<string>;
|
|
1153
|
+
signTx(txRequest: SignTxRequest): Promise<UnsignedTx>;
|
|
1154
|
+
signTxBuffer(txRequest: SignTxBufferRequest): Promise<Buffer[]>;
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
/**
|
|
1158
|
+
* A signer interface for mnemonic wallets that mimics the Legacy Web Wallet. This wallet has
|
|
1159
|
+
* multiple addresses for X/P chains, its address index can be incremented to give the user a new address after every transaction.
|
|
1160
|
+
*/
|
|
1161
|
+
declare class MnemonicWallet extends MnemonicWalletVoid implements Signer {
|
|
1162
|
+
private evmPrivKey;
|
|
1163
|
+
protected accountNode: BIP32Interface;
|
|
1164
|
+
/**
|
|
1165
|
+
*
|
|
1166
|
+
* @param avaxXPriv Bip32 node for m/44'/9000'/0'
|
|
1167
|
+
* @param evmPrivKey of m/44'/60'/0'/0/0
|
|
1168
|
+
* @param provider
|
|
1169
|
+
*/
|
|
1170
|
+
constructor(avaxXPriv: string, evmPrivKey: Buffer, provider: AbstractProvider);
|
|
1171
|
+
static fromMnemonic(mnemonic: string, provider: AbstractProvider): MnemonicWallet;
|
|
1172
|
+
signTx(request: SignTxRequest): Promise<UnsignedTx>;
|
|
1173
|
+
private getExternalPrivateKeys;
|
|
1174
|
+
private getInternalPrivateKeys;
|
|
1175
|
+
private getSigningKeys;
|
|
1176
|
+
signTxBuffer(request: SignTxBufferRequest): Promise<Buffer[]>;
|
|
1177
|
+
signMessage(request: SignMessageRequest): Promise<Buffer>;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
/**
|
|
1181
|
+
* A signer wallet class that has single key for X/P chains, and another key for C chain. Same key
|
|
1182
|
+
* can be used for both.
|
|
1183
|
+
* This wallet type does not use dynamic addresses for X and P chains. Only a single address is used.
|
|
1184
|
+
*/
|
|
1185
|
+
declare class StaticSigner extends WalletVoid implements Signer {
|
|
1186
|
+
protected privKeyXP: Buffer;
|
|
1187
|
+
protected privKeyC: Buffer;
|
|
1188
|
+
constructor(privKeyXP: Buffer, privKeyC: Buffer, prov: AbstractProvider);
|
|
1189
|
+
/**
|
|
1190
|
+
* Create a wallet instance using a mnemonic.
|
|
1191
|
+
* @param mnemonic A valid mnemonic string
|
|
1192
|
+
* @param pathXP BIP44 derivation path for the X/P chain address
|
|
1193
|
+
* @param pathC BIP44 derivation path for the C chain address
|
|
1194
|
+
* @param provider
|
|
1195
|
+
*/
|
|
1196
|
+
static fromMnemonic(mnemonic: string, pathXP: string, pathC: string, provider: AbstractProvider): StaticSigner;
|
|
1197
|
+
signMessage(request: SignMessageRequest): Promise<Buffer>;
|
|
1198
|
+
/**
|
|
1199
|
+
* Return the private key for the given chain
|
|
1200
|
+
* @param chain
|
|
1201
|
+
* @protected
|
|
1202
|
+
*/
|
|
1203
|
+
protected getSigningKey(chain: ChainIDAlias): Buffer;
|
|
1204
|
+
/**
|
|
1205
|
+
* Sign Avalanche X/P/C chain transactions in place.
|
|
1206
|
+
* @param request
|
|
1207
|
+
*/
|
|
1208
|
+
signTx(request: SignTxRequest): Promise<_avalabs_avalanchejs.UnsignedTx | _avalabs_avalanchejs.EVMUnsignedTx>;
|
|
1209
|
+
signTxBuffer(request: SignTxBufferRequest): Promise<Buffer[]>;
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/**
|
|
1213
|
+
* A wallet class that can sign X/P and C transactions with the provided mnemonic code.
|
|
1214
|
+
* It can:
|
|
1215
|
+
* - act like the {@link StaticSigner} by only using the signing key of the active account
|
|
1216
|
+
* - sign X/P transactions containing multiple inputs coming from different addresses
|
|
1217
|
+
* However, it doesn't support dynamic addresses like {@link MnemonicWallet} does.
|
|
1218
|
+
*/
|
|
1219
|
+
declare class SimpleSigner implements Signer {
|
|
1220
|
+
/**
|
|
1221
|
+
* Node for `m/44'/9000'/0'`
|
|
1222
|
+
* @private {BIP32Interface}
|
|
1223
|
+
*/
|
|
1224
|
+
private accountNodeXP;
|
|
1225
|
+
/**
|
|
1226
|
+
* Node for `m/44'/60'/0'/0/n`
|
|
1227
|
+
* @private {BIP32Interface}
|
|
1228
|
+
*/
|
|
1229
|
+
private signerNodeEVM;
|
|
1230
|
+
/**
|
|
1231
|
+
* The primary account's index used for signing C transactions and X/P transactions with static addresses
|
|
1232
|
+
* @private {number}
|
|
1233
|
+
*/
|
|
1234
|
+
private activeAccountIndex;
|
|
1235
|
+
/**
|
|
1236
|
+
* @param {string} mnemonic - mnemonic code as defined in {@link https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki}
|
|
1237
|
+
* @param {number} activeAccountIndex - the index of the primary account used for static signing
|
|
1238
|
+
*/
|
|
1239
|
+
constructor(mnemonic: string, activeAccountIndex: number);
|
|
1240
|
+
/**
|
|
1241
|
+
* Generate X/P private keys for custom address indices
|
|
1242
|
+
* @param {number[]} customIndices - optional list of custom address indices
|
|
1243
|
+
* @param {boolean} isChange - optional flag for deriving internal / external addresses from the indices
|
|
1244
|
+
* @returns {Buffer[]} list of private key buffers
|
|
1245
|
+
*/
|
|
1246
|
+
private getAdditionalKeys;
|
|
1247
|
+
/**
|
|
1248
|
+
* Gets the proper list of signing keys for the given VM
|
|
1249
|
+
* @param {VM} vm - the target VM's type
|
|
1250
|
+
* @param {number[]} externalIndices - optional list of custom external address indices
|
|
1251
|
+
* @param {number[]} internalIndices - optional list of custom internal address indices
|
|
1252
|
+
* @returns {Buffer[]} list of private key raw bytes
|
|
1253
|
+
*/
|
|
1254
|
+
private getSigningKeys;
|
|
1255
|
+
signTx(request: SignTxRequest): Promise<_avalabs_avalanchejs.UnsignedTx | _avalabs_avalanchejs.EVMUnsignedTx>;
|
|
1256
|
+
signTxBuffer(request: SignTxBufferRequest): Promise<void>;
|
|
1257
|
+
/**
|
|
1258
|
+
* Returns the X/P/C Chain bip32 node for the active signer.
|
|
1259
|
+
* @private
|
|
1260
|
+
*/
|
|
1261
|
+
private getActiveAccountNode;
|
|
1262
|
+
/**
|
|
1263
|
+
* Signs the given message with the active X/P Chain account.
|
|
1264
|
+
* Used for signing primary network messages.
|
|
1265
|
+
* @param request
|
|
1266
|
+
*/
|
|
1267
|
+
signMessage(request: SignMessageRequest): Promise<Buffer>;
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
/**
|
|
1271
|
+
* Ledger wallet that uses a single address for X/P chains, and another for C chain. Same address can be used for all.
|
|
1272
|
+
*/
|
|
1273
|
+
declare class LedgerSigner extends WalletVoid implements Signer {
|
|
1274
|
+
private pathXP;
|
|
1275
|
+
private pathC;
|
|
1276
|
+
/**
|
|
1277
|
+
*
|
|
1278
|
+
* @param pubkey public key of the address account
|
|
1279
|
+
* @param prov Avalanche network provider
|
|
1280
|
+
* @param path BIP44 derivation path for the given public key
|
|
1281
|
+
*/
|
|
1282
|
+
constructor(pubkeyXP: Buffer, pathXP: string, pubkeyC: Buffer, pathC: string, prov: AbstractProvider);
|
|
1283
|
+
/**
|
|
1284
|
+
*
|
|
1285
|
+
* @param transport Active transport instance
|
|
1286
|
+
* @param pathXP BIP44 path for the X/P chain address
|
|
1287
|
+
* @param pathC BIP44 path for the C chain address
|
|
1288
|
+
* @param provider
|
|
1289
|
+
*/
|
|
1290
|
+
static fromTransport(transport: Transport, pathXP: string, pathC: string, provider: AbstractProvider): Promise<LedgerSigner>;
|
|
1291
|
+
signMessage(request: SignMessageRequest): Promise<Buffer>;
|
|
1292
|
+
/**
|
|
1293
|
+
* Returns the full HD path that will be used for signing.
|
|
1294
|
+
* @return BIP44 path, ex. m/44'/60'/0'/0/0 for C chain
|
|
1295
|
+
*/
|
|
1296
|
+
getFullSignerPath(chain: ChainIDAlias): string;
|
|
1297
|
+
/**
|
|
1298
|
+
* Only returns the last two indices of the full signer path
|
|
1299
|
+
* @return ex. 0/0, 0/1
|
|
1300
|
+
*/
|
|
1301
|
+
getPartialSignerPath(chain: ChainIDAlias): string;
|
|
1302
|
+
/**
|
|
1303
|
+
* Returns the correct HD path for the given chain.
|
|
1304
|
+
* @return ex. m/44'/60'/0'
|
|
1305
|
+
*/
|
|
1306
|
+
getAccountPath(chain: ChainIDAlias): string;
|
|
1307
|
+
signTx(txRequest: SignTxRequest): Promise<UnsignedTx>;
|
|
1308
|
+
signTxBuffer(txRequest: SignTxBufferRequest): Promise<Buffer[]>;
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
/**
|
|
1312
|
+
* A wallet class that can sign X/P and C transactions.
|
|
1313
|
+
* It can:
|
|
1314
|
+
* - act like the {@link LedgerSigner} by only using the signing key of the active account
|
|
1315
|
+
* - sign X/P transactions containing multiple inputs coming from different addresses with the provided extended public key
|
|
1316
|
+
* However, it doesn't support dynamic addresses like {@link LedgerWallet} does.
|
|
1317
|
+
*/
|
|
1318
|
+
declare class SimpleLedgerSigner implements Signer {
|
|
1319
|
+
private activeAccountIndex;
|
|
1320
|
+
private provider;
|
|
1321
|
+
private accountNode;
|
|
1322
|
+
/**
|
|
1323
|
+
* @param {number} activeAccountIndex - the index of the primary account used for static signing
|
|
1324
|
+
* @param {string} xpubXP - optional extended public key of `m/44'/9000'/0`
|
|
1325
|
+
*/
|
|
1326
|
+
constructor(activeAccountIndex: number, provider: JsonRpcProvider, xpubXP?: string);
|
|
1327
|
+
private reSerializeTx;
|
|
1328
|
+
private getChainAlias;
|
|
1329
|
+
private getAccountPath;
|
|
1330
|
+
private getAddressOfPath;
|
|
1331
|
+
private getAddressPathMap;
|
|
1332
|
+
private getAddressBipPaths;
|
|
1333
|
+
signTx(txRequest: SignTxRequest): Promise<UnsignedTx>;
|
|
1334
|
+
signTxBuffer(txRequest: SignTxBufferRequest): Promise<Buffer[]>;
|
|
1335
|
+
signMessage(request: SignMessageRequest): Promise<Buffer>;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
declare const addSignaturesToAvalancheTx: ({ transactionHex, signatures, chainAlias, provider, utxos, }: {
|
|
1339
|
+
transactionHex: string;
|
|
1340
|
+
signatures: Uint8Array[];
|
|
1341
|
+
chainAlias: ChainIDAlias;
|
|
1342
|
+
provider: JsonRpcProvider;
|
|
1343
|
+
utxos: Utxo[];
|
|
1344
|
+
}) => Promise<{
|
|
1345
|
+
signedTxHex: string;
|
|
1346
|
+
hasAllSignatures: boolean;
|
|
1347
|
+
}>;
|
|
1348
|
+
|
|
1349
|
+
type GlacierOutput = Utxo$1 | PChainUtxo;
|
|
1350
|
+
declare const convertGlacierUtxo: (glacierUtxo: GlacierOutput, isTestnet: boolean) => Utxo;
|
|
1351
|
+
|
|
1352
|
+
type Params$2 = {
|
|
1353
|
+
txBytes: Uint8Array;
|
|
1354
|
+
fromAddress: string;
|
|
1355
|
+
vm: VM;
|
|
1356
|
+
utxos: Utxo[];
|
|
1357
|
+
};
|
|
1358
|
+
declare const createAvalancheEvmUnsignedTx: ({ txBytes, fromAddress, vm, utxos, }: Params$2) => Promise<UnsignedTx>;
|
|
1359
|
+
|
|
1360
|
+
type Params$1 = {
|
|
1361
|
+
tx: avaxSerial.AvaxTx;
|
|
1362
|
+
fromAddressBytes?: Uint8Array[];
|
|
1363
|
+
provider: JsonRpcProvider;
|
|
1364
|
+
credentials?: Credential[];
|
|
1365
|
+
utxos: Utxo[];
|
|
1366
|
+
};
|
|
1367
|
+
declare const createAvalancheUnsignedTx: ({ tx, fromAddressBytes, provider, credentials, utxos, }: Params$1) => Promise<UnsignedTx>;
|
|
1368
|
+
|
|
1369
|
+
declare function digestMessage(message: string): Buffer;
|
|
1370
|
+
|
|
1371
|
+
/**
|
|
1372
|
+
* Derive X or P Chain address from a given extended public key.
|
|
1373
|
+
* @param xpub of m/44'/9000'/0'
|
|
1374
|
+
* @param addressIndex will add 0/n to account path where n is the account index
|
|
1375
|
+
* @param provider For parsing the bech32 address with the correct HRP
|
|
1376
|
+
* @param chain X/P/C to prepend to the address
|
|
1377
|
+
* @param isChange if true derived addresses will have the change index set to `1`. ex. `m/44'/9000'/0'/1/0
|
|
1378
|
+
*/
|
|
1379
|
+
declare function getAddressFromXpub(xpub: string, addressIndex: number, provider: AbstractProvider, chain: ChainIDAlias, isChange?: boolean): string;
|
|
1380
|
+
|
|
1381
|
+
/**
|
|
1382
|
+
* Get the address public key from an account xpub
|
|
1383
|
+
* @param xpub xpub string for the path m/44'/9000'/0'
|
|
1384
|
+
* @param index
|
|
1385
|
+
* @return public key of m/44'/9000'/0'/0/index
|
|
1386
|
+
*/
|
|
1387
|
+
declare function getAddressPublicKeyFromXpub(xpub: string, index: number): Buffer;
|
|
1388
|
+
|
|
1389
|
+
/**
|
|
1390
|
+
* Fetches all UTXOs for all addresses given. Splits addresses in to groups if necessary.
|
|
1391
|
+
* @param addrs Addresses to get UTXOs for, address chain must match the api instance chain.
|
|
1392
|
+
* @param api API instance for the chain
|
|
1393
|
+
* @param config
|
|
1394
|
+
*/
|
|
1395
|
+
declare function getUTXOsForAddresses(addrs: string[], api: avm.AVMApi | pvm.PVMApi | evm.EVMApi, config?: Common.GetUTXOsInput): Promise<utils.UtxoSet>;
|
|
1396
|
+
/**
|
|
1397
|
+
* Gets all UTXOs by pagination.
|
|
1398
|
+
* @param api
|
|
1399
|
+
* @param config
|
|
1400
|
+
*/
|
|
1401
|
+
declare function getPaginatedUTXOs(api: avm.AVMApi | pvm.PVMApi | evm.EVMApi, config: Common.GetUTXOsInput): Promise<utils.UtxoSet>;
|
|
1402
|
+
|
|
1403
|
+
interface GetAvaxBalanceDict {
|
|
1404
|
+
/**
|
|
1405
|
+
* UTXOS that have a locktime in the future
|
|
1406
|
+
*/
|
|
1407
|
+
locked: bigint;
|
|
1408
|
+
/**
|
|
1409
|
+
* UTXOs that can be consumed
|
|
1410
|
+
*/
|
|
1411
|
+
available: bigint;
|
|
1412
|
+
/**
|
|
1413
|
+
* UTXOs with a threshold of > 1
|
|
1414
|
+
*/
|
|
1415
|
+
multisig: bigint;
|
|
1416
|
+
/**
|
|
1417
|
+
* LockedStakeable UTXOs, only on P chain
|
|
1418
|
+
*/
|
|
1419
|
+
lockedStakeable: bigint;
|
|
1420
|
+
total: bigint;
|
|
1421
|
+
}
|
|
1422
|
+
/**
|
|
1423
|
+
* Sum the UTXOs into multiple buckets.
|
|
1424
|
+
* @param utxoSet
|
|
1425
|
+
* @param assetID
|
|
1426
|
+
*/
|
|
1427
|
+
declare function getAssetBalance(utxoSet: utils.UtxoSet, assetID: string): GetAvaxBalanceDict;
|
|
1428
|
+
|
|
1429
|
+
/**
|
|
1430
|
+
* Get the current p-chain timestamp in unix
|
|
1431
|
+
*/
|
|
1432
|
+
declare function getPchainUnixNow(isTestnet: boolean): Promise<bigint>;
|
|
1433
|
+
|
|
1434
|
+
interface GetStakedAvaxBalanceDict {
|
|
1435
|
+
/**
|
|
1436
|
+
* UTXOs that are NOT of type LockedStakeable out
|
|
1437
|
+
*/
|
|
1438
|
+
unlockedStaked: bigint;
|
|
1439
|
+
/**
|
|
1440
|
+
* UTXOs that are of type LockedStakeable out
|
|
1441
|
+
*/
|
|
1442
|
+
lockedStaked: bigint;
|
|
1443
|
+
total: bigint;
|
|
1444
|
+
}
|
|
1445
|
+
declare function getStakedAssetBalance(stakeResponse: pvm.GetStakeResponse): GetStakedAvaxBalanceDict;
|
|
1446
|
+
|
|
1447
|
+
declare function getStakeForAddresses(addresses: string[], api: pvm.PVMApi): Promise<pvm.GetStakeResponse>;
|
|
1448
|
+
|
|
1449
|
+
/**
|
|
1450
|
+
* Get the current UNIX time stamp as a BigInt
|
|
1451
|
+
*/
|
|
1452
|
+
declare function getUnixNow(): bigint;
|
|
1453
|
+
|
|
1454
|
+
type UtxoInfo = {
|
|
1455
|
+
utxoId: string;
|
|
1456
|
+
assetId: string;
|
|
1457
|
+
locktime: bigint;
|
|
1458
|
+
stakeableLocktime: bigint;
|
|
1459
|
+
threshold: number;
|
|
1460
|
+
amount: bigint;
|
|
1461
|
+
};
|
|
1462
|
+
declare const getUtxoInfo: (utxo: Utxo) => UtxoInfo;
|
|
1463
|
+
|
|
1464
|
+
type Params = {
|
|
1465
|
+
transactionHex: string;
|
|
1466
|
+
chainAlias: ChainIDAlias;
|
|
1467
|
+
isTestnet: boolean;
|
|
1468
|
+
url: string;
|
|
1469
|
+
token?: string;
|
|
1470
|
+
};
|
|
1471
|
+
declare const getUtxosByTxFromGlacier: ({ transactionHex, chainAlias, isTestnet, url, token, }: Params) => Promise<Utxo[]>;
|
|
1472
|
+
|
|
1473
|
+
declare const getVmByChainAlias: (chainAlias: string) => "EVM" | "AVM" | "PVM";
|
|
1474
|
+
|
|
1475
|
+
/**
|
|
1476
|
+
* Get the xpub for m/44'/9000'/0' from the given mnemonic
|
|
1477
|
+
* @param mnemonic
|
|
1478
|
+
*/
|
|
1479
|
+
declare function getXpubFromMnemonic(mnemonic: string): string;
|
|
1480
|
+
|
|
1481
|
+
/**
|
|
1482
|
+
* Verify the given address is a valid Avalanche bech32 address
|
|
1483
|
+
* @param address The address to test
|
|
1484
|
+
* @param hasChainId if true requires chain alias prefix (X-, P-, C-), if false address must not have a prefix
|
|
1485
|
+
*/
|
|
1486
|
+
declare function isBech32Address(address: string, hasChainId?: boolean): boolean;
|
|
1487
|
+
|
|
1488
|
+
/**
|
|
1489
|
+
* Returns human readable data from a given a transaction buffer,
|
|
1490
|
+
*/
|
|
1491
|
+
declare function parseAvalancheTx(unsignedTx: Common.UnsignedTx, provider: JsonRpcProvider, currentAddress: string): Promise<Tx>;
|
|
1492
|
+
|
|
1493
|
+
declare const emptySignature: Signature;
|
|
1494
|
+
declare const populateCredential: (indices: number[], existingCredentialData?: {
|
|
1495
|
+
unsignedTx: UnsignedTx;
|
|
1496
|
+
credentialIndex: number;
|
|
1497
|
+
}) => Signature[];
|
|
1498
|
+
|
|
1499
|
+
declare function signedTxToHex(signedTx: avaxSerial.SignedTx): string;
|
|
1500
|
+
|
|
1501
|
+
/**
|
|
1502
|
+
* The UTXOs will be sorted in the following order.
|
|
1503
|
+
* 1- LockedStakeable UTXOs with the highest locktime to lowest
|
|
1504
|
+
* 2- Highest value UTXOs to lowest
|
|
1505
|
+
* @remark Does not check for locked UTXOs
|
|
1506
|
+
*/
|
|
1507
|
+
declare function sortUTXOsStaking(utxos: Utxo[]): Utxo[];
|
|
1508
|
+
declare function sortUTXOsByAmount(utxos: Utxo[], isDescending: boolean): Utxo[];
|
|
1509
|
+
declare const sortUTXOsByAmountDescending: (utxos: Utxo[]) => Utxo[];
|
|
1510
|
+
declare const sortUTXOsByAmountAscending: (utxos: Utxo[]) => Utxo[];
|
|
1511
|
+
|
|
1512
|
+
/**
|
|
1513
|
+
* The list of transaction types supported by `getMaximumUtxoSet`.
|
|
1514
|
+
*/
|
|
1515
|
+
declare enum SizeSupportedTx {
|
|
1516
|
+
AddValidator = 0,
|
|
1517
|
+
AddDelegator = 1,
|
|
1518
|
+
ExportP = 2,
|
|
1519
|
+
ImportP = 3,
|
|
1520
|
+
AddPermissionlessValidator = 4,
|
|
1521
|
+
AddPermissionlessDelegator = 5,
|
|
1522
|
+
BaseP = 6,
|
|
1523
|
+
ConsolidateP = 7
|
|
1524
|
+
}
|
|
1525
|
+
/**
|
|
1526
|
+
* 64 KB.
|
|
1527
|
+
* @see https://github.com/ava-labs/avalanchego/blob/aa481ddce393fbb3ab957e4c8f87d5cd50b5eb4e/vms/platformvm/txs/mempool/mempool.go#L21-L23
|
|
1528
|
+
*/
|
|
1529
|
+
declare const P_CHAIN_TX_SIZE_LIMIT = 65536;
|
|
1530
|
+
/**
|
|
1531
|
+
* This method will sort `utxos` depending on the `sizeSupportedTx`'s configured sorting algorithm.
|
|
1532
|
+
* It then performs a binary search over the sorted UTXOs to determine the largest prefix of the sorted array
|
|
1533
|
+
* which can be consumed while still remaining under the byte size limit
|
|
1534
|
+
* @param wallet - an instance of the `WalletAbstract` class, with utilities for creating unsigned transactions
|
|
1535
|
+
* @param utxos - list of UTXOs to be consumed by the transaction. **WARNING:** `utxos` will be sorted **IN PLACE** by this function!
|
|
1536
|
+
* @param sizeSupportedTx - one of the supported transaction types
|
|
1537
|
+
* @param limit - optional - byte size limit, defaults to 64kb.
|
|
1538
|
+
* @returns the largest prefix of `utxos` before hitting the size limit. If no such prefix exists, then an empty array.
|
|
1539
|
+
*/
|
|
1540
|
+
declare function getMaximumUtxoSet(wallet: WalletAbstract$1, utxos: Utxo[], sizeSupportedTx: SizeSupportedTx, limit?: number): Utxo[];
|
|
1541
|
+
|
|
1542
|
+
/**
|
|
1543
|
+
* Verifies the given derivation path is valid, starts with `m`, and of the right length
|
|
1544
|
+
* @param path BIP44 derivation path
|
|
1545
|
+
*/
|
|
1546
|
+
declare function verifyDerivationPath(path: string): any;
|
|
1547
|
+
|
|
1548
|
+
type index_AbstractProvider = AbstractProvider;
|
|
1549
|
+
declare const index_AbstractProvider: typeof AbstractProvider;
|
|
1550
|
+
type index_AddDelegatorTx = AddDelegatorTx;
|
|
1551
|
+
type index_AddPermissionlessDelegatorTx = AddPermissionlessDelegatorTx;
|
|
1552
|
+
type index_AddPermissionlessValidatorTx = AddPermissionlessValidatorTx;
|
|
1553
|
+
type index_AddSubnetValidatorTx = AddSubnetValidatorTx;
|
|
1554
|
+
type index_AddValidatorTx = AddValidatorTx;
|
|
1555
|
+
type index_AddressWallet = AddressWallet;
|
|
1556
|
+
declare const index_AddressWallet: typeof AddressWallet;
|
|
1557
|
+
type index_BaseTx = BaseTx;
|
|
1558
|
+
type index_ChainIDAlias = ChainIDAlias;
|
|
1559
|
+
type index_CreateChainTx = CreateChainTx;
|
|
1560
|
+
type index_CreateSubnetTx = CreateSubnetTx;
|
|
1561
|
+
type index_ExportTx = ExportTx;
|
|
1562
|
+
type index_FeeData = FeeData;
|
|
1563
|
+
declare const index_FujiContext: typeof FujiContext;
|
|
1564
|
+
type index_GetAvaxBalanceDict = GetAvaxBalanceDict;
|
|
1565
|
+
type index_GetStakedAvaxBalanceDict = GetStakedAvaxBalanceDict;
|
|
1566
|
+
type index_GlacierOutput = GlacierOutput;
|
|
1567
|
+
type index_ImportTx = ImportTx;
|
|
1568
|
+
type index_JsonRpcProvider = JsonRpcProvider;
|
|
1569
|
+
declare const index_JsonRpcProvider: typeof JsonRpcProvider;
|
|
1570
|
+
type index_LedgerGetXpubResponse = LedgerGetXpubResponse;
|
|
1571
|
+
type index_LedgerSigner = LedgerSigner;
|
|
1572
|
+
declare const index_LedgerSigner: typeof LedgerSigner;
|
|
1573
|
+
type index_LedgerWallet = LedgerWallet;
|
|
1574
|
+
declare const index_LedgerWallet: typeof LedgerWallet;
|
|
1575
|
+
declare const index_MainnetContext: typeof MainnetContext;
|
|
1576
|
+
type index_MnemonicWallet = MnemonicWallet;
|
|
1577
|
+
declare const index_MnemonicWallet: typeof MnemonicWallet;
|
|
1578
|
+
type index_MnemonicWalletVoid = MnemonicWalletVoid;
|
|
1579
|
+
declare const index_MnemonicWalletVoid: typeof MnemonicWalletVoid;
|
|
1580
|
+
declare const index_P_CHAIN_TX_SIZE_LIMIT: typeof P_CHAIN_TX_SIZE_LIMIT;
|
|
1581
|
+
type index_RemoveSubnetValidatorTx = RemoveSubnetValidatorTx;
|
|
1582
|
+
type index_SignMessageRequest = SignMessageRequest;
|
|
1583
|
+
type index_SignTxBufferRequest = SignTxBufferRequest;
|
|
1584
|
+
type index_SignTxRequest = SignTxRequest;
|
|
1585
|
+
type index_Signer = Signer;
|
|
1586
|
+
type index_SimpleLedgerSigner = SimpleLedgerSigner;
|
|
1587
|
+
declare const index_SimpleLedgerSigner: typeof SimpleLedgerSigner;
|
|
1588
|
+
type index_SimpleSigner = SimpleSigner;
|
|
1589
|
+
declare const index_SimpleSigner: typeof SimpleSigner;
|
|
1590
|
+
type index_SizeSupportedTx = SizeSupportedTx;
|
|
1591
|
+
declare const index_SizeSupportedTx: typeof SizeSupportedTx;
|
|
1592
|
+
type index_StaticSigner = StaticSigner;
|
|
1593
|
+
declare const index_StaticSigner: typeof StaticSigner;
|
|
1594
|
+
type index_TransferSubnetOwnershipTx = TransferSubnetOwnershipTx;
|
|
1595
|
+
type index_TransformSubnetTx = TransformSubnetTx;
|
|
1596
|
+
type index_Tx = Tx;
|
|
1597
|
+
type index_TxBase = TxBase;
|
|
1598
|
+
type index_TxType = TxType;
|
|
1599
|
+
declare const index_TxType: typeof TxType;
|
|
1600
|
+
type index_UnknownTx = UnknownTx;
|
|
1601
|
+
type index_UtxoInfo = UtxoInfo;
|
|
1602
|
+
type index_WalletAbstract = WalletAbstract;
|
|
1603
|
+
declare const index_WalletAbstract: typeof WalletAbstract;
|
|
1604
|
+
type index_WalletVoid = WalletVoid;
|
|
1605
|
+
declare const index_WalletVoid: typeof WalletVoid;
|
|
1606
|
+
declare const index_addSignaturesToAvalancheTx: typeof addSignaturesToAvalancheTx;
|
|
1607
|
+
declare const index_convertGlacierUtxo: typeof convertGlacierUtxo;
|
|
1608
|
+
declare const index_createAvalancheEvmUnsignedTx: typeof createAvalancheEvmUnsignedTx;
|
|
1609
|
+
declare const index_createAvalancheUnsignedTx: typeof createAvalancheUnsignedTx;
|
|
1610
|
+
declare const index_digestMessage: typeof digestMessage;
|
|
1611
|
+
declare const index_emptySignature: typeof emptySignature;
|
|
1612
|
+
declare const index_getAddressFromXpub: typeof getAddressFromXpub;
|
|
1613
|
+
declare const index_getAddressPublicKeyFromXpub: typeof getAddressPublicKeyFromXpub;
|
|
1614
|
+
declare const index_getAssetBalance: typeof getAssetBalance;
|
|
1615
|
+
declare const index_getLedgerProvider: typeof getLedgerProvider;
|
|
1616
|
+
declare const index_getMaximumUtxoSet: typeof getMaximumUtxoSet;
|
|
1617
|
+
declare const index_getPaginatedUTXOs: typeof getPaginatedUTXOs;
|
|
1618
|
+
declare const index_getPchainUnixNow: typeof getPchainUnixNow;
|
|
1619
|
+
declare const index_getStakeForAddresses: typeof getStakeForAddresses;
|
|
1620
|
+
declare const index_getStakedAssetBalance: typeof getStakedAssetBalance;
|
|
1621
|
+
declare const index_getUTXOsForAddresses: typeof getUTXOsForAddresses;
|
|
1622
|
+
declare const index_getUnixNow: typeof getUnixNow;
|
|
1623
|
+
declare const index_getUtxoInfo: typeof getUtxoInfo;
|
|
1624
|
+
declare const index_getUtxosByTxFromGlacier: typeof getUtxosByTxFromGlacier;
|
|
1625
|
+
declare const index_getVmByChainAlias: typeof getVmByChainAlias;
|
|
1626
|
+
declare const index_getXpubFromMnemonic: typeof getXpubFromMnemonic;
|
|
1627
|
+
declare const index_isAddDelegatorTx: typeof isAddDelegatorTx;
|
|
1628
|
+
declare const index_isAddPermissionlessDelegatorTx: typeof isAddPermissionlessDelegatorTx;
|
|
1629
|
+
declare const index_isAddPermissionlessValidatorTx: typeof isAddPermissionlessValidatorTx;
|
|
1630
|
+
declare const index_isAddSubnetValidatorTx: typeof isAddSubnetValidatorTx;
|
|
1631
|
+
declare const index_isAddValidatorTx: typeof isAddValidatorTx;
|
|
1632
|
+
declare const index_isBaseTx: typeof isBaseTx;
|
|
1633
|
+
declare const index_isBech32Address: typeof isBech32Address;
|
|
1634
|
+
declare const index_isCreateChainTx: typeof isCreateChainTx;
|
|
1635
|
+
declare const index_isCreateSubnetTx: typeof isCreateSubnetTx;
|
|
1636
|
+
declare const index_isExportTx: typeof isExportTx;
|
|
1637
|
+
declare const index_isImportTx: typeof isImportTx;
|
|
1638
|
+
declare const index_isObsidianApp: typeof isObsidianApp;
|
|
1639
|
+
declare const index_isRemoveSubnetValidatorTx: typeof isRemoveSubnetValidatorTx;
|
|
1640
|
+
declare const index_isTransferSubnetOwnershipTx: typeof isTransferSubnetOwnershipTx;
|
|
1641
|
+
declare const index_isTransformSubnetTx: typeof isTransformSubnetTx;
|
|
1642
|
+
declare const index_parseAvalancheTx: typeof parseAvalancheTx;
|
|
1643
|
+
declare const index_populateCredential: typeof populateCredential;
|
|
1644
|
+
declare const index_signedTxToHex: typeof signedTxToHex;
|
|
1645
|
+
declare const index_sortUTXOsByAmount: typeof sortUTXOsByAmount;
|
|
1646
|
+
declare const index_sortUTXOsByAmountAscending: typeof sortUTXOsByAmountAscending;
|
|
1647
|
+
declare const index_sortUTXOsByAmountDescending: typeof sortUTXOsByAmountDescending;
|
|
1648
|
+
declare const index_sortUTXOsStaking: typeof sortUTXOsStaking;
|
|
1649
|
+
declare const index_verifyDerivationPath: typeof verifyDerivationPath;
|
|
1650
|
+
declare namespace index {
|
|
1651
|
+
export {
|
|
1652
|
+
index_AbstractProvider as AbstractProvider,
|
|
1653
|
+
index_AddDelegatorTx as AddDelegatorTx,
|
|
1654
|
+
index_AddPermissionlessDelegatorTx as AddPermissionlessDelegatorTx,
|
|
1655
|
+
index_AddPermissionlessValidatorTx as AddPermissionlessValidatorTx,
|
|
1656
|
+
index_AddSubnetValidatorTx as AddSubnetValidatorTx,
|
|
1657
|
+
index_AddValidatorTx as AddValidatorTx,
|
|
1658
|
+
index_AddressWallet as AddressWallet,
|
|
1659
|
+
index_BaseTx as BaseTx,
|
|
1660
|
+
index_ChainIDAlias as ChainIDAlias,
|
|
1661
|
+
index_CreateChainTx as CreateChainTx,
|
|
1662
|
+
index_CreateSubnetTx as CreateSubnetTx,
|
|
1663
|
+
index_ExportTx as ExportTx,
|
|
1664
|
+
index_FeeData as FeeData,
|
|
1665
|
+
index_FujiContext as FujiContext,
|
|
1666
|
+
index_GetAvaxBalanceDict as GetAvaxBalanceDict,
|
|
1667
|
+
index_GetStakedAvaxBalanceDict as GetStakedAvaxBalanceDict,
|
|
1668
|
+
index_GlacierOutput as GlacierOutput,
|
|
1669
|
+
index_ImportTx as ImportTx,
|
|
1670
|
+
index_JsonRpcProvider as JsonRpcProvider,
|
|
1671
|
+
index_LedgerGetXpubResponse as LedgerGetXpubResponse,
|
|
1672
|
+
index_LedgerSigner as LedgerSigner,
|
|
1673
|
+
index_LedgerWallet as LedgerWallet,
|
|
1674
|
+
index_MainnetContext as MainnetContext,
|
|
1675
|
+
index_MnemonicWallet as MnemonicWallet,
|
|
1676
|
+
index_MnemonicWalletVoid as MnemonicWalletVoid,
|
|
1677
|
+
index_P_CHAIN_TX_SIZE_LIMIT as P_CHAIN_TX_SIZE_LIMIT,
|
|
1678
|
+
index_RemoveSubnetValidatorTx as RemoveSubnetValidatorTx,
|
|
1679
|
+
index_SignMessageRequest as SignMessageRequest,
|
|
1680
|
+
index_SignTxBufferRequest as SignTxBufferRequest,
|
|
1681
|
+
index_SignTxRequest as SignTxRequest,
|
|
1682
|
+
index_Signer as Signer,
|
|
1683
|
+
index_SimpleLedgerSigner as SimpleLedgerSigner,
|
|
1684
|
+
index_SimpleSigner as SimpleSigner,
|
|
1685
|
+
index_SizeSupportedTx as SizeSupportedTx,
|
|
1686
|
+
index_StaticSigner as StaticSigner,
|
|
1687
|
+
index_TransferSubnetOwnershipTx as TransferSubnetOwnershipTx,
|
|
1688
|
+
index_TransformSubnetTx as TransformSubnetTx,
|
|
1689
|
+
index_Tx as Tx,
|
|
1690
|
+
index_TxBase as TxBase,
|
|
1691
|
+
index_TxType as TxType,
|
|
1692
|
+
index_UnknownTx as UnknownTx,
|
|
1693
|
+
index_UtxoInfo as UtxoInfo,
|
|
1694
|
+
index_WalletAbstract as WalletAbstract,
|
|
1695
|
+
index_WalletVoid as WalletVoid,
|
|
1696
|
+
index_addSignaturesToAvalancheTx as addSignaturesToAvalancheTx,
|
|
1697
|
+
index_convertGlacierUtxo as convertGlacierUtxo,
|
|
1698
|
+
index_createAvalancheEvmUnsignedTx as createAvalancheEvmUnsignedTx,
|
|
1699
|
+
index_createAvalancheUnsignedTx as createAvalancheUnsignedTx,
|
|
1700
|
+
index_digestMessage as digestMessage,
|
|
1701
|
+
index_emptySignature as emptySignature,
|
|
1702
|
+
index_getAddressFromXpub as getAddressFromXpub,
|
|
1703
|
+
index_getAddressPublicKeyFromXpub as getAddressPublicKeyFromXpub,
|
|
1704
|
+
index_getAssetBalance as getAssetBalance,
|
|
1705
|
+
index_getLedgerProvider as getLedgerProvider,
|
|
1706
|
+
index_getMaximumUtxoSet as getMaximumUtxoSet,
|
|
1707
|
+
index_getPaginatedUTXOs as getPaginatedUTXOs,
|
|
1708
|
+
index_getPchainUnixNow as getPchainUnixNow,
|
|
1709
|
+
index_getStakeForAddresses as getStakeForAddresses,
|
|
1710
|
+
index_getStakedAssetBalance as getStakedAssetBalance,
|
|
1711
|
+
index_getUTXOsForAddresses as getUTXOsForAddresses,
|
|
1712
|
+
index_getUnixNow as getUnixNow,
|
|
1713
|
+
index_getUtxoInfo as getUtxoInfo,
|
|
1714
|
+
index_getUtxosByTxFromGlacier as getUtxosByTxFromGlacier,
|
|
1715
|
+
index_getVmByChainAlias as getVmByChainAlias,
|
|
1716
|
+
index_getXpubFromMnemonic as getXpubFromMnemonic,
|
|
1717
|
+
index_isAddDelegatorTx as isAddDelegatorTx,
|
|
1718
|
+
index_isAddPermissionlessDelegatorTx as isAddPermissionlessDelegatorTx,
|
|
1719
|
+
index_isAddPermissionlessValidatorTx as isAddPermissionlessValidatorTx,
|
|
1720
|
+
index_isAddSubnetValidatorTx as isAddSubnetValidatorTx,
|
|
1721
|
+
index_isAddValidatorTx as isAddValidatorTx,
|
|
1722
|
+
index_isBaseTx as isBaseTx,
|
|
1723
|
+
index_isBech32Address as isBech32Address,
|
|
1724
|
+
index_isCreateChainTx as isCreateChainTx,
|
|
1725
|
+
index_isCreateSubnetTx as isCreateSubnetTx,
|
|
1726
|
+
index_isExportTx as isExportTx,
|
|
1727
|
+
index_isImportTx as isImportTx,
|
|
1728
|
+
index_isObsidianApp as isObsidianApp,
|
|
1729
|
+
index_isRemoveSubnetValidatorTx as isRemoveSubnetValidatorTx,
|
|
1730
|
+
index_isTransferSubnetOwnershipTx as isTransferSubnetOwnershipTx,
|
|
1731
|
+
index_isTransformSubnetTx as isTransformSubnetTx,
|
|
1732
|
+
index_parseAvalancheTx as parseAvalancheTx,
|
|
1733
|
+
index_populateCredential as populateCredential,
|
|
1734
|
+
index_signedTxToHex as signedTxToHex,
|
|
1735
|
+
index_sortUTXOsByAmount as sortUTXOsByAmount,
|
|
1736
|
+
index_sortUTXOsByAmountAscending as sortUTXOsByAmountAscending,
|
|
1737
|
+
index_sortUTXOsByAmountDescending as sortUTXOsByAmountDescending,
|
|
1738
|
+
index_sortUTXOsStaking as sortUTXOsStaking,
|
|
1739
|
+
index_verifyDerivationPath as verifyDerivationPath,
|
|
1740
|
+
};
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
/**
|
|
1744
|
+
* Get the derivation path used by wallet addresses
|
|
1745
|
+
* @param addressIndex Which index is the address on
|
|
1746
|
+
* @param pathSpec BIP44 vs LedgerLive
|
|
1747
|
+
* @param vm Which VM is this address on. Coin index changes between Avalanche and EVM
|
|
1748
|
+
*/
|
|
1749
|
+
declare function getAddressDerivationPath(addressIndex: number, pathSpec: DerivationPath, vm: 'EVM' | 'AVM' | 'PVM'): string;
|
|
1750
|
+
|
|
1751
|
+
/**
|
|
1752
|
+
* Get the public key from a given private key.
|
|
1753
|
+
* @param {(string | Buffer)} privateKey - The string or (hex encoded) byte sequence representation of the private key
|
|
1754
|
+
* @throws Will throw an error for invalid private keys
|
|
1755
|
+
*/
|
|
1756
|
+
declare function getPublicKeyFromPrivateKey(privateKey: string | Buffer): Buffer;
|
|
1757
|
+
|
|
1758
|
+
declare function getPubKeyFromTransport(t: Transport, accountIndex: number, pathType: DerivationPath, vm?: VM): Promise<Buffer>;
|
|
1759
|
+
|
|
1760
|
+
/**
|
|
1761
|
+
* Returns an extended public key for address derivation.
|
|
1762
|
+
* @remarks Returns the extended public key for the given `path` (`m/44'/60'/0'` by default). This key can be used to derive addresses.
|
|
1763
|
+
* @param transport
|
|
1764
|
+
* @param display
|
|
1765
|
+
* @param path
|
|
1766
|
+
*/
|
|
1767
|
+
declare function getLedgerExtendedPublicKey(transport: Transport, display?: boolean, path?: string): Promise<string>;
|
|
1768
|
+
|
|
1769
|
+
declare function omitUndefinedKeys(object: Record<string, any>): Record<string, any>;
|
|
1770
|
+
|
|
1771
|
+
/**
|
|
1772
|
+
* Get application name and version.
|
|
1773
|
+
* @see https://developers.ledger.com/docs/transport/open-close-info-on-apps/#get-information
|
|
1774
|
+
* @param transport
|
|
1775
|
+
*/
|
|
1776
|
+
declare function getLedgerAppInfo(transport: Transport): Promise<{
|
|
1777
|
+
applicationName: string;
|
|
1778
|
+
version: string;
|
|
1779
|
+
}>;
|
|
1780
|
+
|
|
1781
|
+
/**
|
|
1782
|
+
* Open a given application on the connected Hardware Wallet, based on its ASCII name. If successfully processed, it triggers a specific display on the product’s screen, asking the user for a confirmation before actually opening the application.
|
|
1783
|
+
* @see https://developers.ledger.com/docs/transport/open-close-info-on-apps/#open-application
|
|
1784
|
+
*/
|
|
1785
|
+
declare function openLedgerApp(transport: Transport, applicationName: string): Promise<boolean>;
|
|
1786
|
+
|
|
1787
|
+
/**
|
|
1788
|
+
* Quit the current ledger app.
|
|
1789
|
+
* @see https://developers.ledger.com/docs/transport/open-close-info-on-apps/#quit-application
|
|
1790
|
+
* @param transport
|
|
1791
|
+
*/
|
|
1792
|
+
declare function quitLedgerApp(transport: Transport): Promise<Buffer>;
|
|
1793
|
+
|
|
1794
|
+
export { index as Avalanche, BitcoinHistoryTx, BitcoinInputUTXO, BitcoinInputUTXOWithOptionalScript, BitcoinLedgerInputUTXO, BitcoinLedgerWallet, BitcoinOutputUTXO, BitcoinProvider, BitcoinProviderAbstract, BitcoinTx, BitcoinWallet, BitcoinWalletAbstract, BitcoinWalletVoid, DerivationPath, ETH_ACCOUNT_PATH, ETH_COIN_PATH, JsonRpcBatchInternal, LedgerSigner$1 as LedgerSigner, addEncodedSigToPsbt, createPSBTV2, createPsbt, createTransferTx, createWalletPolicy, formatAddressForNetworkBech32, getAddressDerivationPath, getAddressFromXPub, getAddressPrivateKeyFromXPriv, getAddressPublicKeyFromXPub, getAppEth, getBech32Address, getBech32AddressFromXPub, getBtcAddressFromPubKey, getEvmAddressFromPubKey, getLedgerAppInfo, getLedgerExtendedPublicKey, getMaxTransferAmount, getPubKeyFromTransport, getPublicKeyFromPrivateKey, getTransferTxDetails, getVoidSigner, getWalletFromMnemonic, getXpubFromMnemonic$1 as getXpubFromMnemonic, isERC20Transfer, isNativeTxn, omitUndefinedKeys, onBalanceChange, openLedgerApp, psbt2ToPsbt0, quitLedgerApp, selectUtxos };
|