public BitcoinWitPubKeyAddress(WitKeyId segwitKeyId, Network network) :
     base(
         NotNull(segwitKeyId) ??
         Network.CreateBech32(Bech32Type.WITNESS_PUBKEY_ADDRESS, segwitKeyId.ToBytes(), 0, network), network)
 {
     this.Hash = segwitKeyId;
 }
Esempio n. 2
0
 private static string NotNull(WitKeyId segwitKeyId)
 {
     if (segwitKeyId == null)
     {
         throw new ArgumentNullException("segwitKeyId");
     }
     return(null);
 }
Esempio n. 3
0
        public BitcoinWitPubKeyAddress(string bech32, Network expectedNetwork = null)
            : base(Validate(bech32, ref expectedNetwork), expectedNetwork)
        {
            var  encoder = expectedNetwork.GetBech32Encoder(Bech32Type.WITNESS_PUBKEY_ADDRESS, true);
            byte witVersion;
            var  decoded = encoder.Decode(bech32, out witVersion);

            _Hash = new WitKeyId(decoded);
        }
 public BitcoinWitPubKeyAddress(string bech32, Network expectedNetwork)
     : base(Validate(bech32, expectedNetwork), expectedNetwork)
 {
     if (expectedNetwork.GetBech32Encoder(Bech32Type.WITNESS_PUBKEY_ADDRESS, false) is Bech32Encoder encoder)
     {
         byte witVersion;
         var  decoded = encoder.Decode(bech32, out witVersion);
         _Hash = new WitKeyId(decoded);
     }
     else
     {
         throw expectedNetwork.Bech32NotSupported(Bech32Type.WITNESS_PUBKEY_ADDRESS);
     }
 }
Esempio n. 5
0
        public override Script GetScriptCode(Network network)
        {
            if (!CanGetScriptCode(network))
            {
                throw new InvalidOperationException("You need to provide the P2WSH redeem script with ScriptCoin.ToScriptCoin()");
            }
            if (_OverrideScriptCode != null)
            {
                return(_OverrideScriptCode);
            }
            WitKeyId key = PayToWitPubKeyHashTemplate.Instance.ExtractScriptPubKeyParameters(network, Redeem);

            if (key != null)
            {
                return(key.AsKeyId().ScriptPubKey);
            }
            return(Redeem);
        }
Esempio n. 6
0
 public Script GenerateScriptPubKey(WitKeyId pubkeyHash)
 {
     return(pubkeyHash.ScriptPubKey);
 }
Esempio n. 7
0
		public Script GenerateScriptPubKey(WitKeyId pubkeyHash)
		{
			return pubkeyHash.ScriptPubKey;
		}
Esempio n. 8
0
 public BitcoinWitPubKeyAddress(WitKeyId segwitKeyId, Network network)
     : base(new[] { (byte)OpcodeType.OP_0, (byte)0x00 }.Concat(segwitKeyId.ToBytes(true)).ToArray(), network)
 {
 }
Esempio n. 9
0
 public virtual BitcoinAddress CreateP2WPKH(WitKeyId witKeyId, Network network)
 {
     return(new BitcoinWitPubKeyAddress(witKeyId, network));
 }
Esempio n. 10
0
 internal BitcoinWitPubKeyAddress(string str, byte[] key, Network network) : base(str, network)
 {
     _Hash = new WitKeyId(key);
 }
Esempio n. 11
0
		public BitcoinWitPubKeyAddress(WitKeyId segwitKeyId, Network network)
			: base(new[] { (byte)OpcodeType.OP_0, (byte)0x00 }.Concat(segwitKeyId.ToBytes(true)).ToArray(), network)
		{
		}