bfgapi

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIVersion = 1

	CmdPingRequest                          = "bfgapi-ping-request"
	CmdPingResponse                         = "bfgapi-ping-response"
	CmdPopTxForL2BlockRequest               = "bfgapi-pop-txs-for-l2-block-request"
	CmdPopTxForL2BlockResponse              = "bfgapi-pop-txs-for-l2-block-response"
	CmdNewL2KeystonesRequest                = "bfgapi-new-l2-keystones-request"
	CmdNewL2KeystonesResponse               = "bfgapi-new-l2-keystones-response"
	CmdBTCFinalityByRecentKeystonesRequest  = "bfgapi-btc-finality-by-recent-keystones-request"
	CmdBTCFinalityByRecentKeystonesResponse = "bfgapi-btc-finality-by-recent-keystones-response"
	CmdBTCFinalityByKeystonesRequest        = "bfgapi-btc-finality-by-keystones-request"
	CmdBTCFinalityByKeystonesResponse       = "bfgapi-btc-finality-by-keystones-response"
	CmdBTCFinalityNotification              = "bfgapi-btc-finality-notification"
	CmdBTCNewBlockNotification              = "bfgapi-btc-new-block-notification"
	CmdL2KeystonesNotification              = "bfgapi-l2-keystones-notification"
	CmdL2KeystonesRequest                   = "bfgapi-l2-keystones-request"
	CmdL2KeystonesResponse                  = "bfgapi-l2-keystones-response"
	CmdBitcoinBalanceRequest                = "bfgapi-bitcoin-balance-request"
	CmdBitcoinBalanceResponse               = "bfgapi-bitcoin-balance-response"
	CmdBitcoinBroadcastRequest              = "bfgapi-bitcoin-broadcast-request"
	CmdBitcoinBroadcastResponse             = "bfgapi-bitcoin-broadcast-response"
	CmdBitcoinInfoRequest                   = "bfgapi-bitcoin-info-request"
	CmdBitcoinInfoResponse                  = "bfgapi-bitcoin-info-response"
	CmdBitcoinUTXOsRequest                  = "bfgapi-bitcoin-utxos-request"
	CmdBitcoinUTXOsResponse                 = "bfgapi-bitcoin-utxos-response"
	CmdAccessPublicKeyCreateRequest         = "bfgapi-access-public-key-create-request"
	CmdAccessPublicKeyCreateResponse        = "bfgapi-access-public-key-create-response"
	CmdAccessPublicKeyDeleteRequest         = "bfgapi-access-public-key-delete-request"
	CmdAccessPublicKeyDeleteResponse        = "bfgapi-access-public-key-delete-response"
)

Variables

View Source
var (
	APIVersionRoute         = fmt.Sprintf("v%d", APIVersion)
	RouteWebsocketPrivate   = fmt.Sprintf("/%s/ws/private", APIVersionRoute)
	RouteWebsocketPublic    = fmt.Sprintf("/%s/ws/public", APIVersionRoute)
	DefaultPrivateListen    = "localhost:8080"
	DefaultPublicListen     = "localhost:8383"
	DefaultPrometheusListen = "localhost:2112"
	DefaultPrivateURL       = "ws://" + DefaultPrivateListen + RouteWebsocketPrivate
	DefaultPublicURL        = "ws://" + DefaultPublicListen + RouteWebsocketPublic
	DefaultRequestLimit     = 10000 // XXX this is a bandaid
	DefaultRequestTimeout   = 10    // XXX PNOOMA
)

Functions

func APICommands

func APICommands() map[protocol.Command]reflect.Type

func Call

func Call(ctx context.Context, c *protocol.Conn, payload any) (protocol.Command, string, any, error)

Call is a blocking call. One should use ReadConn when using Call or else the completion will end up in the Read instead of being completed as expected.

func Read

Read is the low level primitive of a protocol Read. One should generally not use this function and use ReadConn instead.

func ReadConn

func ReadConn(ctx context.Context, c *protocol.Conn) (protocol.Command, string, any, error)

ReadConn reads from Conn and performs callbacks. One should use ReadConn over Read when mixing Write, WriteConn and Call.

func Write

func Write(ctx context.Context, c protocol.APIConn, id string, payload any) error

Write is the low level primitive of a protocol Write. One should generally not use this function and use WriteConn and Call instead.

func WriteConn

func WriteConn(ctx context.Context, c *protocol.Conn, id string, payload any) error

WriteConn writes to Conn. It is equivalent to Write but exists for symmetry reasons.

Types

type AccessPublicKey

type AccessPublicKey struct {
	PublicKey string `json:"public_key"`
	CreatedAt string `json:"created_at" deep:"-"`
}

type AccessPublicKeyCreateRequest

type AccessPublicKeyCreateRequest struct {
	PublicKey string `json:"public_key"` // encoded compressed public key
}

type AccessPublicKeyCreateResponse

type AccessPublicKeyCreateResponse struct {
	Error *protocol.Error `json:"error,omitempty"`
}

type AccessPublicKeyDeleteRequest

type AccessPublicKeyDeleteRequest struct {
	PublicKey string `json:"public_key"`
}

