@Override public String toString() { return toString(null); }
@Override public String toString() { return toString(null); }
@Override public String toString() { return toString(null); }
@Override public String toString() { return toString(null); }
/** * Creates a transaction by reading payload starting from offset bytes in. Length of a transaction is fixed. */ /*public TransactionLockRequest(NetworkParameters params, byte[] payload, @Nullable Message parent, boolean parseLazy, boolean parseRetain, int length) throws ProtocolException { super(params, payload, 0, parent, parseLazy, parseRetain, length); }*/ public String toString(@Nullable AbstractBlockChain chain) { return "Transaction Lock Request:\n" + super.toString(chain); }
/** * A human readable version of the transaction useful for debugging. The format is not guaranteed to be stable. * @param chain If provided, will be used to estimate lock times (if set). Can be null. */ public String toString(@Nullable AbstractBlockChain chain) { return transaction.toString(chain); }
@Override public String toString() { final String newline = String.format(Locale.US, "%n"); final String closeStr = close == null ? "still open" : close.toString().replaceAll(newline, newline + " "); return String.format(Locale.US, "Stored client channel for server ID %s (%s)%n" + " Version: %d%n" + " Key: %s%n" + " Server key: %s%n" + " Value left: %s%n" + " Refund fees: %s%n" + " Expiry : %s%n" + " Contract: %s" + "Refund: %s" + "Close: %s", id, active ? "active" : "inactive", majorVersion, myKey, serverKey, valueToMe, refundFees, expiryTime, contract.toString().replaceAll(newline, newline + " "), refund.toString().replaceAll(newline, newline + " "), closeStr); } }
@Override public String toString() { final String newline = String.format(Locale.US, "%n"); final String closeStr = close == null ? "still open" : close.toString().replaceAll(newline, newline + " "); return String.format(Locale.US, "Stored client channel for server ID %s (%s)%n" + " Version: %d%n" + " Key: %s%n" + " Server key: %s%n" + " Value left: %s%n" + " Refund fees: %s%n" + " Expiry : %s%n" + " Contract: %s" + "Refund: %s" + "Close: %s", id, active ? "active" : "inactive", majorVersion, myKey, serverKey, valueToMe, refundFees, expiryTime, contract.toString().replaceAll(newline, newline + " "), refund.toString().replaceAll(newline, newline + " "), closeStr); } }
@Override public synchronized String toString() { final String newline = String.format(Locale.US, "%n"); return String.format(Locale.US, "Stored server channel (%s)%n" + " Version: %d%n" + " Key: %s%n" + " Value to me: %s%n" + " Client output: %s%n" + " Refund unlock: %s (%d unix time)%n" + " Contract: %s%n", connectedHandler != null ? "connected" : "disconnected", majorVersion, myKey, bestValueToMe, clientOutput, new Date(refundTransactionUnlockTimeSecs * 1000), refundTransactionUnlockTimeSecs, contract.toString().replaceAll(newline, newline + " ")); } }
@Override public synchronized String toString() { final String newline = String.format(Locale.US, "%n"); return String.format(Locale.US, "Stored server channel (%s)%n" + " Version: %d%n" + " Key: %s%n" + " Value to me: %s%n" + " Client output: %s%n" + " Refund unlock: %s (%d unix time)%n" + " Contract: %s%n", connectedHandler != null ? "connected" : "disconnected", majorVersion, myKey, bestValueToMe, clientOutput, new Date(refundTransactionUnlockTimeSecs * 1000), refundTransactionUnlockTimeSecs, contract.toString().replaceAll(newline, newline + " ")); } }
@Override public String toString() { final String newline = String.format(Locale.US, "%n"); final String closeStr = close == null ? "still open" : close.toString().replaceAll(newline, newline + " "); return String.format(Locale.US, "Stored client channel for server ID %s (%s)%n" + " Version: %d%n" + " Key: %s%n" + " Server key: %s%n" + " Value left: %s%n" + " Refund fees: %s%n" + " Expiry : %s%n" + " Contract: %s" + "Refund: %s" + "Close: %s", id, active ? "active" : "inactive", majorVersion, myKey, serverKey, valueToMe, refundFees, expiryTime, contract.toString().replaceAll(newline, newline + " "), refund.toString().replaceAll(newline, newline + " "), closeStr); } }
@Override public synchronized String toString() { final String newline = String.format(Locale.US, "%n"); return String.format(Locale.US, "Stored server channel (%s)%n" + " Version: %d%n" + " Key: %s%n" + " Value to me: %s%n" + " Client output: %s%n" + " Refund unlock: %s (%d unix time)%n" + " Contract: %s%n", connectedHandler != null ? "connected" : "disconnected", majorVersion, myKey, bestValueToMe, clientOutput, new Date(refundTransactionUnlockTimeSecs * 1000), refundTransactionUnlockTimeSecs, contract.toString().replaceAll(newline, newline + " ")); } }
@Override public String toString() { final String newline = String.format(Locale.US, "%n"); final String closeStr = close == null ? "still open" : close.toString().replaceAll(newline, newline + " "); return String.format(Locale.US, "Stored client channel for server ID %s (%s)%n" + " Version: %d%n" + " Key: %s%n" + " Server key: %s%n" + " Value left: %s%n" + " Refund fees: %s%n" + " Expiry : %s%n" + " Contract: %s" + "Refund: %s" + "Close: %s", id, active ? "active" : "inactive", majorVersion, myKey, serverKey, valueToMe, refundFees, expiryTime, contract.toString().replaceAll(newline, newline + " "), refund.toString().replaceAll(newline, newline + " "), closeStr); } }
@Override public synchronized String toString() { final String newline = String.format(Locale.US, "%n"); return String.format(Locale.US, "Stored server channel (%s)%n" + " Version: %d%n" + " Key: %s%n" + " Value to me: %s%n" + " Client output: %s%n" + " Refund unlock: %s (%d unix time)%n" + " Contract: %s%n", connectedHandler != null ? "connected" : "disconnected", majorVersion, myKey, bestValueToMe, clientOutput, new Date(refundTransactionUnlockTimeSecs * 1000), refundTransactionUnlockTimeSecs, contract.toString().replaceAll(newline, newline + " ")); } }
@Override public synchronized void onCoinsReceived(Wallet w, Transaction tx, Coin prevBalance, Coin newBalance) { System.out.println("\nReceived tx " + tx.getHashAsString()); System.out.println(tx.toString()); } });
private void toStringHelper(StringBuilder builder, Map<Sha256Hash, Transaction> transactionMap, @Nullable AbstractBlockChain chain, @Nullable Comparator<Transaction> sortOrder) { checkState(lock.isHeldByCurrentThread()); final Collection<Transaction> txns; if (sortOrder != null) { txns = new TreeSet<>(sortOrder); txns.addAll(transactionMap.values()); } else { txns = transactionMap.values(); } for (Transaction tx : txns) { try { builder.append(tx.getValue(this).toFriendlyString()); builder.append(" total value (sends "); builder.append(tx.getValueSentFromMe(this).toFriendlyString()); builder.append(" and receives "); builder.append(tx.getValueSentToMe(this).toFriendlyString()); builder.append(")\n"); } catch (ScriptException e) { // Ignore and don't print this line. } if (tx.hasConfidence()) builder.append(" confidence: ").append(tx.getConfidence()).append('\n'); builder.append(tx.toString(chain)); } }
@Test public void testToStringWhenThereAreZeroInputs() { Transaction tx = new Transaction(PARAMS); assertEquals(tx.toString().contains("No inputs!"), true); }
@Test public void testToStringWhenLockTimeIsSpecifiedInBlockHeight() { Transaction tx = FakeTxBuilder.createFakeTx(PARAMS); TransactionInput input = tx.getInput(0); input.setSequenceNumber(42); int TEST_LOCK_TIME = 20; tx.setLockTime(TEST_LOCK_TIME); Calendar cal = Calendar.getInstance(); cal.set(2085, 10, 4, 17, 53, 21); cal.set(Calendar.MILLISECOND, 0); BlockChain mockBlockChain = createMock(BlockChain.class); EasyMock.expect(mockBlockChain.estimateBlockTime(TEST_LOCK_TIME)).andReturn(cal.getTime()); replay(mockBlockChain); String str = tx.toString(mockBlockChain); assertEquals(str.contains("block " + TEST_LOCK_TIME), true); assertEquals(str.contains("estimated to be reached at"), true); }
@Test public void testToStringWhenIteratingOverAnInputCatchesAnException() { Transaction tx = FakeTxBuilder.createFakeTx(PARAMS); TransactionInput ti = new TransactionInput(PARAMS, tx, new byte[0]) { @Override public Script getScriptSig() throws ScriptException { throw new ScriptException(""); } }; tx.addInput(ti); assertEquals(tx.toString().contains("[exception: "), true); }
@Test public void pubkeyOnlyScripts() throws Exception { // Verify that we support outputs like OP_PUBKEY and the corresponding inputs. ECKey key1 = wallet.freshReceiveKey(); Coin value = valueOf(5, 0); Transaction t1 = createFakeTx(PARAMS, value, key1); if (wallet.isPendingTransactionRelevant(t1)) wallet.receivePending(t1, null); // TX should have been seen as relevant. assertEquals(value, wallet.getBalance(Wallet.BalanceType.ESTIMATED)); assertEquals(ZERO, wallet.getBalance(Wallet.BalanceType.AVAILABLE)); sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, t1); // TX should have been seen as relevant, extracted and processed. assertEquals(value, wallet.getBalance(Wallet.BalanceType.AVAILABLE)); // Spend it and ensure we can spend the <key> OP_CHECKSIG output correctly. Transaction t2 = wallet.createSend(OTHER_ADDRESS, value); assertNotNull(t2); // TODO: This code is messy, improve the Script class and fixinate! assertEquals(t2.toString(), 1, t2.getInputs().get(0).getScriptSig().getChunks().size()); assertTrue(t2.getInputs().get(0).getScriptSig().getChunks().get(0).data.length > 50); }