public void Update(Network network, Transaction transaction, int height) { if (!transaction.IsCoinBase) { foreach (TxIn input in transaction.Inputs) { UnspentOutput unspentOutput = this.AccessCoins(input.PrevOut); if (!unspentOutput.Spend()) { throw new InvalidOperationException("Unspendable coins are invalid at this point"); } } } foreach (IndexedTxOut output in transaction.Outputs.AsIndexedOutputs()) { var outpoint = output.ToOutPoint(); var coinbase = transaction.IsCoinBase; var coinstake = network.Consensus.IsProofOfStake ? transaction.IsCoinStake : false; var time = (transaction is IPosTransactionWithTime posTx) ? posTx.Time : 0; var coins = new Coins((uint)height, output.TxOut, coinbase, coinstake, time); var unspentOutput = new UnspentOutput(outpoint, coins) { CreatedFromBlock = true }; // If the output is an opreturn just ignore it if (coins.IsPrunable) { continue; } // In cases where an output is spent in the same block // It will already exist as an input in the unspent list. this.unspents.AddOrReplace(outpoint, unspentOutput); } }