Blockchain

class Blockchain(config: BlockchainConfig)

A blockchain backend.

Samples


fun main() { 
   //sampleStart 
   val blockchainConfig: BlockchainConfig = BlockchainConfig.Electrum(
    ElectrumConfig(
        electrumURL,
        null,
        5u,
        null,
        10u
    )
)

val blockchain: Blockchain = Blockchain(blockchainConfig)

val feeRate: FeeRate = blockchain.estimateFee(3u)

val (psbt, txDetails) = TxBuilder()
    .addRecipient(faucetAddress.scriptPubkey(), 1000uL)
    .feeRate(feeRate.asSatPerVb())
    .finish(wallet)

wallet.sign(psbt)

blockchain.broadcast(psbt) 
   //sampleEnd
}

Parameters

config

The blockchain configuration required.

Constructors

Link copied to clipboard
fun Blockchain(config: BlockchainConfig)

Create the new blockchain client.

Functions

Link copied to clipboard
fun broadcast(transaction: Transaction)

Broadcast a transaction.

Link copied to clipboard
fun estimateFee(target: ULong): <Error class: unknown class>

Estimate the fee rate required to confirm a transaction in a given target of blocks.

Link copied to clipboard
fun getBlockHash(height: UInt): String

Get the block hash of a given block.

Link copied to clipboard
fun getHeight(): UInt

Get the current height of the blockchain.