Table of Contents

Class Wallet

Namespace
chia.dotnet
Assembly
chia-dotnet.dll

Base class representing a specific wallet (i.e. anything with a WalletID)

public class Wallet
Inheritance
Wallet
Derived
Inherited Members
Extension Methods

Remarks

When not derived from this represents a STANDARD_WALLET

Constructors

Wallet(uint, WalletProxy)

Base class representing a specific wallet (i.e. anything with a WalletID)

public Wallet(uint walletId, WalletProxy walletProxy)

Parameters

walletId uint

The wallet_id to wrap

walletProxy WalletProxy

Wallet RPC proxy to use for communication

Remarks

When not derived from this represents a STANDARD_WALLET

Properties

WalletId

The id of the wallet

public uint WalletId { get; init; }

Property Value

uint
Base class representing a specific wallet (i.e. anything with a WalletID)

WalletProxy

Wallet RPC proxy for communication

public WalletProxy WalletProxy { get; init; }

Property Value

WalletProxy
Base class representing a specific wallet (i.e. anything with a WalletID)

Methods

CreateWalletDataObject()

Creates a dynamic object and sets its wallet_id property to WalletId

protected dynamic CreateWalletDataObject()

Returns

dynamic

A dynamic object

DeleteUnconfirmedTransactions(CancellationToken)

Delete unconfirmed transactions from the wallet

public Task DeleteUnconfirmedTransactions(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task

An awaitable Task

GetBalance(CancellationToken)

Get the balance of a specific wallet

public Task<WalletBalance> GetBalance(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<WalletBalance>

The wallet balance (in units of mojos)

GetNextAddress(bool, CancellationToken)

Get the last address or create a new one

public Task<string> GetNextAddress(bool newAddress, CancellationToken cancellationToken = default)

Parameters

newAddress bool

Whether to generate a new address

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<string>

An address

GetSpendableCoins(ulong?, ulong?, IEnumerable<ulong>?, IEnumerable<Coin>?, IEnumerable<string>?, CancellationToken)

Get the list of spendable coins

public Task<(IEnumerable<CoinRecord> ConfirmedRecords, IEnumerable<CoinRecord> UnconfirmedRecords, IEnumerable<Coin> UnconfirmedAdditions)> GetSpendableCoins(ulong? minCoinAmount, ulong? maxCoinAmount, IEnumerable<ulong>? excludedCoinAmounts = null, IEnumerable<Coin>? excludedCoins = null, IEnumerable<string>? excludedCoinIds = null, CancellationToken cancellationToken = default)

Parameters

minCoinAmount ulong?

The minimum coin amount

maxCoinAmount ulong?

The maximum coin amount>

excludedCoinAmounts IEnumerable<ulong>

Amounts to exclude

excludedCoins IEnumerable<Coin>

Coins to exclude

excludedCoinIds IEnumerable<string>

Coin ids to exclude

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<(IEnumerable<CoinRecord> ConfirmedRecords, IEnumerable<CoinRecord> UnconfirmedRecords, IEnumerable<Coin> UnconfirmedAdditions)>

Information about spendable coins

GetTransactionCount(TransactionTypeFilter?, CancellationToken)

Get the number of transactions

public Task<uint> GetTransactionCount(TransactionTypeFilter? typeFilter = null, CancellationToken cancellationToken = default)

Parameters

typeFilter TransactionTypeFilter
cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<uint>

The number of transactions

GetTransactions(string?, TransactionTypeFilter?, bool, string?, uint, uint, bool?, CancellationToken)

Retrieves a list of transactions from a wallet.

public Task<IEnumerable<TransactionRecord>> GetTransactions(string? toAddress = null, TransactionTypeFilter? typeFilter = null, bool reverse = false, string? sortKey = null, uint start = 0, uint end = 50, bool? confirmed = null, CancellationToken cancellationToken = default)

Parameters

toAddress string

Restrict results only to this address

typeFilter TransactionTypeFilter
reverse bool

Reverse the sort order of the results

sortKey string

Field to sort results by

start uint

the start index of transactions (zero based)

end uint

The end index of transactions

confirmed bool?
cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<IEnumerable<TransactionRecord>>

A list of TransactionRecord

GetWalletInfo(CancellationToken)

Retrieves information about this wallet

public Task<WalletInfo> GetWalletInfo(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<WalletInfo>

WalletInfo and the wallet pubkey fingerprint

Remarks

Throws an exception if the wallet does not exist

SelectCoins(ulong, IEnumerable<Coin>?, IEnumerable<ulong>?, ulong?, ulong?, CancellationToken)

Returns a set of coins that can be used for generating a new transaction.

public Task<IEnumerable<Coin>> SelectCoins(ulong amount, IEnumerable<Coin>? excludedCoins = null, IEnumerable<ulong>? excludedCoinAmounts = null, ulong? minCoinAmount = null, ulong? maxCoinAmount = null, CancellationToken cancellationToken = default)

Parameters

amount ulong

An amount

excludedCoins IEnumerable<Coin>
excludedCoinAmounts IEnumerable<ulong>
minCoinAmount ulong?
maxCoinAmount ulong?
cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<IEnumerable<Coin>>

The list of IEnumerable<T>s

SendTransaction(string, ulong, IEnumerable<string>?, IEnumerable<ulong>?, IEnumerable<string>?, ulong?, ulong?, bool, ulong, CancellationToken)

Sends a transaction

public Task<TransactionRecord> SendTransaction(string address, ulong amount, IEnumerable<string>? memos = null, IEnumerable<ulong>? excludeCoinAmounts = null, IEnumerable<string>? excludeCoinsIds = null, ulong? minCoinAmount = null, ulong? maxCoinAmount = null, bool reusePuzhash = false, ulong fee = 0, CancellationToken cancellationToken = default)

Parameters

address string

The receiving address

amount ulong

The amount to send (in units of mojos)

memos IEnumerable<string>

Memos to go along with the transaction

excludeCoinAmounts IEnumerable<ulong>
excludeCoinsIds IEnumerable<string>
minCoinAmount ulong?
maxCoinAmount ulong?
reusePuzhash bool
fee ulong

Fee (in units of mojos)

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<TransactionRecord>

The TransactionRecord

SendTransactionMulti(IEnumerable<Coin>, IEnumerable<Coin>?, ulong, CancellationToken)

Sends a transaction

public Task<TransactionRecord> SendTransactionMulti(IEnumerable<Coin> additions, IEnumerable<Coin>? coins = null, ulong fee = 0, CancellationToken cancellationToken = default)

Parameters

additions IEnumerable<Coin>

Additions to the block chain

coins IEnumerable<Coin>

Coins to include

fee ulong

Fee (in units of mojos)

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<TransactionRecord>

The TransactionRecord

Validate(CancellationToken)

Validates that WalletId is a STANDARD_WALLET

public virtual Task Validate(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken
Base class representing a specific wallet (i.e. anything with a WalletID)

Returns

Task

True if the wallet is of the expected type

Remarks

Intended to be overridden by derived classes of specific WalletType

Validate(WalletType, CancellationToken)

Validates that WalletId exists and is of the correct WalletType

protected Task Validate(WalletType walletType, CancellationToken cancellationToken)

Parameters

walletType WalletType

The expected type of wallet

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task

true if the wallet is of the expected type

Remarks

Throws an exception if the wallet does not exist