当前位置: 首页>>代码示例>>C#>>正文


C# Script.ToOps方法代码示例

本文整理汇总了C#中System.Script.ToOps方法的典型用法代码示例。如果您正苦于以下问题:C# Script.ToOps方法的具体用法?C# Script.ToOps怎么用?C# Script.ToOps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Script的用法示例。


在下文中一共展示了Script.ToOps方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadScript

		private bool ReadScript(Script script)
		{
			var bytes = script.ToBytes(true);
			if(bytes.Length == 0 || bytes[0] != (byte)OpcodeType.OP_RETURN)
				return false;
			foreach(var op in script.ToOps())
			{
				if(op.PushData != null && !op.IsInvalid)
				{
					if(ReadData(op.PushData))
						return true;
				}
			}
			return false;
		}
开发者ID:woutersmit,项目名称:NBitcoin,代码行数:15,代码来源:ColorMarker.cs

示例2: Fill

		private static bool Fill(StealthMetadata output, Script metadata)
		{
			var ops = metadata.ToOps().ToArray();
			if(ops.Length != 2 || ops[0].Code != OpcodeType.OP_RETURN)
				return false;
			var data = ops[1].PushData;
			if(data == null || data.Length != 1 + 4 + 33)
				return false;
			MemoryStream ms = new MemoryStream(data);
			output.Version = ms.ReadByte();
			if(output.Version != 6)
				return false;
			output.Nonce = ms.ReadBytes(4);
			output.EphemKey = new PubKey(ms.ReadBytes(33));
			output.Script = metadata;
			output.Hash = Hashes.Hash256(data);
			var msprefix = new MemoryStream(output.Hash.ToBytes(false));
			output.BitField = Utils.ToUInt32(msprefix.ReadBytes(4), true);
			return true;
		}
开发者ID:xcrash,项目名称:NBitcoin,代码行数:20,代码来源:StealthMetadata.cs

示例3: Add

		/// <summary>
		/// Register the specified ScriptPubKey
		/// </summary>
		/// <param name="scriptPubKey">The ScriptPubKey</param>
		/// <param name="isRedeemScript">If true, the P2SH of the destination's script will be tracked (Default: false)</param>
		/// <param name="isInternal">If true, the scriptPubKey will not belong to tracked data, typically, change addresses (Default: false)</param>
		/// <param name="filter">The filter in which this key will appear (http://eprint.iacr.org/2014/763.pdf)</param>
		/// <param name="wallet">The wallet name to which it belongs</param>
		public bool Add(Script scriptPubKey, bool isRedeemScript = false, bool isInternal = false, string filter = "a", string wallet = "default")
		{
			if(filter == null)
				throw new ArgumentNullException("filter");
			if(wallet == null)
				throw new ArgumentNullException("wallet");
			Script redeem = isRedeemScript ? scriptPubKey : null;
			scriptPubKey = isRedeemScript ? scriptPubKey.Hash.ScriptPubKey : scriptPubKey;
			var data = scriptPubKey.ToOps().First(o => o.PushData != null).PushData;

			var trackedScript = new TrackedScript()
			{
				ScriptPubKey = scriptPubKey,
				RedeemScript = redeem,
				AddedDate = DateTimeOffset.UtcNow,
				IsInternal = isInternal,
				Filter = filter,
				Wallet = wallet
			};

			bool added = false;
			lock(cs)
			{
				added = _TrackedScripts.TryAdd(trackedScript.GetId(), trackedScript);
			}
			return added;
		}
开发者ID:xcrash,项目名称:NBitcoin,代码行数:35,代码来源:Tracker.cs


注:本文中的System.Script.ToOps方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。