Exemplo n.º 1
0
 private static string NotNull(WitScriptId segwitScriptId)
 {
     if (segwitScriptId == null)
     {
         throw new ArgumentNullException("segwitScriptId");
     }
     return(null);
 }
Exemplo n.º 2
0
        public BitcoinWitScriptAddress(string bech32, Network expectedNetwork = null)
            : base(Validate(bech32, ref expectedNetwork), expectedNetwork)
        {
            var  encoder = expectedNetwork.GetBech32Encoder(Bech32Type.WITNESS_SCRIPT_ADDRESS, true);
            byte witVersion;
            var  decoded = encoder.Decode(bech32, out witVersion);

            _Hash = new WitScriptId(decoded);
        }
        /// <summary>
        /// Extract witness redeem from WitScript
        /// </summary>
        /// <param name="witScript">Witscript to extract information from</param>
        /// <param name="expectedScriptId">Expected redeem hash</param>
        /// <returns>The witness redeem</returns>
        public Script ExtractWitScriptParameters(WitScript witScript, WitScriptId expectedScriptId = null)
        {
            if (witScript.PushCount == 0)
            {
                return(null);
            }
            var    last   = witScript.GetUnsafePush(witScript.PushCount - 1);
            Script redeem = new Script(last);

            if (expectedScriptId != null)
            {
                if (expectedScriptId != redeem.WitHash)
                {
                    return(null);
                }
            }
            return(redeem);
        }
 public Script GenerateScriptPubKey(WitScriptId scriptHash)
 {
     return(scriptHash.ScriptPubKey);
 }
Exemplo n.º 5
0
 public BitcoinWitScriptAddress(WitScriptId segwitScriptId, Network network)
     : base(NotNull(segwitScriptId) ?? Network.CreateBech32(Bech32Type.WITNESS_SCRIPT_ADDRESS, segwitScriptId.ToBytes(), 0, network), network)
 {
     _Hash = segwitScriptId;
 }