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


C# Key.GetAddress方法代码示例

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


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

示例1: Play

		public static void Play()
		{
			Transaction txxxxx = new Transaction("0100000000010213206299feb17742091c3cb2ab45faa3aa87922d3c030cafb3f798850a2722bf0000000000feffffffa12f2424b9599898a1d30f06e1ce55eba7fabfeee82ae9356f07375806632ff3010000006b483045022100fcc8cf3014248e1a0d6dcddf03e80f7e591605ad0dbace27d2c0d87274f8cd66022053fcfff64f35f22a14deb657ac57f110084fb07bb917c3b42e7d033c54c7717b012102b9e4dcc33c9cc9cb5f42b96dddb3b475b067f3e21125f79e10c853e5ca8fba31feffffff02206f9800000000001976a9144841b9874d913c430048c78a7b18baebdbea440588ac8096980000000000160014e4873ef43eac347471dd94bc899c51b395a509a502483045022100dd8250f8b5c2035d8feefae530b10862a63030590a851183cb61b3672eb4f26e022057fe7bc8593f05416c185d829b574290fb8706423451ebd0a0ae50c276b87b43012102179862f40b85fa43487500f1d6b13c864b5eb0a83999738db0f7a6b91b2ec64f00db080000");

			Script scriptCode = new Script("OP_DUP OP_HASH160 e4873ef43eac347471dd94bc899c51b395a509a5 OP_EQUALVERIFY OP_CHECKSIG");
			var rrrr = Script.SignatureHash(scriptCode, txxxxx, 0, SigHash.All, Money.Satoshis(10000000), HashVersion.Witness);

			//Console.WriteLine(total);
			new Key().PubKey.WitHash.GetAddress(Network.SegNet).ToString();

			var node = Node.Connect(Network.SegNet, "qbitninja-server.cloudapp.net");
			node.VersionHandshake();

			uint256 p2wsh = null;
			uint256 p2pwkh = null;
			uint256 p2wshp2sh = null;
			uint256 p2wpkhp2sh = null;
			foreach(var block in node.GetBlocks())
			{
				foreach(var tx in block.Transactions)
				{
					if(p2wsh != null && p2pwkh != null && p2wshp2sh != null && p2wpkhp2sh != null)
						break;
					if(!tx.IsCoinBase && tx.HasWitness)
					{
						foreach(var input in tx.Inputs.AsIndexedInputs())
						{
							if(input.WitScript == WitScript.Empty)
								continue;
							if(input.ScriptSig == Script.Empty)
							{
								if(PayToWitPubKeyHashTemplate.Instance.ExtractWitScriptParameters(input.WitScript) != null)
									p2pwkh = tx.GetHash();
								else
									p2wsh = tx.GetHash();
							}
							else
							{
								if(PayToWitPubKeyHashTemplate.Instance.ExtractWitScriptParameters(input.WitScript) != null)
									p2wpkhp2sh = tx.GetHash();
								else
									p2wshp2sh = tx.GetHash();
							}
							break;
						}
					}
				}
			}

			var secret = new BitcoinSecret("QTrKVpsVwNUD9GayzdbUNz2NNDqiPgjd9RCprwSa4gmBFg3V2oik", Network.SegNet);

			var oo = secret.PubKey.WitHash.GetAddress(Network.SegNet);

			var key = new Key().GetBitcoinSecret(Network.SegNet);
			var aa = key.GetAddress();
			foreach(var n in new[] { Network.Main, Network.SegNet })
			{
				for(int i = 0 ; i < 2 ; i++)
				{
					BitcoinAddress addr = i == 0 ? (BitcoinAddress)new Key().PubKey.GetSegwitAddress(n) : new Key().ScriptPubKey.GetWitScriptAddress(n);
					var c = addr.ScriptPubKey.ToString();
				}
			}


			var networks = Network.GetNetworks().ToArray();
			List<Conflict> conflicts = new List<Conflict>();
			for(int n = 0 ; n < networks.Length ; n++)
			{
				for(int n2 = n + 1 ; n2 < networks.Length ; n2++)
				{
					var a = networks[n];
					var b = networks[n2];
					if(a == Network.RegTest || b == Network.RegTest)
						continue;
					if(a == b)
						throw new Exception();
					for(int i = 0 ; i < a.base58Prefixes.Length ; i++)
					{
						for(int y = i + 1 ; y < a.base58Prefixes.Length ; y++)
						{
							if(a.base58Prefixes[i] != null && b.base58Prefixes[y] != null)
							{
								var ae = Encoders.Hex.EncodeData(a.base58Prefixes[i]);
								var be = Encoders.Hex.EncodeData(b.base58Prefixes[y]);
								if(ae == be)
									continue;
								if(ae.StartsWith(be) || be.StartsWith(ae))
								{
									ConflictPart ca = new ConflictPart();
									ca.Network = a;
									ca.Type = (Base58Type)i;
									ca.Value = a.base58Prefixes[i];

									ConflictPart cb = new ConflictPart();
									cb.Network = b;
									cb.Type = (Base58Type)y;
									cb.Value = b.base58Prefixes[y];

									Conflict cc = new Conflict();
//.........这里部分代码省略.........
开发者ID:thesmartbit,项目名称:NBitcoin,代码行数:101,代码来源:RepositoryTests.cs

示例2: Play

		public static void Play()
		{
			new Key().PubKey.WitHash.GetAddress(Network.SegNet).ToString();

			var node = Node.Connect(Network.SegNet, "qbitninja-server.cloudapp.net");
			node.VersionHandshake();

			uint256 p2wsh = null;
			uint256 p2pwkh = null;
			uint256 p2wshp2sh = null;
			uint256 p2wpkhp2sh = null;
			foreach(var block in node.GetBlocks())
			{
				foreach(var tx in block.Transactions)
				{
					if(p2wsh != null && p2pwkh != null && p2wshp2sh != null && p2wpkhp2sh != null)
						break;
					if(!tx.IsCoinBase && !tx.Witness.IsEmpty)
					{
						foreach(var input in tx.Inputs.AsIndexedInputs())
						{
							if(input.WitScript == WitScript.Empty)
								continue;
							if(input.ScriptSig == Script.Empty)
							{
								if(PayToWitPubKeyHashTemplate.Instance.ExtractWitScriptParameters(input.WitScript) != null)
									p2pwkh = tx.GetHash();
								else
									p2wsh = tx.GetHash();
							}
							else
							{
								if(PayToWitPubKeyHashTemplate.Instance.ExtractWitScriptParameters(input.WitScript) != null)
									p2wpkhp2sh = tx.GetHash();
								else
									p2wshp2sh = tx.GetHash();
							}
							break;
						}
					}
				}
			}

			var secret = new BitcoinSecret("QTrKVpsVwNUD9GayzdbUNz2NNDqiPgjd9RCprwSa4gmBFg3V2oik", Network.SegNet);

			var oo = secret.PubKey.WitHash.GetAddress(Network.SegNet);

			var key = new Key().GetBitcoinSecret(Network.SegNet);
			var aa = key.GetAddress();
			foreach(var n in new[]{Network.Main, Network.SegNet})
			{
				for(int i = 0; i < 2;i++)
				{
					BitcoinAddress addr = i == 0 ? (BitcoinAddress)new Key().PubKey.GetSegwitAddress(n) : new Key().ScriptPubKey.GetWitScriptAddress(n);
					var c = addr.ScriptPubKey.ToString();
				}
			}


			var networks = Network.GetNetworks().ToArray();		
			List<Conflict> conflicts = new List<Conflict>();
			for(int n = 0 ; n < networks.Length ; n++)
			{
				for(int n2 = n+1; n2 < networks.Length ; n2++)
				{
					var a = networks[n];
					var b = networks[n2];
					if(a == Network.RegTest || b == Network.RegTest)
						continue;
					if(a == b)
						throw new Exception();
					for(int i = 0 ; i < a.base58Prefixes.Length ; i++)
					{
						for(int y = i + 1 ; y < a.base58Prefixes.Length ; y++)
						{
							if(a.base58Prefixes[i] != null && b.base58Prefixes[y] != null)
							{
								var ae = Encoders.Hex.EncodeData(a.base58Prefixes[i]);
								var be = Encoders.Hex.EncodeData(b.base58Prefixes[y]);
								if(ae == be)
									continue;
								if(ae.StartsWith(be) || be.StartsWith(ae))
								{
									ConflictPart ca = new ConflictPart();
									ca.Network = a;
									ca.Type = (Base58Type)i;
									ca.Value = a.base58Prefixes[i];

									ConflictPart cb = new ConflictPart();
									cb.Network = b;
									cb.Type = (Base58Type)y;
									cb.Value = b.base58Prefixes[y];

									Conflict cc = new Conflict();
									cc.A = ca;
									cc.B = cb;
									conflicts.Add(cc);
								}
							}
						}
//.........这里部分代码省略.........
开发者ID:n1rvana,项目名称:NBitcoin,代码行数:101,代码来源:RepositoryTests.cs


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