MidnightWalletProvider
Midnight.js API Reference v2.0.2
Midnight.js API Reference / @midnight-ntwrk/midnight-js-testing / MidnightWalletProvider
Class: MidnightWalletProvider
Provider class that implements wallet functionality for the Midnight network. Handles transaction balancing, submission, and wallet state management.
Implementsβ
Implementsβ
Implementsβ
Implementsβ
MidnightProviderWalletProviderResource
Propertiesβ
coinPublicKeyβ
readonlycoinPublicKey:string
Wallet public coin key
Implementation ofβ
encryptionPublicKeyβ
readonlyencryptionPublicKey:string
Wallet EncryptionPublicKey
Implementation ofβ
WalletProvider.encryptionPublicKey
envβ
readonlyenv:EnvironmentConfiguration
loggerβ
logger:
Logger
walletβ
readonlywallet:MidnightWallet
Methodsβ
balanceTx()β
balanceTx(
tx,newCoins):Promise<BalancedTransaction>
Balances an unbalanced transaction by adding necessary inputs and change outputs.
Parametersβ
txβ
The unbalanced transaction to balance
newCoinsβ
CoinInfo[]
Array of new coins to include in the transaction
Returnsβ
Promise<BalancedTransaction>
A promise that resolves to the balanced transaction
Implementation ofβ
close()β
close():
Promise<void>
Closes the wallet and releases resources.
Returnsβ
Promise<void>
A promise that resolves when the wallet is closed
Implementation ofβ
Resource.close
start()β
start(
waitForFundsInWallet):Promise<void>
Starts the wallet and optionally waits for funds to be available.
Parametersβ
waitForFundsInWalletβ
boolean = true
Whether to wait for funds to be available (default: true)
Returnsβ
Promise<void>
A promise that resolves when the wallet is started and funds are available if requested
Implementation ofβ
Resource.start
submitTx()β
submitTx(
tx):Promise<string>
Submits a balanced transaction to the network.
Parametersβ
txβ
The balanced transaction to submit
Returnsβ
Promise<string>
A promise that resolves to the transaction hash
Implementation ofβ
build()β
staticbuild(logger,env,seed?,walletLogLevel?):Promise<MidnightWalletProvider>
Creates a new MidnightWalletProvider instance.
Parametersβ
loggerβ
Logger
Logger instance for recording operations
envβ
Configuration for the wallet environment
seed?β
string
Optional seed for wallet generation. If not provided, a new random wallet will be created
walletLogLevel?β
LogLevel = DEFAULT_WALLET_LOG_LEVEL
Optional log level for wallet operations
Returnsβ
Promise<MidnightWalletProvider>
A promise that resolves to the new wallet provider
Staticβ
withWallet()β
staticwithWallet(logger,env,wallet):Promise<MidnightWalletProvider>
Creates a new MidnightWalletProvider instance using an existing wallet.
Parametersβ
loggerβ
Logger
Logger instance for recording operations
envβ
Configuration for the wallet environment
walletβ
Existing wallet instance to use
Returnsβ
Promise<MidnightWalletProvider>
A promise that resolves to the new wallet provider using the existing wallet