asp.net-core - 已过时的“改用 GetAddress(ScriptPubKeyType.Legacy)”
问题描述
using System;
using NBitcoin;
namespace RSA
{
public class RSA
{
public static Wallet KeyGenerate()
{
Key privateKey = new Key();
var v = privateKey.GetBitcoinSecret(Network.Main).GetAddress();
var address = BitcoinAddress.Create(v.ToString(), Network.Main);
return new Wallet { PublicKey = v.ToString(), PrivateKey = privateKey.GetBitcoinSecret(Network.Main).ToString() };
}
}
}
我得到了这种警告,请任何人帮助如何解决它?
解决方案
如前所述Progman
,您可以改用GetAddress(ScriptPublicKeyType.Legacy)
to BitcoinSecret.getAddress()
。
下面是 GetAddress(ScriptPublicKeyType.Legacy) 的用法:
var v = privateKey.PubKey.GetAddress(ScriptPubKeyType.Legacy, Network.Main);
此外,如果您不想更改方法。您可以使用[Obsolete]
.
这是一个演示:Program.cs:</p>
[Obsolete]
class Program
{
static void Main(string[] args) {
KeyGenerate();
}
public static Wallet KeyGenerate()
{
Key privateKey = new Key();
var v = privateKey.GetBitcoinSecret(Network.Main).GetAddress();
Console.WriteLine(v);
var v1 = privateKey.PubKey.GetAddress(ScriptPubKeyType.Legacy, Network.Main);
Console.WriteLine(v1);
var address = BitcoinAddress.Create(v.ToString(), Network.Main);
return new Wallet { PublicKey = v.ToString(), PrivateKey = privateKey.GetBitcoinSecret(Network.Main).ToString() };
}
}
结果:
推荐阅读
- javascript - java - 如何在java脚本中定位privious元素的前一个元素?
- node.js - 在 Nodejs、Telegram API 中,messages.sendMultiMedia 方法不起作用?
- javascript - 如何在 ngFor 内单击以突出显示选定的单选按钮
- python - 使用 Python 请求下载文件时连接重置
- reactjs - 将图像置于文本之上
- c# - 找不到适用于应用程序的有效“aps-environment”权利字符串,Microsoft iOS 推送通知教程存在问题
- javascript - 如何在 Javascript 中增加 marginLeft onclick?
- c++ - C++:文件节拍进程运行时使用文件库写入文件的问题
- reactjs - Jest 和 Enzyme 配置无法正常运行我的 React/Typescript 项目
- java - 如何修复 Jar 文件的 JNI 问题?