@Override public String toString() { return "data: " + Convert.toHexString(data) + " nonce: " + Convert.toHexString(nonce); }
BuilderImpl referencedTransactionFullHash(byte[] referencedTransactionFullHash) { if (referencedTransactionFullHash != null) { this.referencedTransactionFullHash = Convert.toHexString(referencedTransactionFullHash); } return this; }
BuilderImpl fullHash(byte[] fullHash) { if (fullHash != null) { this.fullHash = Convert.toHexString(fullHash); } return this; }
@Override public String getPublicKeySerialized() { return Convert.toHexString(getPublicKey()); }
@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; }
buffer.get(referencedTransactionFullHashBytes); if (Convert.emptyToNull(referencedTransactionFullHashBytes) != null) { referencedTransactionFullHash = Convert.toHexString(referencedTransactionFullHashBytes);
@Test public void testSerializeKeychainToProtobuf() throws UnreadableWalletException { List<Protos.Key> keys = nxtAccount.serializeKeychainToProtobuf(); NxtFamilyKey newKey = NxtFamilyKey.fromProtobuf(keys); NxtFamilyWallet newWallet = new NxtFamilyWallet(newKey, NXT); assertEquals(Convert.toHexString(nxtAccount.getPublicKey()), Convert.toHexString(newWallet.getPublicKey())); assertEquals(nxtAccount.getPublicKeyMnemonic(), newWallet.getPublicKeyMnemonic()); assertEquals(nxtAccount.getId(), newWallet.getId()); }
@Test public void testEncryptedNxtFamilyKey() throws UnreadableWalletException { nxtAccount.encrypt(crypter, aesKey); List<Protos.Key> keys = nxtAccount.serializeKeychainToProtobuf(); NxtFamilyKey newKey = NxtFamilyKey.fromProtobuf(keys, crypter); NxtFamilyWallet newWallet = new NxtFamilyWallet(newKey, NXT); assertEquals(Convert.toHexString(nxtAccount.getPublicKey()), Convert.toHexString(newWallet.getPublicKey())); assertEquals(nxtAccount.getPublicKeyMnemonic(), newWallet.getPublicKeyMnemonic()); assertEquals(nxtAccount.getId(), newWallet.getId()); } }
@Override public boolean broadcastTxSync(final NxtTransaction tx) { RequestBody formBody = new FormEncodingBuilder().add("requestType","broadcastTransaction") .add("transactionBytes", Convert.toHexString(tx.getRawTransaction().getBytes())).build(); Request request = new Request.Builder().url(getBaseUrl()).post(formBody).build(); // FIXME this is not a sync call getHttpClient().newCall(request).enqueue(new Callback() { @Override public void onFailure(Request request, IOException e) { log.info("Failed to communicate with server: " + request.toString()); } @Override public void onResponse(Response response) throws IOException { try { if (!response.isSuccessful()) { log.info("Unable to fetch txs."); log.info("[Error code] = " + response.code()); } JSONObject reply = parseReply(response); log.info("Transaction broadcasted {0}", reply.toString()); } catch (IOException e) { log.info("IOException: " + e.getMessage()); } catch (JSONException e) { log.info("Could not parse JSON: " + e.getMessage()); } } }); return true; }