OSDN Git Service

move code
authoroys <oys@oysdeMBP.localdomain>
Wed, 10 Jul 2019 02:49:54 +0000 (10:49 +0800)
committeroys <oys@oysdeMBP.localdomain>
Wed, 10 Jul 2019 02:49:54 +0000 (10:49 +0800)
common/address.go
consensus/general.go

index a5162e4..9888d08 100644 (file)
@@ -116,7 +116,7 @@ func DecodeAddress(addr string, param *consensus.Params) (Address, error) {
        oneIndex := strings.LastIndexByte(addr, '1')
        if oneIndex > 1 {
                prefix := addr[:oneIndex+1]
-               if consensus.IsBech32SegwitPrefix(prefix, param) {
+               if strings.ToLower(prefix) == param.Bech32HRPSegwit+"1" {
                        witnessVer, witnessProg, err := decodeSegWitAddress(addr)
                        if err != nil {
                                return nil, err
index 4c77582..fee177c 100644 (file)
@@ -2,7 +2,6 @@ package consensus
 
 import (
        "encoding/binary"
-       "strings"
 
        "github.com/vapor/protocol/bc"
 )
@@ -195,11 +194,3 @@ func BlockSubsidy(height uint64) uint64 {
        }
        return 0
 }
-
-// IsBech32SegwitPrefix returns whether the prefix is a known prefix for segwit
-// addresses on any default or registered network.  This is used when decoding
-// an address string into a specific address type.
-func IsBech32SegwitPrefix(prefix string, params *Params) bool {
-       prefix = strings.ToLower(prefix)
-       return prefix == params.Bech32HRPSegwit+"1"
-}