Ejemplo n.º 1
0
 public BitcoinWitPubKeyAddress(WitKeyId segwitKeyId, Network network) :
     base(
         NotNull(segwitKeyId) ??
         Network.CreateBech32(Bech32Type.WITNESS_PUBKEY_ADDRESS, segwitKeyId.ToBytes(), 0, network), network)
 {
     this.Hash = segwitKeyId;
 }
Ejemplo n.º 2
0
 private static string NotNull(WitKeyId segwitKeyId)
 {
     if (segwitKeyId == null)
     {
         throw new ArgumentNullException("segwitKeyId");
     }
     return(null);
 }
Ejemplo 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);
     }
 }
Ejemplo 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);
        }
Ejemplo n.º 6
0
 public Script GenerateScriptPubKey(WitKeyId pubkeyHash)
 {
     return(pubkeyHash.ScriptPubKey);
 }
Ejemplo n.º 7
0
		public Script GenerateScriptPubKey(WitKeyId pubkeyHash)
		{
			return pubkeyHash.ScriptPubKey;
		}
Ejemplo n.º 8
0
 public BitcoinWitPubKeyAddress(WitKeyId segwitKeyId, Network network)
     : base(new[] { (byte)OpcodeType.OP_0, (byte)0x00 }.Concat(segwitKeyId.ToBytes(true)).ToArray(), network)
 {
 }
Ejemplo n.º 9
0
 public virtual BitcoinAddress CreateP2WPKH(WitKeyId witKeyId, Network network)
 {
     return(new BitcoinWitPubKeyAddress(witKeyId, network));
 }
Ejemplo n.º 10
0
 internal BitcoinWitPubKeyAddress(string str, byte[] key, Network network) : base(str, network)
 {
     _Hash = new WitKeyId(key);
 }
Ejemplo n.º 11
0
		public BitcoinWitPubKeyAddress(WitKeyId segwitKeyId, Network network)
			: base(new[] { (byte)OpcodeType.OP_0, (byte)0x00 }.Concat(segwitKeyId.ToBytes(true)).ToArray(), network)
		{
		}