當前位置: 首頁>>代碼示例>>C#>>正文


C# NBitcoin.Op類代碼示例

本文整理匯總了C#中NBitcoin.Op的典型用法代碼示例。如果您正苦於以下問題:C# Op類的具體用法?C# Op怎麽用?C# Op使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Op類屬於NBitcoin命名空間,在下文中一共展示了Op類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CheckScriptPubKeyCore

		protected override bool CheckScriptPubKeyCore(Script scriptPubKey, Op[] scriptPubKeyOps)
		{
			var ops = scriptPubKeyOps;
			if(ops.Length < 1)
				return false;
			if(ops[0].Code != OpcodeType.OP_RETURN)
				return false;
			if(scriptPubKey.ToBytes(true).Length > MaxScriptSizeLimit)
				return false;
			return scriptPubKeyOps.Skip(1).All(o => o.PushData != null && !o.IsInvalid);
		}
開發者ID:D-bank,項目名稱:NBitcoin,代碼行數:11,代碼來源:StandardScriptTemplate.cs

示例2: CheckScriptPubKeyCore

		protected override bool CheckScriptPubKeyCore(Script scriptPubKey, Op[] scriptPubKeyOps)
		{
			var ops = scriptPubKeyOps;
			if(ops.Length < 1)
				return false;
			if(ops[0].Code != OpcodeType.OP_RETURN)
				return false;
			if(ops.Length == 2)
			{
				return ops[1].PushData != null && ops[1].PushData.Length <= MAX_OPRETURN_SIZE;
			}
			return true;
		}
開發者ID:tungpang2009,項目名稱:NBitcoin,代碼行數:13,代碼來源:StandardScriptTemplate.cs

示例3: bytes

		public const int MAX_OP_RETURN_RELAY = 83; //! bytes (+1 for OP_RETURN, +2 for the pushdata opcodes)
		public Script GenerateScriptPubKey(params byte[][] data)
		{
			if(data == null)
				throw new ArgumentNullException("data");
			Op[] ops = new Op[data.Length + 1];
			ops[0] = OpcodeType.OP_RETURN;
			for(int i = 0; i < data.Length; i++)
			{
				ops[1 + i] = Op.GetPushOp(data[i]);
			}
			var script = new Script(ops);
			if(script.ToBytes(true).Length > MaxScriptSizeLimit)
				throw new ArgumentOutOfRangeException("data", "Data in OP_RETURN should have a maximum size of " + MaxScriptSizeLimit + " bytes");
			return script;
		}
開發者ID:crowar,項目名稱:NBitcoin,代碼行數:16,代碼來源:StandardScriptTemplate.cs

示例4: CheckScriptSigCore

		protected override bool CheckScriptSigCore(Script scriptSig, Op[] scriptSigOps, Script scriptPubKey, Op[] scriptPubKeyOps)
		{
			if(!scriptSig.IsPushOnly)
				return false;
			if(scriptSigOps[0].Code != OpcodeType.OP_0)
				return false;
			if(scriptSigOps.Length == 1)
				return false;
			if(!scriptSigOps.Skip(1).All(s => TransactionSignature.ValidLength(s.PushData.Length) || s.Code == OpcodeType.OP_0))
				return false;
			if(scriptPubKeyOps != null)
			{
				if(!CheckScriptPubKeyCore(scriptPubKey, scriptPubKeyOps))
					return false;
				var sigCountExpected = scriptPubKeyOps[0].GetValue();
				return sigCountExpected == scriptSigOps.Length + 1;
			}
			return true;

		}
開發者ID:crowar,項目名稱:NBitcoin,代碼行數:20,代碼來源:StandardScriptTemplate.cs

示例5: GenerateWitScript

		public WitScript GenerateWitScript(Op[] scriptSig, Script redeemScript)
		{
			if(redeemScript == null)
				throw new ArgumentNullException("redeemScript");
			if(scriptSig == null)
				throw new ArgumentNullException("scriptSig");

			var ops = scriptSig.Concat(new[] { Op.GetPushOp(redeemScript.ToBytes(true)) }).ToArray();
			return new WitScript(ops);
		}
開發者ID:n1rvana,項目名稱:NBitcoin,代碼行數:10,代碼來源:StandardScriptTemplate.cs

示例6: GetPushOp

		public static Op GetPushOp(byte[] data)
		{
			Op op = new Op();
			op.PushData = data;
			if(data.Length == 0)
				op.Code = OpcodeType.OP_0;
			else if(data.Length == 1 && (byte)1 <= data[0] && data[0] <= (byte)16)
				op.Code = (OpcodeType)(data[0] + (byte)OpcodeType.OP_1 - 1);
			else if(data.Length == 1 && (byte)0x81 == data[0])
				op.Code = OpcodeType.OP_1NEGATE;
			else if(0x01 <= data.Length && data.Length <= 0x4b)
				op.Code = (OpcodeType)(byte)data.Length;
			else if(data.Length <= 0xFF)
				op.Code = OpcodeType.OP_PUSHDATA1;
#if !PORTABLE
			else if(data.LongLength <= 0xFFFF)
				op.Code = OpcodeType.OP_PUSHDATA2;
			else if(data.LongLength <= 0xFFFFFFFF)
				op.Code = OpcodeType.OP_PUSHDATA4;
#else
			else if(data.Length <= 0xFFFF)
				op.Code = OpcodeType.OP_PUSHDATA2;
#endif
			else
				throw new NotSupportedException("Data length should not be bigger than 0xFFFFFFFF");
			return op;
		}
