Base58

將 BTC 地址列表(base58)轉換為 Ripemd16(base16)

  • December 24, 2017

是否有可以同時將多個 base58(BTC 地址)轉換為 base16 的線上工具或儲存庫?

在 Go 中,你可以很容易地做到這一點:

package main

import (
   "fmt"

   "github.com/btcsuite/btcutil/base58"
)

var addresses = []string{
   "1Nh7uHdvY6fNwtQtM1G5EZAFPLC33B59rB",
   "1Le1ttNd2GQ79212Epyciw39JDy2E6DYWf",
   "1LpRieyPAZfFyUSMGiZhwAarQoJw1Y8pEx",
}

func main() {
   for _, address := range addresses {
       ripemd160, _, err := base58.CheckDecode(address)
       if err != nil {
           fmt.Printf("Failed to decode address %s: %s\n", address, err)
           continue
       }

       fmt.Printf("HASH160 %x from address %s\n", ripemd160, address)
   }
}

安裝 Go 後,您可以在終端中輕鬆執行此程式碼:

$ go get github.com/btcsuite/btcutil/base58
$ go run thefile.go
HASH160 edf10a7fac6b32e24daa5305c723f3de58db1bc8 from address 1Nh7uHdvY6fNwtQtM1G5EZAFPLC33B59rB
HASH160 d76a86f903b33835f06d7b18a1429a8f249f3ab1 from address 1Le1ttNd2GQ79212Epyciw39JDy2E6DYWf
HASH160 d96292e45d045d2269a818b96b13422555557d85 from address 1LpRieyPAZfFyUSMGiZhwAarQoJw1Y8pEx
static const QByteArray convert ( const QLatin1String& buf )
{
 QByteArray ret;
 ret.resize ( 20 );
 quint8 addr [30];
 BASE58::decodeBase58 ( buf.latin1 ( ), addr, 26, true );
 memcpy ( ret.data ( ), addr + 1, 20 );
//printf ( "%s\n", ret.toHex ( ).constData ( ) );
 return ret.toHex ( );
}

哎呀,對不起。如果您正在尋找線上解決方案,這不是答案

引用自:https://bitcoin.stackexchange.com/questions/63202