type AccessPublicKeyDeleteResponse

type AccessPublicKeyDeleteResponse struct {
	Error *protocol.Error `json:"error,omitempty"`
}

type BTCFinalityByKeystonesRequest

type BTCFinalityByKeystonesRequest struct {
	L2Keystones []hemi.L2Keystone `json:"l2_keystones"`
	Page        uint32            `json:"page,omitempty"`
	Limit       uint32            `json:"limit,omitempty"`
}

type BTCFinalityByKeystonesResponse

type BTCFinalityByKeystonesResponse struct {
	L2BTCFinalities []hemi.L2BTCFinality `json:"l2_btc_finalities"`
	Error           *protocol.Error      `json:"error,omitempty"`
}

type BTCFinalityByRecentKeystonesRequest

type BTCFinalityByRecentKeystonesRequest struct {
	NumRecentKeystones uint32 `json:"num_recent_keystones"`
}

type BTCFinalityByRecentKeystonesResponse

type BTCFinalityByRecentKeystonesResponse struct {
	L2BTCFinalities []hemi.L2BTCFinality `json:"l2_btc_finalities"`
	Error           *protocol.Error      `json:"error,omitempty"`
}

type BTCFinalityNotification

type BTCFinalityNotification struct{}

type BTCNewBlockNotification

type BTCNewBlockNotification struct{}

type BitcoinBalanceRequest

type BitcoinBalanceRequest struct {
	ScriptHash api.ByteSlice `json:"script_hash"`
}

type BitcoinBalanceResponse

type BitcoinBalanceResponse struct {
	Confirmed   uint64          `json:"confirmed"`
	Unconfirmed int64           `json:"unconfirmed"`
	Error       *protocol.Error `json:"error,omitempty"`
}

type BitcoinBroadcastRequest

type BitcoinBroadcastRequest struct {
	Transaction api.ByteSlice `json:"transaction"` // XXX this needs to be plural
}

type BitcoinBroadcastResponse

type BitcoinBroadcastResponse struct {
	TXID  api.ByteSlice   `json:"txid"`
	Error *protocol.Error `json:"error,omitempty"`
}

type BitcoinInfoRequest

type BitcoinInfoRequest struct{}

type BitcoinInfoResponse

type BitcoinInfoResponse struct {
	Height uint64          `json:"height"`
	Error  *protocol.Error `json:"error,omitempty"`
}

type BitcoinUTXO

type BitcoinUTXO struct {
	Hash  api.ByteSlice `json:"hash"`
	Index uint32        `json:"index"`
	Value int64         `json:"value"`
}

type BitcoinUTXOsRequest

type BitcoinUTXOsRequest struct {
	ScriptHash api.ByteSlice `json:"script_hash"`
}

type BitcoinUTXOsResponse

type BitcoinUTXOsResponse struct {
	UTXOs []*BitcoinUTXO  `json:"utxos"`
	Error *protocol.Error `json:"error,omitempty"`
}

type L2KeystonesNotification

type L2KeystonesNotification struct{}

type L2KeystonesRequest

type L2KeystonesRequest struct {
	NumL2Keystones uint64 `json:"num_l2_keystones"`
}

type L2KeystonesResponse

type L2KeystonesResponse struct {
	L2Keystones []hemi.L2Keystone `json:"l2_keystones"`
	Error       *protocol.Error   `json:"error,omitempty"`
}

type NewL2KeystonesRequest

type NewL2KeystonesRequest struct {
	L2Keystones []hemi.L2Keystone `json:"l2_keystones"`
}

type NewL2KeystonesResponse

type NewL2KeystonesResponse struct {
	Error *protocol.Error `json:"error,omitempty"`
}

type PingRequest

type PingRequest protocol.PingRequest

PingRequest and PingResponse are bfg-specific ping request/replies

type PingResponse

type PingResponse protocol.PingResponse

PingRequest and PingResponse are bfg-specific ping request/replies

type PopTx

type PopTx struct {
	BtcTxId             api.ByteSlice `json:"btc_tx_id"`
	BtcRawTx            api.ByteSlice `json:"btc_raw_tx"`
	BtcHeaderHash       api.ByteSlice `json:"btc_header_hash"`
	BtcTxIndex          *uint64       `json:"btc_tx_index"`
	BtcMerklePath       []string      `json:"btc_merkle_path"`
	PopTxId             api.ByteSlice `json:"pop_tx_id"`
	PopMinerPublicKey   api.ByteSlice `json:"pop_miner_public_key"`
	L2KeystoneAbrevHash api.ByteSlice `json:"l2_keystone_abrev_hash"`
}

type PopTxsForL2BlockRequest

type PopTxsForL2BlockRequest struct {
	L2Block api.ByteSlice `json:"l2_block"`
	Page    uint32        `json:"page,omitempty"`
}

type PopTxsForL2BlockResponse

type PopTxsForL2BlockResponse struct {
	PopTxs []PopTx         `json:"pop_txs"`
	Error  *protocol.Error `json:"error,omitempty"`
}

Jump to

Keyboard shortcuts

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