Documentation
¶
Overview ¶
Package thunder provides a JSON-RPC client for the Thunder sidechain.
Index ¶
- type BalanceResponse
- type BmmResult
- type Client
- func (c *Client) Balance(ctx context.Context) (*BalanceResponse, error)
- func (c *Client) ConnectPeer(ctx context.Context, address string) error
- func (c *Client) CreateDeposit(ctx context.Context, address string, valueSats, feeSats int64) (string, error)
- func (c *Client) GenerateMnemonic(ctx context.Context) (string, error)
- func (c *Client) GetBMMInclusions(ctx context.Context, blockHash string) (string, error)
- func (c *Client) GetBestMainchainBlockHash(ctx context.Context) (*string, error)
- func (c *Client) GetBestSidechainBlockHash(ctx context.Context) (*string, error)
- func (c *Client) GetBlock(ctx context.Context, hash string) (json.RawMessage, error)
- func (c *Client) GetBlockCount(ctx context.Context) (int, error)
- func (c *Client) GetNewAddress(ctx context.Context) (string, error)
- func (c *Client) GetWalletAddresses(ctx context.Context) ([]string, error)
- func (c *Client) GetWalletUTXOs(ctx context.Context) (json.RawMessage, error)
- func (c *Client) LatestFailedWithdrawalBundleHeight(ctx context.Context) (*int, error)
- func (c *Client) ListPeers(ctx context.Context) ([]PeerInfo, error)
- func (c *Client) ListUTXOs(ctx context.Context) (json.RawMessage, error)
- func (c *Client) Mine(ctx context.Context, feeSats int64) (*BmmResult, error)
- func (c *Client) MyUTXOs(ctx context.Context) (json.RawMessage, error)
- func (c *Client) OpenAPISchema(ctx context.Context) (json.RawMessage, error)
- func (c *Client) PendingWithdrawalBundle(ctx context.Context) (json.RawMessage, error)
- func (c *Client) RemoveFromMempool(ctx context.Context, txid string) error
- func (c *Client) SetSeedFromMnemonic(ctx context.Context, mnemonic string) error
- func (c *Client) SidechainWealthSats(ctx context.Context) (int64, error)
- func (c *Client) Stop(ctx context.Context) error
- func (c *Client) Transfer(ctx context.Context, dest string, valueSats, feeSats int64, memo *string) (string, error)
- func (c *Client) Withdraw(ctx context.Context, mainchainAddr string, ...) (string, error)
- type Handler
- func (h *Handler) CallRaw(ctx context.Context, req *connect.Request[pb.CallRawRequest]) (*connect.Response[pb.CallRawResponse], error)
- func (h *Handler) ConnectPeer(ctx context.Context, req *connect.Request[pb.ConnectPeerRequest]) (*connect.Response[pb.ConnectPeerResponse], error)
- func (h *Handler) CreateDeposit(ctx context.Context, req *connect.Request[pb.CreateDepositRequest]) (*connect.Response[pb.CreateDepositResponse], error)
- func (h *Handler) GenerateMnemonic(ctx context.Context, req *connect.Request[pb.GenerateMnemonicRequest]) (*connect.Response[pb.GenerateMnemonicResponse], error)
- func (h *Handler) GetBalance(ctx context.Context, req *connect.Request[pb.GetBalanceRequest]) (*connect.Response[pb.GetBalanceResponse], error)
- func (h *Handler) GetBestMainchainBlockHash(ctx context.Context, req *connect.Request[pb.GetBestMainchainBlockHashRequest]) (*connect.Response[pb.GetBestMainchainBlockHashResponse], error)
- func (h *Handler) GetBestSidechainBlockHash(ctx context.Context, req *connect.Request[pb.GetBestSidechainBlockHashRequest]) (*connect.Response[pb.GetBestSidechainBlockHashResponse], error)
- func (h *Handler) GetBlock(ctx context.Context, req *connect.Request[pb.GetBlockRequest]) (*connect.Response[pb.GetBlockResponse], error)
- func (h *Handler) GetBlockCount(ctx context.Context, req *connect.Request[pb.GetBlockCountRequest]) (*connect.Response[pb.GetBlockCountResponse], error)
- func (h *Handler) GetBmmInclusions(ctx context.Context, req *connect.Request[pb.GetBmmInclusionsRequest]) (*connect.Response[pb.GetBmmInclusionsResponse], error)
- func (h *Handler) GetLatestFailedWithdrawalBundleHeight(ctx context.Context, ...) (*connect.Response[pb.GetLatestFailedWithdrawalBundleHeightResponse], error)
- func (h *Handler) GetNewAddress(ctx context.Context, req *connect.Request[pb.GetNewAddressRequest]) (*connect.Response[pb.GetNewAddressResponse], error)
- func (h *Handler) GetPendingWithdrawalBundle(ctx context.Context, ...) (*connect.Response[pb.GetPendingWithdrawalBundleResponse], error)
- func (h *Handler) GetSidechainWealth(ctx context.Context, req *connect.Request[pb.GetSidechainWealthRequest]) (*connect.Response[pb.GetSidechainWealthResponse], error)
- func (h *Handler) GetWalletUtxos(ctx context.Context, req *connect.Request[pb.GetWalletUtxosRequest]) (*connect.Response[pb.GetWalletUtxosResponse], error)
- func (h *Handler) ListPeers(ctx context.Context, req *connect.Request[pb.ListPeersRequest]) (*connect.Response[pb.ListPeersResponse], error)
- func (h *Handler) ListUtxos(ctx context.Context, req *connect.Request[pb.ListUtxosRequest]) (*connect.Response[pb.ListUtxosResponse], error)
- func (h *Handler) Mine(ctx context.Context, req *connect.Request[pb.MineRequest]) (*connect.Response[pb.MineResponse], error)
- func (h *Handler) RemoveFromMempool(ctx context.Context, req *connect.Request[pb.RemoveFromMempoolRequest]) (*connect.Response[pb.RemoveFromMempoolResponse], error)
- func (h *Handler) SetSeedFromMnemonic(ctx context.Context, req *connect.Request[pb.SetSeedFromMnemonicRequest]) (*connect.Response[pb.SetSeedFromMnemonicResponse], error)
- func (h *Handler) Stop(ctx context.Context, req *connect.Request[pb.StopRequest]) (*connect.Response[pb.StopResponse], error)
- func (h *Handler) Transfer(ctx context.Context, req *connect.Request[pb.TransferRequest]) (*connect.Response[pb.TransferResponse], error)
- func (h *Handler) Withdraw(ctx context.Context, req *connect.Request[pb.WithdrawRequest]) (*connect.Response[pb.WithdrawResponse], error)
- type PeerInfo
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 (*Client) Balance ¶
func (c *Client) Balance(ctx context.Context) (*BalanceResponse, error)
Balance returns the node wallet balance.
func (*Client) ConnectPeer ¶
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 ¶
GenerateMnemonic generates a new BIP-39 mnemonic.
func (*Client) GetBMMInclusions ¶
GetBMMInclusions returns mainchain blocks that commit to the given block hash.
func (*Client) GetBestMainchainBlockHash ¶
GetBestMainchainBlockHash returns the best known mainchain block hash.
func (*Client) GetBestSidechainBlockHash ¶
GetBestSidechainBlockHash returns the best known sidechain block hash.
func (*Client) GetBlockCount ¶
GetBlockCount returns the current block height.
func (*Client) GetNewAddress ¶
GetNewAddress generates and returns a new wallet address.
func (*Client) GetWalletAddresses ¶
GetWalletAddresses returns all wallet addresses sorted by base58.
func (*Client) GetWalletUTXOs ¶
GetWalletUTXOs returns wallet UTXOs as raw JSON (schema varies).
func (*Client) LatestFailedWithdrawalBundleHeight ¶
LatestFailedWithdrawalBundleHeight returns the height of the most recent failed withdrawal bundle, or nil if none.
func (*Client) OpenAPISchema ¶
OpenAPISchema returns the node's OpenAPI schema.
func (*Client) PendingWithdrawalBundle ¶
PendingWithdrawalBundle returns the current pending withdrawal bundle as raw JSON.
func (*Client) RemoveFromMempool ¶
RemoveFromMempool removes a transaction from the mempool.
func (*Client) SetSeedFromMnemonic ¶
SetSeedFromMnemonic sets the wallet seed from a mnemonic phrase.
func (*Client) SidechainWealthSats ¶
SidechainWealthSats returns the total sidechain wealth in satoshis.
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