Remove unnecessary methods from BlockChainParser interface
This commit is contained in:
parent
dda80bd074
commit
32a2c1a417
@ -33,22 +33,14 @@ func GetChainParams(chain string) *chaincfg.Params {
|
||||
return &chaincfg.MainNetParams
|
||||
}
|
||||
|
||||
func (p *BitcoinBlockParser) GetAddrIDFromVout(output *bchain.Vout) string {
|
||||
return output.ScriptPubKey.Hex
|
||||
func (p *BitcoinBlockParser) GetAddrIDFromVout(output *bchain.Vout) ([]byte, error) {
|
||||
return hex.DecodeString(output.ScriptPubKey.Hex)
|
||||
}
|
||||
|
||||
func (p *BitcoinBlockParser) GetAddrIDFromAddress(address string) ([]byte, error) {
|
||||
return p.AddressToOutputScript(address)
|
||||
}
|
||||
|
||||
func (p *BitcoinBlockParser) PackAddrID(str string) ([]byte, error) {
|
||||
return hex.DecodeString(str)
|
||||
}
|
||||
|
||||
func (p *BitcoinBlockParser) UnpackAddrID(buf []byte) string {
|
||||
return hex.EncodeToString(buf)
|
||||
}
|
||||
|
||||
// AddressToOutputScript converts bitcoin address to ScriptPubKey
|
||||
func (p *BitcoinBlockParser) AddressToOutputScript(address string) ([]byte, error) {
|
||||
da, err := btcutil.DecodeAddress(address, p.Params)
|
||||
|
||||
@ -26,21 +26,13 @@ func GetChainParams(chain string) *chaincfg.Params {
|
||||
return &chaincfg.MainNetParams
|
||||
}
|
||||
|
||||
func (p *ZCashBlockParser) GetAddrIDFromVout(output *bchain.Vout) string {
|
||||
func (p *ZCashBlockParser) GetAddrIDFromVout(output *bchain.Vout) ([]byte, error) {
|
||||
if len(output.ScriptPubKey.Addresses) != 1 {
|
||||
return ""
|
||||
return nil, nil
|
||||
}
|
||||
return output.ScriptPubKey.Addresses[0]
|
||||
return []byte(output.ScriptPubKey.Addresses[0]), nil
|
||||
}
|
||||
|
||||
func (p *ZCashBlockParser) GetAddrIDFromAddress(address string) ([]byte, error) {
|
||||
return p.PackAddrID(address)
|
||||
}
|
||||
|
||||
func (p *ZCashBlockParser) PackAddrID(str string) ([]byte, error) {
|
||||
return []byte(str), nil
|
||||
}
|
||||
|
||||
func (p *ZCashBlockParser) UnpackAddrID(buf []byte) string {
|
||||
return string(buf)
|
||||
return []byte(address), nil
|
||||
}
|
||||
|
||||
@ -117,10 +117,8 @@ type BlockChainParser interface {
|
||||
// non UTXO chains have mapping of address to input and output transactions directly in "outputs" column in db
|
||||
IsUTXOChain() bool
|
||||
// address id conversions
|
||||
GetAddrIDFromVout(output *Vout) string
|
||||
GetAddrIDFromVout(output *Vout) ([]byte, error)
|
||||
GetAddrIDFromAddress(address string) ([]byte, error)
|
||||
PackAddrID(addrID string) ([]byte, error)
|
||||
UnpackAddrID(buf []byte) string
|
||||
// address to output script conversions
|
||||
AddressToOutputScript(address string) ([]byte, error)
|
||||
OutputScriptToAddresses(script []byte) ([]string, error)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user