開發者ID:sumghosh80,項目名稱:NBitcoin,代碼行數:27,代碼來源:ScriptReader.cs

示例7: CheckScriptPubKeyCore

		protected override bool CheckScriptPubKeyCore(Script scriptPubKey, Op[] scriptPubKeyOps)
		{
			return true;
		}
開發者ID:crowar,項目名稱:NBitcoin,代碼行數:4,代碼來源:StandardScriptTemplate.cs

示例8: CheckScriptSigCore

		protected override bool CheckScriptSigCore(Script scriptSig, Op[] scriptSigOps, Script scriptPubKey, Op[] scriptPubKeyOps)
		{
			return scriptSig.Length == 0;
		}
開發者ID:D-bank,項目名稱:NBitcoin,代碼行數:4,代碼來源:StandardScriptTemplate.cs

示例9: GenerateScriptSig

		public Script GenerateScriptSig(Op[] ops, Script redeemScript)
		{
			var pushScript = Op.GetPushOp(redeemScript._Script);
			return new Script(ops.Concat(new[] { pushScript }));
		}
開發者ID:crowar,項目名稱:NBitcoin,代碼行數:5,代碼來源:StandardScriptTemplate.cs

示例10: CheckScriptSigCore

		protected override bool CheckScriptSigCore(Script scriptSig, Op[] scriptSigOps, Script scriptPubKey, Op[] scriptPubKeyOps)
		{
			var ops = scriptSigOps;
			if(ops.Length != 2)
				return false;
			return ops[0].PushData != null &&
				   ops[1].PushData != null && PubKey.Check(ops[1].PushData, false);
		}
開發者ID:tungpang2009,項目名稱:NBitcoin,代碼行數:8,代碼來源:StandardScriptTemplate.cs

示例11: GenerateScriptSig

 public Script GenerateScriptSig(Op[] ops, Script script)
 {
     var pushScript = Op.GetPushOp(script._Script);
     return new Script(ops.Concat(new[] { pushScript }).ToArray());
 }
開發者ID:nikropht,項目名稱:NBitcoin,代碼行數:5,代碼來源:StandardScriptTemplate.cs

示例12: ReadData

        internal static byte[] ReadData(Op op, Stream stream, bool ignoreWrongPush = false)
        {
            var opcode = op.Code;
            uint len = 0;
            BitcoinStream bitStream = new BitcoinStream(stream, false);
            if(opcode == 0)
                return new byte[0];

            if((byte)OpcodeType.OP_1 <= (byte)opcode && (byte)opcode <= (byte)OpcodeType.OP_16)
            {
                return new byte[] { (byte)(opcode - OpcodeType.OP_1 + 1) };
            }

            if(opcode == OpcodeType.OP_1NEGATE)
            {
                return new byte[] { 0x81 };
            }

            if(0x01 <= (byte)opcode && (byte)opcode <= 0x4b)
                len = (uint)opcode;
            else if(opcode == OpcodeType.OP_PUSHDATA1)
                len = bitStream.ReadWrite((byte)0);
            else if(opcode == OpcodeType.OP_PUSHDATA2)
                len = bitStream.ReadWrite((ushort)0);
            else if(opcode == OpcodeType.OP_PUSHDATA4)
                len = bitStream.ReadWrite((uint)0);
            else
                throw new FormatException("Invalid opcode for pushing data : " + opcode);

            byte[] data = new byte[len];
            var readen = stream.Read(data, 0, data.Length);
            if(readen != data.Length && !ignoreWrongPush)
                throw new FormatException("Not enough bytes pushed with " + opcode.ToString() + " expected " + len + " but got " + readen);
            else if(readen != data.Length)
            {
                op.IncompleteData = true;
                Array.Resize(ref data, readen);
            }
            return data;
        }
開發者ID:nikropht,項目名稱:NBitcoin,代碼行數:40,代碼來源:ScriptReader.cs

示例13: FindAndDelete

		internal int FindAndDelete(Op op)
		{
			return op == null ? 0 : FindAndDelete(o => o.Code == op.Code && Utils.ArrayEqual(o.PushData, op.PushData));
		}
開發者ID:woutersmit,項目名稱:NBitcoin,代碼行數:4,代碼來源:Script.cs

示例14: GenerateWitScript

		public WitScript GenerateWitScript(Op[] scriptSig, Script redeemScript)
		{
			if(redeemScript == null)
				throw new ArgumentNullException("redeemScript");
			if(scriptSig == null)
				throw new ArgumentNullException("scriptSig");
			return GenerateWitScript(new Script(scriptSig), redeemScript);
		}
開發者ID:crowar,項目名稱:NBitcoin,代碼行數:8,代碼來源:StandardScriptTemplate.cs

示例15: Read

		public Op Read()
		{
			var b = Inner.ReadByte();
			if(b == -1)
				return null;
			var opcode = (OpcodeType)b;
			if(Op.IsPushCode(opcode))
			{
				Op op = new Op();
				op.Code = opcode;
				op.PushData = op.ReadData(Inner);
				return op;
			}
			return new Op()
			{
				Code = opcode
			};
		}
開發者ID:sumghosh80,項目名稱:NBitcoin,代碼行數:18,代碼來源:ScriptReader.cs


注:本文中的NBitcoin.Op類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。