BTC 交易地址规则

 

一下代码是 Golang 判断是否是一个合法的 BTC 交易地址。


import "strings"

// 返回 true 为合法 BTC 交易地址
func IsValidBtcAddress(address string) bool {
    len := len(address)
    if len < 25 {
        return false
    }


    if strings.HasPrefix(address, "1") {
        if len >= 26 && len <= 34 {
            return true
        }
    }


    if strings.HasPrefix(address, "3") && len == 34 {
        return true
    }


    if strings.HasPrefix(address, "bc1") && len > 34 {
        return true
    }


    return false
}


相关文章:

  • 2021-12-26
  • 2021-12-26
  • 2021-12-26
  • 2022-12-23
  • 2021-12-26
  • 2021-07-03
  • 2021-08-13
猜你喜欢
  • 2021-12-26
  • 2021-12-26
  • 2021-12-26
  • 2021-12-26
  • 2021-12-26
  • 2021-12-26
相关资源
相似解决方案