scriptBytes column of openOutputs table is defined by BLOB NOT
NULL,getScriptBytes funtion of StoredTransactionOutput class can return a
byte[] whose lenth is 0.
when downloading block at Fri Apr 12 13:06:34 CST 2013 ,bitcoinj receive a
special block which has a TransactionOutput that the lenth of ScriptBytes is
0.the hash of the special TransactionOutput is
7bd54def72825008b4ca0f4aeff13e6be2c5fe0f23430629a9d484a1ac2a29b8 .
it causes addUnspentTransactionOutput(StoredTransactionOutput out) throwing a
exception-java.lang.RuntimeException:
com.google.bitcoin.store.BlockStoreException:
java.sql.SQLIntegrityConstraintViolationException: ORA-01400: can not insert
NULL into ("TIANYU"."OPENOUTPUTS"."SCRIPTBYTES"),because getScriptbytes funtion
return a byte[] whose lenth is 0.
all sockets is disconnected after causing the exception.
I test it by using oracle.it maybe has the same problem by using H2.
the position of code:
package com.google.bitcoin.store;
H2FullPrunedBlockStore class
public void addUnspentTransactionOutput(StoredTransactionOutput out) throws BlockStoreException {
maybeConnect();
PreparedStatement s = null;
try {
s = conn.get().prepareStatement("INSERT INTO openOutputs (hash, index, height, value, scriptBytes) " +
"VALUES (?, ?, ?, ?, ?)");
s.setBytes(1, out.getHash().getBytes());
// index is actually an unsigned int
s.setInt(2, (int)out.getIndex());
s.setInt(3, out.getHeight());
s.setBytes(4, out.getValue().toByteArray());
s.setBytes(5, out.getScriptBytes());
s.executeUpdate();
s.close();
} catch (SQLException e) {
if (e.getErrorCode() != 23505)
throw new BlockStoreException(e);
} finally {
if (s != null)
try {
s.close();
} catch (SQLException e) { throw new BlockStoreException(e); }
}
}
Original issue reported on code.google.com by tian.yuz.gg@gmail.com on 17 Nov 2013 at 4:26
Original issue reported on code.google.com by
tian.yuz.gg@gmail.com
on 17 Nov 2013 at 4:26