Example #1
0
        /// <summary>
        /// Initializes an instance of the <see cref="ScriptPubKey"/> class.
        /// </summary>
        /// <param name="script">The script.</param>
        /// <param name="network">The network where the transaction was conducted.</param>
        public ScriptPubKey(Consensus.ScriptInfo.Script script, Network network) : base(script)
        {
            var destinations = new List <TxDestination> {
                script.GetDestination(network)
            };

            this.Type = this.GetScriptType(script.FindTemplate(network));

            if (destinations[0] == null)
            {
                destinations = script.GetDestinationPublicKeys(network).Select(p => p.Hash).ToList <TxDestination>();
            }

            if (destinations.Count == 1)
            {
                this.ReqSigs   = 1;
                this.Addresses = new List <string> {
                    destinations[0].GetAddress(network).ToString()
                };
            }
            else if (destinations.Count > 1)
            {
                PayToMultiSigTemplateParameters multi = PayToMultiSigTemplate.Instance.ExtractScriptPubKeyParameters(script);
                this.ReqSigs   = multi.SignatureCount;
                this.Addresses = multi.PubKeys.Select(m => m.GetAddress(network).ToString()).ToList();
            }
        }
Example #2
0
        /// <summary>
        /// Initializes a <see cref="Vin"/> instance.
        /// </summary>
        /// <param name="prevOut">The previous output being used as an input.</param>
        /// <param name="sequence">The transaction's sequence number.</param>
        /// <param name="scriptSig">The scriptSig</param>
        public Vin(OutPoint prevOut, Sequence sequence, Consensus.ScriptInfo.Script scriptSig)
        {
            if (prevOut.Hash == uint256.Zero)
            {
                this.Coinbase = Encoders.Hex.EncodeData(scriptSig.ToBytes());
            }
            else
            {
                this.TxId      = prevOut.Hash.ToString();
                this.VOut      = prevOut.N;
                this.ScriptSig = new Script(scriptSig);
            }

            this.Sequence = (uint)sequence;
        }
Example #3
0
 /// <summary>
 /// Initializes a transaction <see cref="Script"/>, which contains the assembly and a hexadecimal representation of the script.
 /// </summary>
 /// <param name="script">A <see cref="Consensus.ScriptInfo.Script"/>.</param>
 public Script(Consensus.ScriptInfo.Script script)
 {
     this.Asm = script.ToString();
     this.Hex = Encoders.Hex.EncodeData(script.ToBytes());
 }