Exemple #1
0
        // Check for standard transaction types
        // @param[in] mapInputs    Map of previous transactions that have outputs we're spending
        // @return True if all inputs (scriptSigs) use only standard transaction forms
        private bool AreInputsStandard(Transaction tx, MempoolCoinView mapInputs)
        {
            if (tx.IsCoinBase)
            {
                return(true); // Coinbases don't use vin normally
            }
            foreach (TxIn txin in tx.Inputs)
            {
                var prev     = mapInputs.GetOutputFor(txin);
                var template = StandardScripts.GetTemplateFromScriptPubKey(prev.ScriptPubKey);
                if (template == null)
                {
                    return(false);
                }

                if (template.Type == TxOutType.TX_SCRIPTHASH)
                {
                    if (prev.ScriptPubKey.GetSigOpCount(true) > 15) //MAX_P2SH_SIGOPS
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
        /// <inheritdoc />
        public async Task <UnspentOutputs> GetUnspentTransactionAsync(uint256 trxid)
        {
            var txInfo = await this.InfoAsync(trxid);

            if (txInfo == null)
            {
                return(null);
            }
            var memPoolCoinView = new MempoolCoinView(this.coinView, this.memPool, this.MempoolLock, this.Validator);
            await memPoolCoinView.LoadViewAsync(txInfo.Trx);

            return(memPoolCoinView.GetCoins(trxid));
        }
        /// <inheritdoc />
        public async Task <UnspentOutputs> GetUnspentTransactionAsync(uint256 trxid)
        {
            TxMempoolInfo txInfo = await this.InfoAsync(trxid);

            if (txInfo == null)
            {
                this.logger.LogTrace("(-):[TX_IS_NULL]");
                return(null);
            }

            var memPoolCoinView = new MempoolCoinView(this.coinView, this.memPool, this.MempoolLock, this.Validator);
            await memPoolCoinView.LoadViewAsync(txInfo.Trx);

            UnspentOutputs unspentOutputs = memPoolCoinView.GetCoins(trxid);

            return(unspentOutputs);
        }
        /// <inheritdoc />
        public async Task <UnspentOutput> GetUnspentTransactionAsync(OutPoint outPoint)
        {
            TxMempoolInfo txInfo = this.Info(outPoint.Hash);

            if (txInfo == null)
            {
                this.logger.LogTrace("(-):[TX_IS_NULL]");
                return(null);
            }

            var memPoolCoinView = new MempoolCoinView(this.network, this.coinView, this.memPool, this.MempoolLock, this.Validator);

            await this.MempoolLock.ReadAsync(() => { memPoolCoinView.LoadViewLocked(txInfo.Trx); });

            UnspentOutput unspentOutput = memPoolCoinView.Set.AccessCoins(outPoint);

            return(unspentOutput);
        }
Exemple #5
0
 private bool IsWitnessStandard(Transaction tx, MempoolCoinView mapInputs)
 {
     // TODO: Implement Witness Code
     return(true);
 }