Documentation ¶
Overview ¶
Package gw provides ability to anchor BBc-1 transactions to the Bitcoin block chain, that hides the implementation of BTC (package btc) and Store (package store) from applications.
Index ¶
- Variables
- type Gateway
- type GatewayImpl
- func (g *GatewayImpl) Close() error
- func (g *GatewayImpl) GetRecord(ctx context.Context, domID, txID []byte) (*model.AnchorRecord, error)
- func (g *GatewayImpl) RefreshRecord(ctx context.Context, domID, txID []byte, pBBc1domName, pNote *string) error
- func (g *GatewayImpl) RegisterTransaction(ctx context.Context, domID, txID []byte) (btcTXID []byte, err error)
- func (g *GatewayImpl) StoreRecord(ctx context.Context, btcTXID []byte) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrCouldNotPutAnchor = errors.New("ErrCouldNotPutAnchor") ErrCouldNotStoreRecord = errors.New("ErrCouldNotStoreRecord") ErrCouldNotGetRecord = errors.New("ErrCouldNotGetRecord") ErrCouldNotRefreshRecord = errors.New("ErrCouldNotRefreshRecord") ErrCouldNotCloseStore = errors.New("ErrCouldNotCloseStore") )
Errors TODO: Handle more error types: e.g. ErrInvalidFee TODO: Provide more error types. e.g. ErrNoConfirmedUTXO
Functions ¶
This section is empty.
Types ¶
type Gateway ¶
type Gateway interface { // RegisterTransaction inserts an anchor into Bitcoin block chain // by sending a transaction, and returns its Bitcoin transaction ID. RegisterTransaction(ctx context.Context, domID, txID []byte) (btcTXID []byte, err error) // StoreRecord retrieves a Bitcoin transaction, // and saves its AnchorRecord embedded in OP_RETURN in the datastore. StoreRecord(ctx context.Context, btcTXID []byte) error // GetRecord gets an AnchorRecord // specified by the given information from the datastore. GetRecord(ctx context.Context, domID, txID []byte) (*model.AnchorRecord, error) // RefreshRecord update AnchorRecord specified by domID and txID. // Get it from datastore, update AnchorRecord.Confirmations by // retrieving and checking the Bitcoin transaction, and then put it into datastore. // In addition, changes AnchorRecord.BBc1DomainName or AnchorRecord.Note or both, if the given value is not nil. RefreshRecord(ctx context.Context, domID, txID []byte, pBBc1domName, pNote *string) error io.Closer }
Gateway provides features to register and verify BBc-1 transactions.
type GatewayImpl ¶
type GatewayImpl struct { BTCNet model.BTCNet BTC btc.BTC Wallet btc.Wallet Store store.Store // contains filtered or unexported fields }
func NewGatewayImpl ¶
NewGatewayImpl initializes a GatewayImpl.
Parameters:
- bn sets Bitcoin network to anchor.
- b sets btc.BTC.
- w sets btc.Wallet.
- s sets store.Store.
bn must be same as b.BTCNet. b must be *btc.BitcoinCLI for now.
func (*GatewayImpl) Close ¶
func (g *GatewayImpl) Close() error
Close closes g.Store. No need to close *btc.BitcoinCLI
func (*GatewayImpl) GetRecord ¶
func (g *GatewayImpl) GetRecord(ctx context.Context, domID, txID []byte) (*model.AnchorRecord, error)
func (*GatewayImpl) RefreshRecord ¶
func (*GatewayImpl) RegisterTransaction ¶
func (*GatewayImpl) StoreRecord ¶
func (g *GatewayImpl) StoreRecord(ctx context.Context, btcTXID []byte) error
Click to show internal directories.
Click to hide internal directories.