impl NewAddressWitnessPubKeyHash in parser

pull/541/head
sidhujag 2020-09-02 20:07:17 -07:00
parent ac717bc464
commit 8e831ffb50
3 changed files with 15 additions and 3 deletions

View File

@ -365,6 +365,9 @@ func (p *BaseParser) GetAllocationFromTx(tx *Tx) (*AssetAllocation, error) {
func (p *BaseParser) LoadAssets(tx *Tx) error {
return errors.New("Not supported")
}
func (p *BaseParser) NewAddressWitnessPubKeyHash(keyId []byte) (string, error) {
return errors.New("Not supported")
}
func (p *BaseParser) AppendAssetInfo(assetInfo *AssetInfo, buf []byte, varBuf []byte) []byte {
return nil
}

View File

@ -12,6 +12,7 @@ import (
"github.com/martinboehm/btcutil/txscript"
vlq "github.com/bsm/go-vlq"
"github.com/juju/errors"
"github.com/martinboehm/btcutil"
)
// magic numbers
@ -303,6 +304,15 @@ func (p *SyscoinParser) LoadAssets(tx *bchain.Tx) error {
return nil
}
func (p *SyscoinParser) NewAddressWitnessPubKeyHash(keyId []byte) (string, error) {
addr, err := btcutil.NewAddressWitnessPubKeyHash(keyId, p.BitcoinParser.Params)
if err != nil {
return ""
}
return addr.EncodeAddress()
}
func (p *SyscoinParser) PackAssetKey(assetGuid uint32, height uint32) []byte {
var buf []byte
varBuf := p.BaseParser.PackUint(assetGuid)

View File

@ -20,7 +20,6 @@ import (
"strconv"
"strings"
"time"
"github.com/martinboehm/btcutil"
"github.com/golang/glog"
"encoding/base64"
)
@ -568,11 +567,11 @@ func formatPercentage(a string) string {
}
func (s *PublicServer) formatKeyID(a string) string {
addr, err := btcutil.NewAddressWitnessPubKeyHash([]byte(a), s.chainParser.Params)
addr, err := s.chainParser.WitnessPubKeyHashFromKeyID([]byte(a))
if err != nil {
return ""
}
return addr.EncodeAddress()
return addr
}
func isAssetUpdateCapabilityFlagsSet(td *TemplateData, f string, mask uint8) bool {