btcAddress function
return a BTC Address
Implementation
String btcAddress(PublicKey pk) {
final pubkey = pk as ECPublicKey;
Digest sha256 = new Digest("SHA-256");
Digest ripemd = new RIPEMD160Digest();
final pub_bytes = pubkey.Q!.getEncoded(false);
final sha_hash = sha256.process(pub_bytes);
final rip_hash = ripemd.process(sha_hash);
// 生成验证
final network_hash = [0x00] + rip_hash.toList();
final check1 = sha256.process(Uint8List.fromList(network_hash));
final check2 = sha256.process(check1);
final final_check = check2.sublist(0, 4);
final code_list = network_hash + final_check;
Base58Encoder b58 = new Base58Encoder(
'123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz');
return b58.convert(code_list);
}