Beispiel #1
0
 private static string NotNull(WitScriptId segwitScriptId)
 {
     if (segwitScriptId == null)
     {
         throw new ArgumentNullException("segwitScriptId");
     }
     return(null);
 }
Beispiel #2
0
        public CoinWitScriptAddress(string bech32, Network expectedNetwork)
            : base(Validate(bech32, ref expectedNetwork), expectedNetwork)
        {
            Type = EncoderType;
            var  encoder = expectedNetwork.GetBech32Encoder(EncoderType, true);
            byte witVersion;
            var  decoded = encoder.Decode(bech32, out witVersion);

            _Hash = new WitScriptId(decoded);
        }
Beispiel #3
0
        /// <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);
        }
Beispiel #4
0
 public CoinWitScriptAddress(WitScriptId segwitScriptId, Network network)
     : base(NotNull(segwitScriptId) ?? Network.CreateBech32(EncoderType, segwitScriptId.ToBytes(), 0, network), network)
 {
     _Hash = segwitScriptId;
 }
Beispiel #5
0
 public virtual CoinAddress CreateP2WSH(WitScriptId scriptId, Network network)
 {
     return(new CoinWitScriptAddress(scriptId, network));
 }
Beispiel #6
0
 public Script GenerateScriptPubKey(WitScriptId scriptHash)
 {
     return(scriptHash.ScriptPubKey);
 }