toAddress method
returns the address's string encoding
Implementation
String toAddress(NetworkInfo networkType, {Uint8List? h160}) {
Uint8List tobytes = h160 ?? hexToBytes(_h160);
switch (type) {
case AddressType.p2wpkhInP2sh:
case AddressType.p2wshInP2sh:
case AddressType.p2sh:
tobytes = Uint8List.fromList([networkType.p2shPrefix, ...tobytes]);
break;
case AddressType.p2pkh:
case AddressType.p2pk:
tobytes = Uint8List.fromList([networkType.p2pkhPrefix, ...tobytes]);
break;
default:
}
Uint8List hash = doubleHash(tobytes);
hash = Uint8List.fromList(
[tobytes, hash.sublist(0, 4)].expand((i) => i).toList(growable: false));
return bs58.base58.encode(hash);
}