Add load address by serialized address descriptor
parent
d6de5b8048
commit
273b880245
|
@ -652,7 +652,12 @@ func (w *Worker) txFromTxid(txid string, bestheight uint32, option AccountDetail
|
|||
func (w *Worker) getAddrDescAndNormalizeAddress(address string) (bchain.AddressDescriptor, string, error) {
|
||||
addrDesc, err := w.chainParser.GetAddrDescFromAddress(address)
|
||||
if err != nil {
|
||||
return nil, "", NewAPIError(fmt.Sprintf("Invalid address, %v", err), true)
|
||||
var errAd error
|
||||
// try if the address is not address descriptor converted to string
|
||||
addrDesc, errAd = bchain.AddressDescriptorFromString(address)
|
||||
if errAd != nil {
|
||||
return nil, "", NewAPIError(fmt.Sprintf("Invalid address, %v", err), true)
|
||||
}
|
||||
}
|
||||
// convert the address to the format defined by the parser
|
||||
addresses, _, err := w.chainParser.GetAddressesFromAddrDesc(addrDesc)
|
||||
|
|
|
@ -168,6 +168,14 @@ func (ad AddressDescriptor) String() string {
|
|||
return "ad:" + hex.EncodeToString(ad)
|
||||
}
|
||||
|
||||
// AddressDescriptorFromString converts string created by AddressDescriptor.String to AddressDescriptor
|
||||
func AddressDescriptorFromString(s string) (AddressDescriptor, error) {
|
||||
if len(s) > 3 && s[0:3] == "ad:" {
|
||||
return hex.DecodeString(s[3:])
|
||||
}
|
||||
return nil, errors.New("Not AddressDescriptor")
|
||||
}
|
||||
|
||||
// EthereumType specific
|
||||
|
||||
// Erc20Contract contains info about ERC20 contract
|
||||
|
|
Loading…
Reference in New Issue