Implement eth parser GetAddrIDFromAddress

This commit is contained in:
Martin Boehm 2018-03-26 18:08:46 +02:00
parent 09a9e623c1
commit 3169446adb

View File

@ -1,40 +1,49 @@
package eth package eth
import "blockbook/bchain" import (
"blockbook/bchain"
"errors"
ethcommon "github.com/ethereum/go-ethereum/common"
)
type EthParser struct { type EthParser struct {
} }
func (p *EthParser) GetAddrIDFromVout(output *bchain.Vout) ([]byte, error) { func (p *EthParser) GetAddrIDFromVout(output *bchain.Vout) ([]byte, error) {
panic("not implemented") if len(output.ScriptPubKey.Addresses) != 1 {
return nil, nil
}
return p.GetAddrIDFromAddress(output.ScriptPubKey.Addresses[0])
} }
func (p *EthParser) GetAddrIDFromAddress(address string) ([]byte, error) { func (p *EthParser) GetAddrIDFromAddress(address string) ([]byte, error) {
panic("not implemented") a := ethcommon.HexToAddress(address)
return a.Bytes(), nil
} }
func (p *EthParser) AddressToOutputScript(address string) ([]byte, error) { func (p *EthParser) AddressToOutputScript(address string) ([]byte, error) {
panic("not implemented") return nil, errors.New("AddressToOutputScript: not implemented")
} }
func (p *EthParser) OutputScriptToAddresses(script []byte) ([]string, error) { func (p *EthParser) OutputScriptToAddresses(script []byte) ([]string, error) {
panic("not implemented") return nil, errors.New("OutputScriptToAddresses: not implemented")
} }
func (p *EthParser) ParseTx(b []byte) (*bchain.Tx, error) { func (p *EthParser) ParseTx(b []byte) (*bchain.Tx, error) {
panic("not implemented") return nil, errors.New("ParseTx: not implemented")
} }
func (p *EthParser) ParseBlock(b []byte) (*bchain.Block, error) { func (p *EthParser) ParseBlock(b []byte) (*bchain.Block, error) {
panic("not implemented") return nil, errors.New("ParseBlock: not implemented")
} }
func (p *EthParser) PackTx(tx *bchain.Tx, height uint32, blockTime int64) ([]byte, error) { func (p *EthParser) PackTx(tx *bchain.Tx, height uint32, blockTime int64) ([]byte, error) {
panic("not implemented") return nil, errors.New("PackTx: not implemented")
} }
func (p *EthParser) UnpackTx(buf []byte) (*bchain.Tx, uint32, error) { func (p *EthParser) UnpackTx(buf []byte) (*bchain.Tx, uint32, error) {
panic("not implemented") return nil, 0, errors.New("UnpackTx: not implemented")
} }
func (p *EthParser) IsUTXOChain() bool { func (p *EthParser) IsUTXOChain() bool {