diff --git a/chain/interface.go b/chain/interface.go index 3039445..1608d4d 100644 --- a/chain/interface.go +++ b/chain/interface.go @@ -20,6 +20,7 @@ type Interface interface { GetBestBlock() (*chainhash.Hash, int32, error) GetBlock(*chainhash.Hash) (*wire.MsgBlock, error) GetBlockHash(int64) (*chainhash.Hash, error) + GetBlockHeader(*chainhash.Hash) (*wire.BlockHeader, error) BlockStamp() (*waddrmgr.BlockStamp, error) SendRawTransaction(*wire.MsgTx, bool) (*chainhash.Hash, error) Rescan(*chainhash.Hash, []btcutil.Address, []*wire.OutPoint) error diff --git a/chain/neutrino.go b/chain/neutrino.go index 373e301..b77c665 100644 --- a/chain/neutrino.go +++ b/chain/neutrino.go @@ -143,6 +143,14 @@ func (s *NeutrinoClient) GetBlockHash(height int64) (*chainhash.Hash, error) { return &hash, nil } +// GetBlockHeader returns the block header for the given block hash, or an error +// if the client has been shut down or the hash doesn't exist or is unknown. +func (s *NeutrinoClient) GetBlockHeader( + blockHash *chainhash.Hash) (*wire.BlockHeader, error) { + header, _, err := s.CS.BlockHeaders.FetchHeader(blockHash) + return header, err +} + // SendRawTransaction replicates the RPC client's SendRawTransaction command. func (s *NeutrinoClient) SendRawTransaction(tx *wire.MsgTx, allowHighFees bool) ( *chainhash.Hash, error) {