bitnames

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: 0

Documentation

Overview

Package bitnames provides a JSON-RPC client for the BitNames 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 BitNameData

type BitNameData struct {
	Commitment       *string `json:"commitment,omitempty"`
	EncryptionPubkey *string `json:"encryption_pubkey,omitempty"`
	PaymailFeeSats   *int64  `json:"paymail_fee_sats,omitempty"`
	SigningPubkey    *string `json:"signing_pubkey,omitempty"`
	SocketAddrV4     *string `json:"socket_addr_v4,omitempty"`
	SocketAddrV6     *string `json:"socket_addr_v6,omitempty"`
}

BitNameData holds optional metadata fields attached to a BitName.

type BitnameDetails

type BitnameDetails struct {
	SeqID            string  `json:"seq_id"`
	Commitment       *string `json:"commitment,omitempty"`
	SocketAddrV4     *string `json:"socket_addr_v4,omitempty"`
	SocketAddrV6     *string `json:"socket_addr_v6,omitempty"`
	EncryptionPubkey *string `json:"encryption_pubkey,omitempty"`
	SigningPubkey    *string `json:"signing_pubkey,omitempty"`
	PaymailFeeSats   *int64  `json:"paymail_fee_sats,omitempty"`
}

BitnameDetails describes the on-chain state of a registered BitName.

type BitnameEntry

type BitnameEntry struct {
	Hash    string
	Details BitnameDetails
}

BitnameEntry is a [hash, details] pair returned by the "bitnames" RPC.

func (BitnameEntry) MarshalJSON

func (e BitnameEntry) MarshalJSON() ([]byte, error)

MarshalJSON encodes as the [hash, details] tuple the node expects.

func (*BitnameEntry) UnmarshalJSON

func (e *BitnameEntry) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes the [hash, details] tuple that the node returns.

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 BitNames sidechain node. It mirrors the RPC surface exposed in the Dart BitnamesRPC class.

func NewClient

func NewClient(host string, port int) *Client

NewClient creates a BitNames 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) BitNameData

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

BitNameData retrieves data for a single BitName.

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) DecryptMsg

func (c *Client) DecryptMsg(ctx context.Context, encryptionPubkey, ciphertext string) (string, error)

DecryptMsg decrypts a ciphertext with the given encryption public key. Returns the hex-encoded plaintext (caller must decode if needed).

func (*Client) EncryptMsg

func (c *Client) EncryptMsg(ctx context.Context, encryptionPubkey, msg string) (string, error)

EncryptMsg encrypts a message to the given encryption public key.

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) GetNewEncryptionKey

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

GetNewEncryptionKey generates a new encryption keypair and returns the public key.

func (*Client) GetNewVerifyingKey

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

GetNewVerifyingKey generates a new signing keypair and returns the verifying key.

func (*Client) GetPaymail

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

GetPaymail returns paymail information as raw JSON.

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) ListBitNames

func (c *Client) ListBitNames(ctx context.Context) ([]BitnameEntry, error)

ListBitNames returns all registered BitNames.

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) RegisterBitName

func (c *Client) RegisterBitName(ctx context.Context, plainName string, data *BitNameData) (string, error)

RegisterBitName registers a new BitName with optional data.

func (*Client) ReserveBitName

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

ReserveBitName reserves a BitName hash.

func (*Client) ResolveCommit

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

ResolveCommit resolves a commitment from a BitName.

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) SignArbitraryMsg

func (c *Client) SignArbitraryMsg(ctx context.Context, msg, verifyingKey string) (string, error)

SignArbitraryMsg signs a message with the specified verifying key.

func (*Client) SignArbitraryMsgAsAddr

func (c *Client) SignArbitraryMsgAsAddr(ctx context.Context, msg, address string) (*SignatureResponse, error)

SignArbitraryMsgAsAddr signs a message with the secret key for the given address.

func (*Client) Stop

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

Stop gracefully shuts down the BitNames 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 BitnamesServiceHandler by proxying to the bitnames binary's JSON-RPC. Common methods delegate to the embedded JSONRPCProxy; BitNames-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) MyUtxos

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.

type SignatureResponse

type SignatureResponse struct {
	VerifyingKey string `json:"verifying_key"`
	Signature    string `json:"signature"`
}

SignatureResponse is returned by "sign_arbitrary_msg_as_addr".

Jump to

Keyboard shortcuts

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