@Override
public long getId() {
if (id == 0) {
if (signature == null && type.isSigned()) {
throw new IllegalStateException("Transaction is not signed yet");
}
byte[] hash;
if (useNQT()) {
byte[] data = zeroSignature(getBytes());
byte[] signatureHash = Crypto.sha256().digest(signature != null ? signature : new byte[64]);
MessageDigest digest = Crypto.sha256();
digest.update(data);
hash = digest.digest(signatureHash);
} else {
hash = Crypto.sha256().digest(getBytes());
}
BigInteger bigInteger = new BigInteger(1, new byte[] {hash[7], hash[6], hash[5], hash[4], hash[3], hash[2], hash[1], hash[0]});
id = bigInteger.longValue();
stringId = bigInteger.toString();
fullHash = Convert.toHexString(hash);
}
return id;
}