Beispiel #1
0
 public Script GenerateScriptPubKey(ScriptId scriptId)
 {
     return(new Script(
                OpcodeType.OP_HASH160,
                Op.GetPushOp(scriptId.ToBytes()),
                OpcodeType.OP_EQUAL));
 }
Beispiel #2
0
        byte[] Compress()
        {
            byte[] result = null;
            KeyId  keyID  = GetKeyId();

            if (keyID != null)
            {
                result    = new byte[21];
                result[0] = 0x00;
                Array.Copy(keyID.ToBytes(), 0, result, 1, 20);
                return(result);
            }
            ScriptId scriptID = GetScriptId();

            if (scriptID != null)
            {
                result    = new byte[21];
                result[0] = 0x01;
                Array.Copy(scriptID.ToBytes(), 0, result, 1, 20);
                return(result);
            }
            PubKey pubkey = GetPubKey();

            if (pubkey != null)
            {
                result = new byte[33];
                var pubBytes = pubkey.ToBytes();
                Array.Copy(pubBytes, 1, result, 1, 32);
                if (pubBytes[0] == 0x02 || pubBytes[0] == 0x03)
                {
                    result[0] = pubBytes[0];
                    return(result);
                }
                else if (pubBytes[0] == 0x04)
                {
                    result[0] = (byte)(0x04 | (pubBytes[64] & 0x01));
                    return(result);
                }
            }
            return(null);
        }
		public Script GenerateScriptPubKey(ScriptId scriptId)
		{
			return new Script(
				OpcodeType.OP_HASH160,
				Op.GetPushOp(scriptId.ToBytes()),
				OpcodeType.OP_EQUAL);
		}
Beispiel #4
0
 public BitcoinScriptAddress(ScriptId scriptId, Network network)
     : base(NotNull(scriptId) ?? Network.CreateBase58(Base58Type.SCRIPT_ADDRESS, scriptId.ToBytes(), network), network)
 {
     _Hash = scriptId;
 }