/** * Get the depth withing the chain of the parent tx, depth is 1 if it the output height is the height of * the latest block. * @return The depth. */ @Override public int getParentTransactionDepthInBlocks() { return chainHeight - output.getHeight() + 1; }
/** * Get the depth withing the chain of the parent tx, depth is 1 if it the output height is the height of * the latest block. * @return The depth. */ @Override public int getParentTransactionDepthInBlocks() { return chainHeight - output.getHeight() + 1; }
/** * Get the depth withing the chain of the parent tx, depth is 1 if it the output height is the height of * the latest block. * @return The depth. */ @Override public int getParentTransactionDepthInBlocks() { return chainHeight - output.getHeight() + 1; }
/** * Get the depth withing the chain of the parent tx, depth is 1 if it the output height is the height of * the latest block. * @return The depth. */ @Override public int getParentTransactionDepthInBlocks() { return chainHeight - output.getHeight() + 1; }
@Override public void addUnspentTransactionOutput(UTXO out) throws BlockStoreException { maybeConnect(); PreparedStatement s = null; try { s = conn.get().prepareStatement(getInsertOpenoutputsSQL()); s.setBytes(1, out.getHash().getBytes()); // index is actually an unsigned int s.setInt(2, (int) out.getIndex()); s.setInt(3, out.getHeight()); s.setLong(4, out.getValue().value); s.setBytes(5, out.getScript().getProgram()); s.setString(6, out.getAddress()); s.setInt(7, out.getScript().getScriptType().ordinal()); s.setBoolean(8, out.isCoinbase()); s.executeUpdate(); s.close(); } catch (SQLException e) { if (!(e.getSQLState().equals(getDuplicateKeyErrorCode()))) throw new BlockStoreException(e); } finally { if (s != null) { try { s.close(); } catch (SQLException e) { throw new BlockStoreException(e); } } } }
@Override public void addUnspentTransactionOutput(UTXO out) throws BlockStoreException { maybeConnect(); PreparedStatement s = null; try { s = conn.get().prepareStatement(getInsertOpenoutputsSQL()); s.setBytes(1, out.getHash().getBytes()); // index is actually an unsigned int s.setInt(2, (int) out.getIndex()); s.setInt(3, out.getHeight()); s.setLong(4, out.getValue().value); s.setBytes(5, out.getScript().getProgram()); s.setString(6, out.getAddress()); s.setInt(7, out.getScript().getScriptType().ordinal()); s.setBoolean(8, out.isCoinbase()); s.executeUpdate(); s.close(); } catch (SQLException e) { if (!(e.getSQLState().equals(getDuplicateKeyErrorCode()))) throw new BlockStoreException(e); } finally { if (s != null) { try { s.close(); } catch (SQLException e) { throw new BlockStoreException(e); } } } }
@Override public void addUnspentTransactionOutput(UTXO out) throws BlockStoreException { maybeConnect(); PreparedStatement s = null; try { s = conn.get().prepareStatement(getInsertOpenoutputsSQL()); s.setBytes(1, out.getHash().getBytes()); // index is actually an unsigned int s.setInt(2, (int) out.getIndex()); s.setInt(3, out.getHeight()); s.setLong(4, out.getValue().value); s.setBytes(5, out.getScript().getProgram()); s.setString(6, out.getAddress()); s.setInt(7, out.getScript().getScriptType().ordinal()); s.setBoolean(8, out.isCoinbase()); s.executeUpdate(); s.close(); } catch (SQLException e) { if (!(e.getSQLState().equals(getDuplicateKeyErrorCode()))) throw new BlockStoreException(e); } finally { if (s != null) { try { s.close(); } catch (SQLException e) { throw new BlockStoreException(e); } } } }
@Override public void addUnspentTransactionOutput(UTXO out) throws BlockStoreException { maybeConnect(); PreparedStatement s = null; try { s = conn.get().prepareStatement(getInsertOpenoutputsSQL()); s.setBytes(1, out.getHash().getBytes()); // index is actually an unsigned int s.setInt(2, (int) out.getIndex()); s.setInt(3, out.getHeight()); s.setLong(4, out.getValue().value); s.setBytes(5, out.getScript().getProgram()); s.setString(6, out.getAddress()); s.setInt(7, out.getScript().getScriptType().ordinal()); s.setBoolean(8, out.isCoinbase()); s.executeUpdate(); s.close(); } catch (SQLException e) { if (!(e.getSQLState().equals(getDuplicateKeyErrorCode()))) throw new BlockStoreException(e); } finally { if (s != null) { try { s.close(); } catch (SQLException e) { throw new BlockStoreException(e); } } } }
for (UTXO output : getStoredOutputsFromUTXOProvider()) { boolean coinbase = output.isCoinbase(); int depth = chainHeight - output.getHeight() + 1; // the current depth of the output (1 = same as head).
for (UTXO output : getStoredOutputsFromUTXOProvider()) { boolean coinbase = output.isCoinbase(); int depth = chainHeight - output.getHeight() + 1; // the current depth of the output (1 = same as head).
for (UTXO output : getStoredOutputsFromUTXOProvider()) { boolean coinbase = output.isCoinbase(); int depth = chainHeight - output.getHeight() + 1; // the current depth of the output (1 = same as head).
for (UTXO output : getStoredOutputsFromUTXOProvider()) { boolean coinbase = output.isCoinbase(); int depth = chainHeight - output.getHeight() + 1; // the current depth of the output (1 = same as head).
Script sc = txout.getScript(); Address address = sc.getToAddress(params, true); UTXO output = new UTXO(txout.getHash(), txout.getIndex(), txout.getValue(), txout.getHeight(), txout.isCoinbase(), txout.getScript(), address.toString()); results.add(output);
Script sc = txout.getScript(); Address address = sc.getToAddress(params, true); UTXO output = new UTXO(txout.getHash(), txout.getIndex(), txout.getValue(), txout.getHeight(), txout.isCoinbase(), txout.getScript(), address.toString()); results.add(output);
Script sc = txout.getScript(); Address address = sc.getToAddress(params, true); UTXO output = new UTXO(txout.getHash(), txout.getIndex(), txout.getValue(), txout.getHeight(), txout.isCoinbase(), txout.getScript(), address.toString()); results.add(output);
Script sc = txout.getScript(); Address address = sc.getToAddress(params, true); UTXO output = new UTXO(txout.getHash(), txout.getIndex(), txout.getValue(), txout.getHeight(), txout.isCoinbase(), txout.getScript(), address.toString()); results.add(output);
@Test public void testJavaSerialization() throws Exception { ECKey key = new ECKey(); UTXO utxo = new UTXO(Sha256Hash.of(new byte[]{1,2,3}), 1, Coin.COIN, 10, true, ScriptBuilder.createOutputScript(key)); ByteArrayOutputStream os = new ByteArrayOutputStream(); new ObjectOutputStream(os).writeObject(utxo); UTXO utxoCopy = (UTXO) new ObjectInputStream( new ByteArrayInputStream(os.toByteArray())).readObject(); assertEquals(utxo, utxoCopy); assertEquals(utxo.getValue(), utxoCopy.getValue()); assertEquals(utxo.getHeight(), utxoCopy.getHeight()); assertEquals(utxo.isCoinbase(), utxoCopy.isCoinbase()); assertEquals(utxo.getScript(), utxoCopy.getScript()); } }
if (prevOut == null) throw new VerificationException("Attempted spend of a non-existent or already spent output!"); if (prevOut.isCoinbase() && newBlock.getHeight() - prevOut.getHeight() < params.getSpendableCoinbaseDepth()) throw new VerificationException("Tried to spend coinbase at depth " + (newBlock.getHeight() - prevOut.getHeight())); valueIn = valueIn.add(prevOut.getValue()); if (verifyFlags.contains(VerifyFlag.P2SH)) {
if (prevOut == null) throw new VerificationException("Attempted spend of a non-existent or already spent output!"); if (prevOut.isCoinbase() && newBlock.getHeight() - prevOut.getHeight() < params.getSpendableCoinbaseDepth()) throw new VerificationException("Tried to spend coinbase at depth " + (newBlock.getHeight() - prevOut.getHeight())); valueIn = valueIn.add(prevOut.getValue()); if (verifyFlags.contains(VerifyFlag.P2SH)) {