synchronized ( confirmed )
{
boolean modified = false;
if ( !t.isDoubleSpend () )
{
TransactionOutput spend = null;
for ( TransactionInput i : t.getInputs () )
{
spend = confirmed.get (i.getSourceHash (), i.getIx ());
if ( spend != null )
{
confirmed.remove (i.getSourceHash (), i.getIx ());
log.trace ("Spend settled output " + i.getSourceHash () + " [" + i.getIx () + "] " + spend.getValue ());
}
else
{
spend = change.get (i.getSourceHash (), i.getIx ());
if ( spend != null )
{
change.remove (i.getSourceHash (), i.getIx ());
log.trace ("Spend change output " + i.getSourceHash () + " [" + i.getIx () + "] " + spend.getValue ());
}
else
{
spend = receiving.get (i.getSourceHash (), i.getIx ());
if ( spend != null )
{
receiving.remove (i.getSourceHash (), i.getIx ());
log.trace ("Spend receiving output " + i.getSourceHash () + " [" + i.getIx () + "] " + spend.getValue ());
}
}
}
}
modified = spend != null;
for ( TransactionOutput o : t.getOutputs () )
{
confirmed.remove (o.getTxHash (), o.getIx ());
change.remove (o.getTxHash (), o.getIx ());
receiving.remove (o.getTxHash (), o.getIx ());
sending.remove (o.getTxHash (), o.getIx ());
if ( isOwnAddress (o.getOutputAddress ()) )
{
modified = true;
if ( t.getBlockHash () != null )
{
confirmed.add (o);
log.trace ("Settled " + t.getHash () + " [" + o.getIx () + "] (" + o.getOutputAddress () + ") " + o.getValue ());
}
else
{
if ( spend != null )
{
change.add (o);
log.trace ("Change " + t.getHash () + " [" + o.getIx () + "] (" + o.getOutputAddress () + ") "
+ o.getValue ());
}
else
{
receiving.add (o);
log.trace ("Receiving " + t.getHash () + " [" + o.getIx () + "] (" + o.getOutputAddress () + ") "
+ o.getValue ());
}
}
}
else
{
if ( t.getBlockHash () == null && spend != null )
{
modified = true;
sending.add (o);
log.trace ("Sending " + t.getHash () + " [" + o.getIx () + "] (" + o.getOutputAddress () + ") " + o.getValue ());
}
}
}
if ( modified )
{
transactions.put (t.getHash (), t);
}
}
else
{
for ( long ix = 0; ix < t.getOutputs ().size (); ++ix )
{
TransactionOutput out = null;
out = confirmed.remove (t.getHash (), ix);
if ( out == null )
{
out = change.remove (t.getHash (), ix);
}
if ( out == null )
{
out = receiving.remove (t.getHash (), ix);
}
if ( out == null )
{
out = sending.remove (t.getHash (), ix);
}
if ( out != null )
{
log.trace ("Remove DS " + out.getTxHash () + " [" + out.getIx () + "] (" + out.getOutputAddress () + ")"
+ out.getValue ());
}
modified |= out != null;
}
transactions.remove (t.getHash ());
}