Documentation
¶
Overview ¶
Package bitnames provides a JSON-RPC client for the BitNames sidechain.
Index ¶
- type BalanceResponse
- type BitNameData
- type BitnameDetails
- type BitnameEntry
- type BmmResult
- type Client
- func (c *Client) Balance(ctx context.Context) (*BalanceResponse, error)
- func (c *Client) BitNameData(ctx context.Context, name string) (*BitNameData, 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) DecryptMsg(ctx context.Context, encryptionPubkey, ciphertext string) (string, error)
- func (c *Client) EncryptMsg(ctx context.Context, encryptionPubkey, msg string) (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) GetNewEncryptionKey(ctx context.Context) (string, error)
- func (c *Client) GetNewVerifyingKey(ctx context.Context) (string, error)
- func (c *Client) GetPaymail(ctx context.Context) (json.RawMessage, 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) ListBitNames(ctx context.Context) ([]BitnameEntry, 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) RegisterBitName(ctx context.Context, plainName string, data *BitNameData) (string, error)
- func (c *Client) ReserveBitName(ctx context.Context, name string) (string, error)
- func (c *Client) ResolveCommit(ctx context.Context, bitname string) (string, error)
- func (c *Client) SetSeedFromMnemonic(ctx context.Context, mnemonic string) error
- func (c *Client) SidechainWealthSats(ctx context.Context) (int64, error)
- func (c *Client) SignArbitraryMsg(ctx context.Context, msg, verifyingKey string) (string, error)
- func (c *Client) SignArbitraryMsgAsAddr(ctx context.Context, msg, address string) (*SignatureResponse, 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) DecryptMsg(ctx context.Context, req *connect.Request[pb.DecryptMsgRequest]) (*connect.Response[pb.DecryptMsgResponse], error)
- func (h *Handler) EncryptMsg(ctx context.Context, req *connect.Request[pb.EncryptMsgRequest]) (*connect.Response[pb.EncryptMsgResponse], 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) GetBitNameData(ctx context.Context, req *connect.Request[pb.GetBitNameDataRequest]) (*connect.Response[pb.GetBitNameDataResponse], 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) GetNewEncryptionKey(ctx context.Context, req *connect.Request[pb.GetNewEncryptionKeyRequest]) (*connect.Response[pb.GetNewEncryptionKeyResponse], error)
- func (h *Handler) GetNewVerifyingKey(ctx context.Context, req *connect.Request[pb.GetNewVerifyingKeyRequest]) (*connect.Response[pb.GetNewVerifyingKeyResponse], error)
- func (h *Handler) GetPaymail(ctx context.Context, req *connect.Request[pb.GetPaymailRequest]) (*connect.Response[pb.GetPaymailResponse], 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) GetWalletAddresses(ctx context.Context, req *connect.Request[pb.GetWalletAddressesRequest]) (*connect.Response[pb.GetWalletAddressesResponse], error)
- func (h *Handler) GetWalletUtxos(ctx context.Context, req *connect.Request[pb.GetWalletUtxosRequest]) (*connect.Response[pb.GetWalletUtxosResponse], error)
- func (h *Handler) ListBitNames(ctx context.Context, req *connect.Request[pb.ListBitNamesRequest]) (*connect.Response[pb.ListBitNamesResponse], 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) MyUtxos(ctx context.Context, req *connect.Request[pb.MyUtxosRequest]) (*connect.Response[pb.MyUtxosResponse], error)
- func (h *Handler) OpenapiSchema(ctx context.Context, req *connect.Request[pb.OpenapiSchemaRequest]) (*connect.Response[pb.OpenapiSchemaResponse], error)
- func (h *Handler) RegisterBitName(ctx context.Context, req *connect.Request[pb.RegisterBitNameRequest]) (*connect.Response[pb.RegisterBitNameResponse], error)
- func (h *Handler) ReserveBitName(ctx context.Context, req *connect.Request[pb.ReserveBitNameRequest]) (*connect.Response[pb.ReserveBitNameResponse], error)
- func (h *Handler) ResolveCommit(ctx context.Context, req *connect.Request[pb.ResolveCommitRequest]) (*connect.Response[pb.ResolveCommitResponse], error)
- func (h *Handler) SetSeedFromMnemonic(ctx context.Context, req *connect.Request[pb.SetSeedFromMnemonicRequest]) (*connect.Response[pb.SetSeedFromMnemonicResponse], error)
- func (h *Handler) SignArbitraryMsg(ctx context.Context, req *connect.Request[pb.SignArbitraryMsgRequest]) (*connect.Response[pb.SignArbitraryMsgResponse], error)
- func (h *Handler) SignArbitraryMsgAsAddr(ctx context.Context, req *connect.Request[pb.SignArbitraryMsgAsAddrRequest]) (*connect.Response[pb.SignArbitraryMsgAsAddrResponse], 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
- type SignatureResponse
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 (*Client) Balance ¶
func (c *Client) Balance(ctx context.Context) (*BalanceResponse, error)
Balance returns the node wallet balance.
func (*Client) BitNameData ¶
BitNameData retrieves data for a single BitName.
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) 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 ¶
EncryptMsg encrypts a message to the given encryption public key.
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) GetNewEncryptionKey ¶
GetNewEncryptionKey generates a new encryption keypair and returns the public key.
func (*Client) GetNewVerifyingKey ¶
GetNewVerifyingKey generates a new signing keypair and returns the verifying key.
func (*Client) GetPaymail ¶
GetPaymail returns paymail information as raw JSON.
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) ListBitNames ¶
func (c *Client) ListBitNames(ctx context.Context) ([]BitnameEntry, error)
ListBitNames returns all registered BitNames.
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) 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 ¶
ReserveBitName reserves a BitName hash.
func (*Client) ResolveCommit ¶
ResolveCommit resolves a commitment from a BitName.
func (*Client) SetSeedFromMnemonic ¶
SetSeedFromMnemonic sets the wallet seed from a mnemonic phrase.
func (*Client) SidechainWealthSats ¶
SidechainWealthSats returns the total sidechain wealth in satoshis.
func (*Client) SignArbitraryMsg ¶
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.
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) ConnectPeer ¶
func (*Handler) CreateDeposit ¶
func (*Handler) DecryptMsg ¶
func (*Handler) EncryptMsg ¶
func (*Handler) GenerateMnemonic ¶
func (*Handler) GetBalance ¶
func (*Handler) GetBestMainchainBlockHash ¶
func (*Handler) GetBestSidechainBlockHash ¶
func (*Handler) GetBitNameData ¶
func (*Handler) GetBlockCount ¶
func (*Handler) GetBmmInclusions ¶
func (*Handler) GetLatestFailedWithdrawalBundleHeight ¶
func (*Handler) GetNewAddress ¶
func (*Handler) GetNewEncryptionKey ¶
func (*Handler) GetNewVerifyingKey ¶
func (*Handler) GetPaymail ¶
func (*Handler) GetPendingWithdrawalBundle ¶
func (*Handler) GetSidechainWealth ¶
func (*Handler) GetWalletAddresses ¶
func (*Handler) GetWalletUtxos ¶
func (*Handler) ListBitNames ¶
func (*Handler) OpenapiSchema ¶
func (*Handler) RegisterBitName ¶
func (*Handler) ReserveBitName ¶
func (*Handler) ResolveCommit ¶
func (*Handler) SetSeedFromMnemonic ¶
func (*Handler) SignArbitraryMsg ¶
func (*Handler) SignArbitraryMsgAsAddr ¶
type SignatureResponse ¶
type SignatureResponse struct {
VerifyingKey string `json:"verifying_key"`
Signature string `json:"signature"`
}
SignatureResponse is returned by "sign_arbitrary_msg_as_addr".