thunder

package
v0.0.0-...-4904f9a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2026 License: MIT Imports: 11 Imported by: 6

Documentation

Overview

Package thunder provides a JSON-RPC client for the Thunder sidechain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BalanceResponse

type BalanceResponse struct {
	TotalSats     int64 `json:"total_sats"`
	AvailableSats int64 `json:"available_sats"`
}

BalanceResponse is the reply from the "balance" RPC.

type BmmResult

type BmmResult struct {
	HashLastMainBlock      string  `json:"hash_last_main_block"`
	BmmBlockCreated        *string `json:"bmm_block_created,omitempty"`
	BmmBlockSubmitted      *string `json:"bmm_block_submitted,omitempty"`
	BmmBlockSubmittedBlind *string `json:"bmm_block_submitted_blind,omitempty"`
	Ntxn                   int     `json:"ntxn"`
	Nfees                  int     `json:"nfees"`
	Txid                   string  `json:"txid"`
	Error                  *string `json:"error,omitempty"`
}

BmmResult is the response from the "mine" RPC.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a JSON-RPC client for the Thunder sidechain node. It mirrors the RPC surface exposed in the Dart ThunderRPC class.

func NewClient

func NewClient(host string, port int) *Client

NewClient creates a Thunder RPC client pointed at host:port.

func (*Client) Balance

func (c *Client) Balance(ctx context.Context) (*BalanceResponse, error)

Balance returns the node wallet balance.

func (*Client) ConnectPeer

func (c *Client) ConnectPeer(ctx context.Context, address string) error

ConnectPeer connects to a peer at the given address.

func (*Client) CreateDeposit

func (c *Client) CreateDeposit(ctx context.Context, address string, valueSats, feeSats int64) (string, error)

CreateDeposit creates a deposit transaction.

func (*Client) GenerateMnemonic

func (c *Client) GenerateMnemonic(ctx context.Context) (string, error)

GenerateMnemonic generates a new BIP-39 mnemonic.

func (*Client) GetBMMInclusions

func (c *Client) GetBMMInclusions(ctx context.Context, blockHash string) (string, error)

GetBMMInclusions returns mainchain blocks that commit to the given block hash.

func (*Client) GetBestMainchainBlockHash

func (c *Client) GetBestMainchainBlockHash(ctx context.Context) (*string, error)

GetBestMainchainBlockHash returns the best known mainchain block hash.

func (*Client) GetBestSidechainBlockHash

func (c *Client) GetBestSidechainBlockHash(ctx context.Context) (*string, error)

GetBestSidechainBlockHash returns the best known sidechain block hash.

func (*Client) GetBlock

func (c *Client) GetBlock(ctx context.Context, hash string) (json.RawMessage, error)

GetBlock returns block data for a given hash.

func (*Client) GetBlockCount

func (c *Client) GetBlockCount(ctx context.Context) (int, error)

GetBlockCount returns the current block height.

func (*Client) GetNewAddress

func (c *Client) GetNewAddress(ctx context.Context) (string, error)

GetNewAddress generates and returns a new wallet address.

func (*Client) GetWalletAddresses

func (c *Client) GetWalletAddresses(ctx context.Context) ([]string, error)

GetWalletAddresses returns all wallet addresses sorted by base58.

func (*Client) GetWalletUTXOs

func (c *Client) GetWalletUTXOs(ctx context.Context) (json.RawMessage, error)

GetWalletUTXOs returns wallet UTXOs as raw JSON (schema varies).

func (*Client) LatestFailedWithdrawalBundleHeight

func (c *Client) LatestFailedWithdrawalBundleHeight(ctx context.Context) (*int, error)

LatestFailedWithdrawalBundleHeight returns the height of the most recent failed withdrawal bundle, or nil if none.

func (*Client) ListPeers

func (c *Client) ListPeers(ctx context.Context) ([]PeerInfo, error)

ListPeers returns connected peers.

func (*Client) ListUTXOs

func (c *Client) ListUTXOs(ctx context.Context) (json.RawMessage, error)

ListUTXOs returns all UTXOs as raw JSON.

func (*Client) Mine

func (c *Client) Mine(ctx context.Context, feeSats int64) (*BmmResult, error)

Mine attempts to create and submit a BMM block.

func (*Client) MyUTXOs

func (c *Client) MyUTXOs(ctx context.Context) (json.RawMessage, error)

MyUTXOs returns the caller's owned UTXOs as raw JSON.

func (*Client) OpenAPISchema

func (c *Client) OpenAPISchema(ctx context.Context) (json.RawMessage, error)

OpenAPISchema returns the node's OpenAPI schema.

func (*Client) PendingWithdrawalBundle

func (c *Client) PendingWithdrawalBundle(ctx context.Context) (json.RawMessage, error)

PendingWithdrawalBundle returns the current pending withdrawal bundle as raw JSON.

func (*Client) RemoveFromMempool

func (c *Client) RemoveFromMempool(ctx context.Context, txid string) error

RemoveFromMempool removes a transaction from the mempool.

func (*Client) SetSeedFromMnemonic

func (c *Client) SetSeedFromMnemonic(ctx context.Context, mnemonic string) error

SetSeedFromMnemonic sets the wallet seed from a mnemonic phrase.

func (*Client) SidechainWealthSats

func (c *Client) SidechainWealthSats(ctx context.Context) (int64, error)

SidechainWealthSats returns the total sidechain wealth in satoshis.

func (*Client) Stop

func (c *Client) Stop(ctx context.Context) error

Stop gracefully shuts down the Thunder node.

func (*Client) Transfer

func (c *Client) Transfer(ctx context.Context, dest string, valueSats, feeSats int64, memo *string) (string, error)

Transfer sends funds.

func (*Client) Withdraw

func (c *Client) Withdraw(ctx context.Context, mainchainAddr string, amountSats, sidechainFeeSats, mainchainFeeSats int64) (string, error)

Withdraw initiates a withdrawal to the mainchain.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler implements ThunderServiceHandler by proxying to the thunder binary's JSON-RPC. Common methods delegate to the embedded JSONRPCProxy; Thunder-specific methods are implemented directly using the proxy's Client.

func NewHandler

func NewHandler(proxy *sidechain.JSONRPCProxy) *Handler

func (*Handler) CallRaw

func (*Handler) GetBlock

func (*Handler) Mine

func (*Handler) Stop

func (*Handler) Transfer

func (*Handler) Withdraw

type PeerInfo

type PeerInfo struct {
	Address string `json:"address"`
	Status  string `json:"status"`
}

PeerInfo describes a connected peer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL