wotsAddressFromBytes static method
Creates a WotsAddress instance from a byte array. Handles different byte array lengths representing WOTS public key, address only, or address with amount. @param bytes The input byte array. @returns A new WotsAddress instance.
Implementation
static WotsAddress wotsAddressFromBytes(ByteArray bytes) {
final wots = WotsAddress();
if (bytes.length == WOTS_PK_LEN) {
final addr = addrFromWots(bytes);
if (addr != null) {
// Set the full address
wots.setTag(addr.sublist(0, ADDR_TAG_LEN));
wots.setAddrHash(addr.sublist(ADDR_TAG_LEN, TXADDRLEN));
}
} else if (bytes.length == TXADDRLEN) {
// Set the full address
wots.setTag(bytes.sublist(0, ADDR_TAG_LEN));
wots.setAddrHash(bytes.sublist(ADDR_TAG_LEN, TXADDRLEN));
} else if (bytes.length == TXADDRLEN + TXAMOUNT) {
// Set address and amount separately
wots.setTag(bytes.sublist(0, ADDR_TAG_LEN));
wots.setAddrHash(bytes.sublist(ADDR_TAG_LEN, TXADDRLEN));
wots.setAmountBytes(bytes.sublist(TXADDRLEN));
}
return wots;
}