argToAddress method
String
argToAddress(
- Uint8List hash, {
- String hashType = ckb.Script.Type,
- AddressType addressType = ckb.AddressType.SHORT,
})
Implementation
String argToAddress(Uint8List hash,
{String hashType = ckb.Script.Type,
ckb.AddressType addressType = ckb.AddressType.SHORT}) {
List<int> data = [];
switch (addressType) {
case ckb.AddressType.LONG:
data.add(0x00);
data.addAll(dynamicToUint8List(ckb.CKB_CODE_HASH));
data.add(ckb.hashTypeToCode(hashType));
data.addAll(hash);
final words = toUint5Array(data);
return bech32.encode(Bech32(CKB_PREFIX, words),
maxLength: ckb.MAX_LENGTH, encoding: 'bech32m');
case ckb.AddressType.SHORT:
data.add(0x01);
data.add(ckb.SHORT_ID);
data.addAll(hash);
final words = toUint5Array(data);
return bech32.encode(Bech32(CKB_PREFIX, words),
maxLength: ckb.MAX_LENGTH);
}
}