Table of Contents

Class FullNodeProxy

Namespace
chia.dotnet
Assembly
chia-dotnet.dll

Proxy that communicates with the full node

public sealed class FullNodeProxy : ServiceProxy, IServiceProxy
Inheritance
FullNodeProxy
Implements
Inherited Members
Extension Methods

Remarks

ctor

Constructors

FullNodeProxy(IRpcClient, string)

Proxy that communicates with the full node

public FullNodeProxy(IRpcClient rpcClient, string originService)

Parameters

rpcClient IRpcClient

IRpcClient instance to use for rpc communication

originService string

Origin

Remarks

ctor

Methods

GetAdditionsAndRemovals(string, CancellationToken)

Retrieves the additions and removals (state transitions) for a certain block. Returns coin records for each addition and removal.

public Task<(IEnumerable<CoinRecord> Additions, IEnumerable<CoinRecord> Removals)> GetAdditionsAndRemovals(string headerhash, CancellationToken cancellationToken = default)

Parameters

headerhash string

The header hash

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<(IEnumerable<CoinRecord> Additions, IEnumerable<CoinRecord> Removals)>

A list of additions and a list of removals

GetAggsigAdditionalData(CancellationToken)

Retrieves aggregated signature additional data.

public Task<string> GetAggsigAdditionalData(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<string>

An awaitable Task

GetAllMempoolItems(CancellationToken)

Returns all items in the mempool.

public Task<IDictionary<string, MempoolItem>> GetAllMempoolItems(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<IDictionary<string, MempoolItem>>

A dictionary of mempool items

GetAllMempoolTxIds(CancellationToken)

Returns a list of all transaction IDs (spend bundle hashes) in the mempool.

public Task<IEnumerable<string>> GetAllMempoolTxIds(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<IEnumerable<string>>

a list of tx_ids

GetAverageBlockTime(CancellationToken)

Estimates the average time it is taking to process the last 500 blocks

public Task<TimeSpan> GetAverageBlockTime(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<TimeSpan>

The TimeSpan estimation

GetBlock(string, CancellationToken)

Get a block by a header hash

public Task<FullBlock> GetBlock(string headerhash, CancellationToken cancellationToken = default)

Parameters

headerhash string

The header hash

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<FullBlock>

The FullBlock

GetBlockCountMetrics(CancellationToken)

Retrieves aggregate information about blocks.

public Task<BlockCountMetrics> GetBlockCountMetrics(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<BlockCountMetrics>

The BlockCountMetrics

GetBlockRecord(string, CancellationToken)

Get a block record by a header hash

public Task<BlockRecord> GetBlockRecord(string headerhash, CancellationToken cancellationToken = default)

Parameters

headerhash string

The header hash

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<BlockRecord>

The BlockRecord

GetBlockRecordByHeight(uint, CancellationToken)

Retrieves a block record by height (assuming the height is less then or equal peak height)

public Task<BlockRecord> GetBlockRecordByHeight(uint height, CancellationToken cancellationToken = default)

Parameters

height uint

the height to get

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<BlockRecord>

The BlockRecord

GetBlockRecords(uint, uint, CancellationToken)

Retrieves block records in a range

public Task<IEnumerable<BlockRecord>> GetBlockRecords(uint start, uint end, CancellationToken cancellationToken = default)

Parameters

start uint

Start height

end uint

End Height - non-inclusive

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<IEnumerable<BlockRecord>>

list of BlockRecords

GetBlockSpends(string, CancellationToken)

Retrieves every coin that was spent in a block

public Task<IEnumerable<CoinSpend>> GetBlockSpends(string headerhash, CancellationToken cancellationToken = default)

Parameters

headerhash string

The block's header_hash

cancellationToken CancellationToken

Returns

Task<IEnumerable<CoinSpend>>

Exceptions

ArgumentNullException

GetBlockSpendsWithConditions(string, CancellationToken)

Retrieves the spends in the given block, including its conditions.

public Task<IEnumerable<BlockSpendWithConditions>> GetBlockSpendsWithConditions(string headerHash, CancellationToken cancellationToken = default)

Parameters

headerHash string
cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<IEnumerable<BlockSpendWithConditions>>

A list of BlockSpendWithConditions

GetBlockchainState(CancellationToken)

Returns a summary of the node's view of the blockchain.

public Task<BlockchainState> GetBlockchainState(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<BlockchainState>

The BlockchainState

GetBlocks(uint, uint, bool?, bool?, CancellationToken)

Get the blocks between a start and end height

public Task<IEnumerable<FullBlock>> GetBlocks(uint start, uint end, bool? excludeHeaderhash = null, bool? excludeReorged = null, CancellationToken cancellationToken = default)

Parameters

start uint

Start height

end uint

End Height - non-inclusive

excludeHeaderhash bool?

Flag indicating whether to include the header hash in the result or not

excludeReorged bool?
cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<IEnumerable<FullBlock>>

A list of FullBlocks

GetCoinRecordByName(string, CancellationToken)

Retrieves a coin record by its name/id.

public Task<CoinRecord> GetCoinRecordByName(string name, CancellationToken cancellationToken = default)

Parameters

name string

The coin name

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<CoinRecord>

A CoinRecord

GetCoinRecordsByHint(string, bool, uint?, uint?, CancellationToken)

Retrieves a coin record by hint

public Task<IEnumerable<CoinRecord>> GetCoinRecordsByHint(string hint, bool includeSpentCoins, uint? startHeight = null, uint? endHeight = null, CancellationToken cancellationToken = default)

Parameters

hint string

The hint

includeSpentCoins bool

whether to include spent coins too, instead of just unspent

startHeight uint?

confirmation start height for search

endHeight uint?

confirmation end height for search

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<IEnumerable<CoinRecord>>

A list of CoinRecords

GetCoinRecordsByNames(IEnumerable<string>, bool, uint?, uint?, CancellationToken)

Retrieves the coins for given coin IDs

public Task<IEnumerable<CoinRecord>> GetCoinRecordsByNames(IEnumerable<string> names, bool includeSpentCoins, uint? startHeight = null, uint? endHeight = null, CancellationToken cancellationToken = default)

Parameters

names IEnumerable<string>

The coin names

includeSpentCoins bool

Flag indicating whether to include spent coins or not

startHeight uint?

confirmation start height for search

endHeight uint?

confirmation end height for search

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<IEnumerable<CoinRecord>>

A list of CoinRecords

GetCoinRecordsByParentIds(IEnumerable<string>, bool, uint?, uint?, CancellationToken)

Retrieves the coins for a given list of parent ids

public Task<IEnumerable<CoinRecord>> GetCoinRecordsByParentIds(IEnumerable<string> parentIds, bool includeSpentCoins, uint? startHeight = null, uint? endHeight = null, CancellationToken cancellationToken = default)

Parameters

parentIds IEnumerable<string>

The list of parent ids hashes

includeSpentCoins bool

whether to include spent coins too, instead of just unspent

startHeight uint?

confirmation start height for search

endHeight uint?

confirmation end height for search

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<IEnumerable<CoinRecord>>

A list of CoinRecords

GetCoinRecordsByPuzzleHash(string, bool, uint?, uint?, CancellationToken)

Retrieves the coins for a given puzzlehash

public Task<IEnumerable<CoinRecord>> GetCoinRecordsByPuzzleHash(string puzzlehash, bool includeSpentCoins, uint? startHeight, uint? endHeight, CancellationToken cancellationToken = default)

Parameters

puzzlehash string

The puzzle hash

includeSpentCoins bool

whether to include spent coins too, instead of just unspent

startHeight uint?

confirmation start height for search

endHeight uint?

confirmation end height for search

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<IEnumerable<CoinRecord>>

A list of CoinRecords

GetCoinRecordsByPuzzleHashes(IEnumerable<string>, bool, uint?, uint?, CancellationToken)

Retrieves the coins for a given list of puzzlehashes, by default returns unspent coins.

public Task<IEnumerable<CoinRecord>> GetCoinRecordsByPuzzleHashes(IEnumerable<string> puzzlehashes, bool includeSpentCoins, uint? startHeight = null, uint? endHeight = null, CancellationToken cancellationToken = default)

Parameters

puzzlehashes IEnumerable<string>

The list of puzzle hashes

includeSpentCoins bool

whether to include spent coins too, instead of just unspent

startHeight uint?

confirmation start height for search

endHeight uint?

confirmation end height for search

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<IEnumerable<CoinRecord>>

A list of CoinRecords

GetFeeEstimate(ulong, IEnumerable<int>, CancellationToken)

Estimate a spend fee

public Task<(IEnumerable<ulong> estimates, IEnumerable<int> targetTimes, float currentFeeRate, ulong mempoolSize, ulong mempoolFees, int numSpends, ulong mempoolMaxSize, bool synced, uint peakHeight, ulong lastPeakTimestamp, ulong nodeTimeUtc, ulong lastBlockCost, ulong feesLastBlock, float feeRateLastBlock, uint lastTxBlockHeight)> GetFeeEstimate(ulong cost, IEnumerable<int> targetTimes, CancellationToken cancellationToken = default)

Parameters

cost ulong
targetTimes IEnumerable<int>

Array of target times

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<(IEnumerable<ulong> estimates, IEnumerable<int> targetTimes, float currentFeeRate, ulong mempoolSize, ulong mempoolFees, int numSpends, ulong mempoolMaxSize, bool synced, uint peakHeight, ulong lastPeakTimestamp, ulong nodeTimeUtc, ulong lastBlockCost, ulong feesLastBlock, float feeRateLastBlock, uint lastTxBlockHeight)>

Fee estimate details

GetFeeEstimate(SpendBundle, IEnumerable<int>, CancellationToken)

Estimate a spend fee

public Task<(IEnumerable<int> Estimates, IEnumerable<int> TargetTimes, ulong CurrentFeeRate, ulong MempoolSize, ulong MempoolMaxSize, bool Synced, uint PeakHeight, ulong LastPeakTimestamp, ulong UtcTimestamp)> GetFeeEstimate(SpendBundle spendBundle, IEnumerable<int> targetTimes, CancellationToken cancellationToken = default)

Parameters

spendBundle SpendBundle

The spend bundle to estimate

targetTimes IEnumerable<int>

Array of target times

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<(IEnumerable<int> Estimates, IEnumerable<int> TargetTimes, ulong CurrentFeeRate, ulong MempoolSize, ulong MempoolMaxSize, bool Synced, uint PeakHeight, ulong LastPeakTimestamp, ulong UtcTimestamp)>

Fee estimate details

GetMempoolItemByTxId(string, bool, CancellationToken)

Gets a mempool item by tx id.

public Task<MempoolItem> GetMempoolItemByTxId(string txId, bool includePending = false, CancellationToken cancellationToken = default)

Parameters

txId string

Transaction id

includePending bool

Including pending transactions

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<MempoolItem>

The MempoolItem

GetMempoolItemsByCoinName(string, CancellationToken)

Gets a mempool item by coin name.

public Task<IEnumerable<MempoolItem>> GetMempoolItemsByCoinName(string coinName, CancellationToken cancellationToken = default)

Parameters

coinName string

Coin name

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<IEnumerable<MempoolItem>>

The MempoolItem

GetNetworkSpace(string, string, CancellationToken)

Retrieves an estimate of total space validating the chain between two block header hashes.

public Task<BigInteger> GetNetworkSpace(string newerBlockHeaderhash, string olderBlockHeaderhash, CancellationToken cancellationToken = default)

Parameters

newerBlockHeaderhash string
olderBlockHeaderhash string
cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<BigInteger>

BigInteger of network space in bytes

GetPuzzleAndSolution(string, uint, CancellationToken)

Gets a coin solution

public Task<CoinSpend> GetPuzzleAndSolution(string coinId, uint height, CancellationToken cancellationToken = default)

Parameters

coinId string

Id/name of the coin

height uint

Block height at which the coin was spent 'spent_block_index'

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<CoinSpend>

A CoinSpend

Remarks

coinId is the coin name

GetRecentEOS(string, CancellationToken)

Gets a recent end of slot

public Task<(EndOfSubSlotBundle Eos, double TimeReceived, bool Reverted, DateTime DateTimeReceived)> GetRecentEOS(string challengeHash, CancellationToken cancellationToken = default)

Parameters

challengeHash string

challenge hash

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<(EndOfSubSlotBundle Eos, double TimeReceived, bool Reverted, DateTime DateTimeReceived)>

The EndOfSubSlotBundle

GetRecentSignagePoint(string, CancellationToken)

Gets a recent signage point

public Task<(SignagePoint SignagePoint, double TimeReceived, bool Reverted, DateTime DateTimeReceived)> GetRecentSignagePoint(string spHash, CancellationToken cancellationToken = default)

Parameters

spHash string

signage point hash

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<(SignagePoint SignagePoint, double TimeReceived, bool Reverted, DateTime DateTimeReceived)>

The SignagePoint

GetUnfinishedBlockHeaders(CancellationToken)

Get unfinished block headers

public Task<IEnumerable<UnfinishedHeaderBlock>> GetUnfinishedBlockHeaders(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<IEnumerable<UnfinishedHeaderBlock>>

A list of UnfinishedHeaderBlocks

OnEventMessage(Message)

protected override void OnEventMessage(Message msg)

Parameters

msg Message

PushTx(SpendBundle, CancellationToken)

Pushes a spend bundle to the mempool and blockchain. Returns whether the spend bundle was successfully included into the mempool

public Task<bool> PushTx(SpendBundle spendBundle, CancellationToken cancellationToken = default)

Parameters

spendBundle SpendBundle
cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task<bool>

Indicator of whether the spend bundle was successfully included in the mempool

WaitForSync(int, CancellationToken)

Will wait until GetBlockchainState(CancellationToken) indicates that the full node has synced or until the cancellation token is canceled

public Task WaitForSync(int millisecondsDelay = 10000, CancellationToken cancellationToken = default)

Parameters

millisecondsDelay int

The number of milliseconds to wait each time before checking sync status

cancellationToken CancellationToken

A token to allow the call to be cancelled

Returns

Task

An awaitable Task

Exceptions

TaskCanceledException

When cancellation token expires or is cancelled

Events

BlockchainStateChanged

Event raised when the blockchain state changes

public event EventHandler<dynamic>? BlockchainStateChanged

Event Type

EventHandler<dynamic>
Proxy that communicates with the full node