Ejemplo n.º 1
0
        public bool HaveInputs(Transaction tx)
        {
            if (!tx.IsCoinBase)
            {
                // first check whether information about the prevout hash is available
                for (int i = 0; i < tx.Inputs.Count; i++)
                {
                    OutPoint prevout = tx.Inputs[i].PrevOut;
                    if (!HaveCoins(prevout.Hash))
                    {
                        return(false);
                    }
                }

                // then check whether the actual outputs are available
                for (int i = 0; i < tx.Inputs.Count; i++)
                {
                    OutPoint prevout = tx.Inputs[i].PrevOut;
                    Coins    coins   = GetCoins(prevout.Hash);
                    if (!coins.IsAvailable(prevout.N))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
        public TxOut GetOutputFor(TxIn input)
        {
            Coins coins = GetCoins(input.PrevOut.Hash);

            if (!coins.IsAvailable(input.PrevOut.N))
            {
                return(null);
            }
            return(coins.Outputs[(int)input.PrevOut.N]);
        }