Package com.bitsofproof.supernode.api

Examples of com.bitsofproof.supernode.api.TransactionOutput


    transaction.setOutputs (new ArrayList<TransactionOutput> ());

    long sumOut = 0;
    for ( TransactionSink s : sinks )
    {
      TransactionOutput o = new TransactionOutput ();
      o.setValue (s.getValue ());
      sumOut += s.getValue ();
      o.setScript (s.getAddress ().getAddressScript ());

      transaction.getOutputs ().add (o);
    }

    long sumInput = 0;
    for ( TransactionOutput o : sources )
    {
      TransactionInput i = new TransactionInput ();
      i.setSourceHash (o.getTxHash ());
      i.setIx (o.getIx ());
      sumInput += o.getValue ();

      transaction.getInputs ().add (i);
    }
    if ( sumInput != (sumOut + fee) )
    {
View Full Code Here


    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 ());
      }
View Full Code Here

TOP

Related Classes of com.bitsofproof.supernode.api.TransactionOutput

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.