Documentation
¶
Overview ¶
Package datasource abstracts every read-only chain/drivechain data fetch that bitwindow + the orchestrator make from Bitcoin Core and the BIP300301 enforcer, behind a single interface. The current ("local") implementation is wired straight to those endpoints; a future PR adds a remote implementation plus wallet-type-based selection (electrum wallets, which run no local Core or enforcer, get their read data from a remote server instead).
Read-only only: writes/broadcast/signing and crypto primitives are NOT here.
Index ¶
- type BitcoindGetter
- type ChainReader
- type CoreSource
- func (c *CoreSource) Block(ctx context.Context, req *corepb.GetBlockRequest) (*corepb.GetBlockResponse, error)
- func (c *CoreSource) BlockHash(ctx context.Context, req *corepb.GetBlockHashRequest) (*corepb.GetBlockHashResponse, error)
- func (c *CoreSource) BlockchainInfo(ctx context.Context, req *corepb.GetBlockchainInfoRequest) (*corepb.GetBlockchainInfoResponse, error)
- func (c *CoreSource) EstimateSmartFee(ctx context.Context, req *corepb.EstimateSmartFeeRequest) (*corepb.EstimateSmartFeeResponse, error)
- func (c *CoreSource) ListUnspent(ctx context.Context, req *corepb.ListUnspentRequest) (*corepb.ListUnspentResponse, error)
- func (c *CoreSource) ListWalletTransactions(ctx context.Context, req *corepb.ListTransactionsRequest) (*corepb.ListTransactionsResponse, error)
- func (c *CoreSource) ListWallets(ctx context.Context, req *emptypb.Empty) (*corepb.ListWalletsResponse, error)
- func (c *CoreSource) NetTotals(ctx context.Context, req *corepb.GetNetTotalsRequest) (*corepb.GetNetTotalsResponse, error)
- func (c *CoreSource) NetworkInfo(ctx context.Context, req *corepb.GetNetworkInfoRequest) (*corepb.GetNetworkInfoResponse, error)
- func (c *CoreSource) PeerInfo(ctx context.Context, req *corepb.GetPeerInfoRequest) (*corepb.GetPeerInfoResponse, error)
- func (c *CoreSource) RawMempool(ctx context.Context, req *corepb.GetRawMempoolRequest) (*corepb.GetRawMempoolResponse, error)
- func (c *CoreSource) RawTransaction(ctx context.Context, req *corepb.GetRawTransactionRequest) (*corepb.GetRawTransactionResponse, error)
- type DataSource
- type DrivechainReader
- type EnforcerSource
- func (e *EnforcerSource) Balance(ctx context.Context, req *v1.GetBalanceRequest) (*v1.GetBalanceResponse, error)
- func (e *EnforcerSource) BlockHeaderInfo(ctx context.Context, req *v1.GetBlockHeaderInfoRequest) (*v1.GetBlockHeaderInfoResponse, error)
- func (e *EnforcerSource) BlockInfo(ctx context.Context, req *v1.GetBlockInfoRequest) (*v1.GetBlockInfoResponse, error)
- func (e *EnforcerSource) BmmHStarCommitment(ctx context.Context, req *v1.GetBmmHStarCommitmentRequest) (*v1.GetBmmHStarCommitmentResponse, error)
- func (e *EnforcerSource) ChainInfo(ctx context.Context, req *v1.GetChainInfoRequest) (*v1.GetChainInfoResponse, error)
- func (e *EnforcerSource) ChainTip(ctx context.Context, req *v1.GetChainTipRequest) (*v1.GetChainTipResponse, error)
- func (e *EnforcerSource) Ctip(ctx context.Context, req *v1.GetCtipRequest) (*v1.GetCtipResponse, error)
- func (e *EnforcerSource) ListSidechainDeposits(ctx context.Context, req *v1.ListSidechainDepositTransactionsRequest) (*v1.ListSidechainDepositTransactionsResponse, error)
- func (e *EnforcerSource) ListTransactions(ctx context.Context, req *v1.ListTransactionsRequest) (*v1.ListTransactionsResponse, error)
- func (e *EnforcerSource) ListUnspentOutputs(ctx context.Context, req *v1.ListUnspentOutputsRequest) (*v1.ListUnspentOutputsResponse, error)
- func (e *EnforcerSource) SidechainProposals(ctx context.Context, req *v1.GetSidechainProposalsRequest) (*v1.GetSidechainProposalsResponse, error)
- func (e *EnforcerSource) Sidechains(ctx context.Context, req *v1.GetSidechainsRequest) (*v1.GetSidechainsResponse, error)
- func (e *EnforcerSource) TwoWayPegData(ctx context.Context, req *v1.GetTwoWayPegDataRequest) (*v1.GetTwoWayPegDataResponse, error)
- func (e *EnforcerSource) WalletInfo(ctx context.Context, req *v1.GetInfoRequest) (*v1.GetInfoResponse, error)
- type EnforcerWalletReader
- type Local
- type ValidatorGetter
- type WalletGetter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BitcoindGetter ¶
type BitcoindGetter func(context.Context) (bitcoindv1alphaconnect.BitcoinServiceClient, error)
BitcoindGetter lazily resolves the Core Connect client.
type ChainReader ¶
type ChainReader interface {
BlockchainInfo(context.Context, *corepb.GetBlockchainInfoRequest) (*corepb.GetBlockchainInfoResponse, error)
BlockHash(context.Context, *corepb.GetBlockHashRequest) (*corepb.GetBlockHashResponse, error)
Block(context.Context, *corepb.GetBlockRequest) (*corepb.GetBlockResponse, error)
RawMempool(context.Context, *corepb.GetRawMempoolRequest) (*corepb.GetRawMempoolResponse, error)
RawTransaction(context.Context, *corepb.GetRawTransactionRequest) (*corepb.GetRawTransactionResponse, error)
NetworkInfo(context.Context, *corepb.GetNetworkInfoRequest) (*corepb.GetNetworkInfoResponse, error)
NetTotals(context.Context, *corepb.GetNetTotalsRequest) (*corepb.GetNetTotalsResponse, error)
PeerInfo(context.Context, *corepb.GetPeerInfoRequest) (*corepb.GetPeerInfoResponse, error)
EstimateSmartFee(context.Context, *corepb.EstimateSmartFeeRequest) (*corepb.EstimateSmartFeeResponse, error)
ListWallets(context.Context, *emptypb.Empty) (*corepb.ListWalletsResponse, error)
ListUnspent(context.Context, *corepb.ListUnspentRequest) (*corepb.ListUnspentResponse, error)
// ListWalletTransactions is Core's wallet tx history (listtransactions).
// Named to disambiguate from EnforcerWalletReader.ListTransactions.
ListWalletTransactions(context.Context, *corepb.ListTransactionsRequest) (*corepb.ListTransactionsResponse, error)
}
ChainReader is the read-only Bitcoin Core surface. It returns the btc-buf corepb messages bitwindow already consumes, so migrating a handler is a pure extraction (drop the service.Get + connect wrappers). A future remote impl serves the same messages.
type CoreSource ¶
type CoreSource struct {
// contains filtered or unexported fields
}
CoreSource implements ChainReader against the live Core Connect client.
func NewCoreSource ¶
func NewCoreSource(bitcoind BitcoindGetter) *CoreSource
NewCoreSource builds the local Core-backed reader from a client getter.
func (*CoreSource) Block ¶
func (c *CoreSource) Block(ctx context.Context, req *corepb.GetBlockRequest) (*corepb.GetBlockResponse, error)
func (*CoreSource) BlockHash ¶
func (c *CoreSource) BlockHash(ctx context.Context, req *corepb.GetBlockHashRequest) (*corepb.GetBlockHashResponse, error)
func (*CoreSource) BlockchainInfo ¶
func (c *CoreSource) BlockchainInfo(ctx context.Context, req *corepb.GetBlockchainInfoRequest) (*corepb.GetBlockchainInfoResponse, error)
func (*CoreSource) EstimateSmartFee ¶
func (c *CoreSource) EstimateSmartFee(ctx context.Context, req *corepb.EstimateSmartFeeRequest) (*corepb.EstimateSmartFeeResponse, error)
func (*CoreSource) ListUnspent ¶
func (c *CoreSource) ListUnspent(ctx context.Context, req *corepb.ListUnspentRequest) (*corepb.ListUnspentResponse, error)
func (*CoreSource) ListWalletTransactions ¶
func (c *CoreSource) ListWalletTransactions(ctx context.Context, req *corepb.ListTransactionsRequest) (*corepb.ListTransactionsResponse, error)
func (*CoreSource) ListWallets ¶
func (c *CoreSource) ListWallets(ctx context.Context, req *emptypb.Empty) (*corepb.ListWalletsResponse, error)
func (*CoreSource) NetTotals ¶
func (c *CoreSource) NetTotals(ctx context.Context, req *corepb.GetNetTotalsRequest) (*corepb.GetNetTotalsResponse, error)
func (*CoreSource) NetworkInfo ¶
func (c *CoreSource) NetworkInfo(ctx context.Context, req *corepb.GetNetworkInfoRequest) (*corepb.GetNetworkInfoResponse, error)
func (*CoreSource) PeerInfo ¶
func (c *CoreSource) PeerInfo(ctx context.Context, req *corepb.GetPeerInfoRequest) (*corepb.GetPeerInfoResponse, error)
func (*CoreSource) RawMempool ¶
func (c *CoreSource) RawMempool(ctx context.Context, req *corepb.GetRawMempoolRequest) (*corepb.GetRawMempoolResponse, error)
func (*CoreSource) RawTransaction ¶
func (c *CoreSource) RawTransaction(ctx context.Context, req *corepb.GetRawTransactionRequest) (*corepb.GetRawTransactionResponse, error)
type DataSource ¶
type DataSource interface {
DrivechainReader
EnforcerWalletReader
ChainReader
}
DataSource is the full read-only surface: mainchain/enforcer reads plus Bitcoin Core chain reads. It is composed of segregated readers so callers can depend only on what they use, and so the Core reader (whose backing client differs between services) can be supplied independently.
type DrivechainReader ¶
type DrivechainReader interface {
ChainTip(context.Context, *v1.GetChainTipRequest) (*v1.GetChainTipResponse, error)
ChainInfo(context.Context, *v1.GetChainInfoRequest) (*v1.GetChainInfoResponse, error)
BlockHeaderInfo(context.Context, *v1.GetBlockHeaderInfoRequest) (*v1.GetBlockHeaderInfoResponse, error)
BlockInfo(context.Context, *v1.GetBlockInfoRequest) (*v1.GetBlockInfoResponse, error)
Sidechains(context.Context, *v1.GetSidechainsRequest) (*v1.GetSidechainsResponse, error)
SidechainProposals(context.Context, *v1.GetSidechainProposalsRequest) (*v1.GetSidechainProposalsResponse, error)
TwoWayPegData(context.Context, *v1.GetTwoWayPegDataRequest) (*v1.GetTwoWayPegDataResponse, error)
Ctip(context.Context, *v1.GetCtipRequest) (*v1.GetCtipResponse, error)
BmmHStarCommitment(context.Context, *v1.GetBmmHStarCommitmentRequest) (*v1.GetBmmHStarCommitmentResponse, error)
}
DrivechainReader is the read-only enforcer ValidatorService surface — chain tip/headers, sidechains, proposals, two-way-peg data. Returns the shared cusf.mainchain.v1 proto messages (both services already speak them), so the local impl is a thin unwrap of the Connect client.
type EnforcerSource ¶
type EnforcerSource struct {
// contains filtered or unexported fields
}
EnforcerSource implements DrivechainReader + EnforcerWalletReader against the live enforcer Connect clients. Shared by both services — they hold the same client types.
func NewEnforcerSource ¶
func NewEnforcerSource(validator ValidatorGetter, wallet WalletGetter) *EnforcerSource
NewEnforcerSource builds the local enforcer-backed reader from client getters.
func (*EnforcerSource) Balance ¶
func (e *EnforcerSource) Balance(ctx context.Context, req *v1.GetBalanceRequest) (*v1.GetBalanceResponse, error)
func (*EnforcerSource) BlockHeaderInfo ¶
func (e *EnforcerSource) BlockHeaderInfo(ctx context.Context, req *v1.GetBlockHeaderInfoRequest) (*v1.GetBlockHeaderInfoResponse, error)
func (*EnforcerSource) BlockInfo ¶
func (e *EnforcerSource) BlockInfo(ctx context.Context, req *v1.GetBlockInfoRequest) (*v1.GetBlockInfoResponse, error)
func (*EnforcerSource) BmmHStarCommitment ¶
func (e *EnforcerSource) BmmHStarCommitment(ctx context.Context, req *v1.GetBmmHStarCommitmentRequest) (*v1.GetBmmHStarCommitmentResponse, error)
func (*EnforcerSource) ChainInfo ¶
func (e *EnforcerSource) ChainInfo(ctx context.Context, req *v1.GetChainInfoRequest) (*v1.GetChainInfoResponse, error)
func (*EnforcerSource) ChainTip ¶
func (e *EnforcerSource) ChainTip(ctx context.Context, req *v1.GetChainTipRequest) (*v1.GetChainTipResponse, error)
func (*EnforcerSource) Ctip ¶
func (e *EnforcerSource) Ctip(ctx context.Context, req *v1.GetCtipRequest) (*v1.GetCtipResponse, error)
func (*EnforcerSource) ListSidechainDeposits ¶
func (e *EnforcerSource) ListSidechainDeposits(ctx context.Context, req *v1.ListSidechainDepositTransactionsRequest) (*v1.ListSidechainDepositTransactionsResponse, error)
func (*EnforcerSource) ListTransactions ¶
func (e *EnforcerSource) ListTransactions(ctx context.Context, req *v1.ListTransactionsRequest) (*v1.ListTransactionsResponse, error)
func (*EnforcerSource) ListUnspentOutputs ¶
func (e *EnforcerSource) ListUnspentOutputs(ctx context.Context, req *v1.ListUnspentOutputsRequest) (*v1.ListUnspentOutputsResponse, error)
func (*EnforcerSource) SidechainProposals ¶
func (e *EnforcerSource) SidechainProposals(ctx context.Context, req *v1.GetSidechainProposalsRequest) (*v1.GetSidechainProposalsResponse, error)
func (*EnforcerSource) Sidechains ¶
func (e *EnforcerSource) Sidechains(ctx context.Context, req *v1.GetSidechainsRequest) (*v1.GetSidechainsResponse, error)
func (*EnforcerSource) TwoWayPegData ¶
func (e *EnforcerSource) TwoWayPegData(ctx context.Context, req *v1.GetTwoWayPegDataRequest) (*v1.GetTwoWayPegDataResponse, error)
func (*EnforcerSource) WalletInfo ¶
func (e *EnforcerSource) WalletInfo(ctx context.Context, req *v1.GetInfoRequest) (*v1.GetInfoResponse, error)
type EnforcerWalletReader ¶
type EnforcerWalletReader interface {
Balance(context.Context, *v1.GetBalanceRequest) (*v1.GetBalanceResponse, error)
WalletInfo(context.Context, *v1.GetInfoRequest) (*v1.GetInfoResponse, error)
ListTransactions(context.Context, *v1.ListTransactionsRequest) (*v1.ListTransactionsResponse, error)
ListSidechainDeposits(context.Context, *v1.ListSidechainDepositTransactionsRequest) (*v1.ListSidechainDepositTransactionsResponse, error)
ListUnspentOutputs(context.Context, *v1.ListUnspentOutputsRequest) (*v1.ListUnspentOutputsResponse, error)
}
EnforcerWalletReader is the read-only enforcer WalletService surface.
type Local ¶
type Local struct {
*CoreSource
*EnforcerSource
}
Local is the full DataSource backed by live Core + enforcer clients. Composes the Core and enforcer readers; this is what the getters return today.
func NewLocal ¶
func NewLocal(bitcoind BitcoindGetter, validator ValidatorGetter, wallet WalletGetter) *Local
NewLocal builds the full local DataSource from the three client getters.
type ValidatorGetter ¶
type ValidatorGetter func(context.Context) (mainchainv1connect.ValidatorServiceClient, error)
Getter lazily resolves a Connect client, mirroring bitwindow's service.Service[T].Get — we take a func rather than the concrete type so the datasource package (in the orchestrator module) doesn't import bitwindow.
type WalletGetter ¶
type WalletGetter func(context.Context) (mainchainv1connect.WalletServiceClient, error)