diff --git a/Src/Autarkysoft.Bitcoin/Blockchain/Consensus.cs b/Src/Autarkysoft.Bitcoin/Blockchain/Consensus.cs index db1849e..511eeb3 100644 --- a/Src/Autarkysoft.Bitcoin/Blockchain/Consensus.cs +++ b/Src/Autarkysoft.Bitcoin/Blockchain/Consensus.cs @@ -47,7 +47,7 @@ public Consensus(NetworkType netType) : this(0, netType) /// Network type public Consensus(int height, NetworkType netType) { - // https://github.com/bitcoin/bitcoin/blob/544709763e1f45148d1926831e07ff03487673ee/src/chainparams.cpp + // https://github.com/bitcoin/bitcoin/blob/349632e022da22a457a85650360b5be41fa500dc/src/kernel/chainparams.cpp switch (netType) { case NetworkType.MainNet: @@ -76,13 +76,26 @@ public Consensus(int height, NetworkType netType) seg = 834624; tap = 2064268; break; + case NetworkType.TestNet4: + PowLimit = Digest256.ParseHex("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); + AllowMinDifficultyBlocks = true; + MaxSigOpCount = 80000; + HalvingInterval = 210000; + bip16 = 1; + bip34 = 1; + bip65 = 1; + bip66 = 1; + bip112 = 1; + seg = 1; + tap = 1; + break; case NetworkType.RegTest: PowLimit = Digest256.ParseHex("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); AllowMinDifficultyBlocks = true; MaxSigOpCount = 80000; HalvingInterval = 150; bip16 = 0; - bip34 = 500; + bip34 = 1; bip65 = 1351; bip66 = 1251; bip112 = 432; @@ -206,11 +219,30 @@ public IBlock GetGenesisBlock() { NetworkType.MainNet => CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, 50_0000_0000), NetworkType.TestNet => CreateGenesisBlock(1296688602, 414098458, 0x1d00ffff, 1, 50_0000_0000), + NetworkType.TestNet4 => CreateTestNet4GenesisBlock(1714777860, 393743547, 0x1d00ffff, 1, 50_0000_0000), NetworkType.RegTest => CreateGenesisBlock(1296688602, 2, 0x207fffff, 1, 50_0000_0000), _ => throw new ArgumentException(Errors.InvalidNetwork.Convert()), }; } + private Block CreateTestNet4GenesisBlock(uint time, uint nonce, Target nbits, int version, ulong reward) + { + string timestamp = "03/May/2024 000000000000000000001ebd58c244970b3aa9d783bb001011fbe8ea8e98e00e"; + byte[] tsBytes = Encoding.UTF8.GetBytes(timestamp); + byte[] sigData = new byte[9 + tsBytes.Length]; + Buffer.BlockCopy(Base16.Decode("04ffff001d01044c4c"), 0, sigData, 0, 9); + Buffer.BlockCopy(tsBytes, 0, sigData, 9, tsBytes.Length); + var sigScr = new SignatureScript(sigData); + + var pubOps = new IOperation[] + { + new PushDataOp(new byte[33]), + new CheckSigOp() + }; + var pubScr = new PubkeyScript(pubOps); + return CreateGenesisBlock(version, time, nbits, nonce, 1, sigScr, reward, pubScr); + } + /// public Block CreateGenesisBlock(uint time, uint nonce, Target nbits, int version, ulong reward) { diff --git a/Src/Autarkysoft.Bitcoin/Clients/ClientSettingsBase.cs b/Src/Autarkysoft.Bitcoin/Clients/ClientSettingsBase.cs index 02443a6..df38428 100644 --- a/Src/Autarkysoft.Bitcoin/Clients/ClientSettingsBase.cs +++ b/Src/Autarkysoft.Bitcoin/Clients/ClientSettingsBase.cs @@ -42,6 +42,7 @@ public ClientSettingsBase(NetworkType netType, int maxConnection, NodePool nodes { NetworkType.MainNet => Constants.MainNetPort, NetworkType.TestNet => Constants.TestNetPort, + NetworkType.TestNet4 => Constants.TestNet4Port, NetworkType.RegTest => Constants.RegTestPort, _ => throw new ArgumentException("Undefined network"), }; @@ -85,6 +86,7 @@ public string UserAgent set => _ua = value ?? string.Empty; } + // TODO: make this readonly? /// public NetworkType Network { get; set; } /// diff --git a/Src/Autarkysoft.Bitcoin/Constants.cs b/Src/Autarkysoft.Bitcoin/Constants.cs index b05ae9f..34b6259 100644 --- a/Src/Autarkysoft.Bitcoin/Constants.cs +++ b/Src/Autarkysoft.Bitcoin/Constants.cs @@ -114,10 +114,14 @@ public struct Constants /// public const ushort MainNetPort = 8333; /// - /// Default test network port + /// Default test network v3 port /// public const ushort TestNetPort = 18333; /// + /// Default test network v4 port + /// + public const ushort TestNet4Port = 48333; + /// /// Default regtest network port /// public const ushort RegTestPort = 18444; @@ -126,10 +130,14 @@ public struct Constants /// public const string MainNetMagic = "f9beb4d9"; /// - /// 4 byte "magic" value used in P2P message headers for test-net + /// 4 byte "magic" value used in P2P message headers for test-net v3 /// public const string TestNetMagic = "0b110907"; /// + /// 4 byte "magic" value used in P2P message headers for test-net v4 + /// + public const string TestNet4Magic = "1c163f28"; + /// /// 4 byte "magic" value used in P2P message headers for reg-test /// public const string RegTestMagic = "fabfb5da"; @@ -201,7 +209,7 @@ public static string[] GetMainNetDnsSeeds() } /// - /// Returns a list of DNS seeds used for initial peer discovery on TestNet. + /// Returns a list of DNS seeds used for initial peer discovery on TestNet v3. /// /// List of TestNet DNS seeds public static string[] GetTestNetDnsSeeds() @@ -215,6 +223,20 @@ public static string[] GetTestNetDnsSeeds() "testnet-seed.bluematt.me", // Just a static list of stable node(s), only supports x9 }; } + + /// + /// Returns a list of DNS seeds used for initial peer discovery on TestNet. + /// + /// List of TestNet DNS seeds + public static string[] GetTestNet4DnsSeeds() + { + // https://github.com/bitcoin/bitcoin/blob/00ac1b963d08f2779d2197edcdb1e76392993378/src/kernel/chainparams.cpp#L245-L248 + return new string[] + { + "seed.testnet4.bitcoin.sprovoost.nl", // Sjors Provoost + "seed.testnet4.wiz.biz", // Jason Maurice + }; + } } diff --git a/Src/Autarkysoft.Bitcoin/Cryptography/EllipticCurve/PrivateKey.cs b/Src/Autarkysoft.Bitcoin/Cryptography/EllipticCurve/PrivateKey.cs index 2548a1a..fff13c6 100644 --- a/Src/Autarkysoft.Bitcoin/Cryptography/EllipticCurve/PrivateKey.cs +++ b/Src/Autarkysoft.Bitcoin/Cryptography/EllipticCurve/PrivateKey.cs @@ -141,6 +141,7 @@ public PrivateKey(string wif, NetworkType netType = NetworkType.MainNet) private const int KeyByteSize = 32; private const byte MainNetByte = 128; private const byte TestNetByte = 239; + private const byte TestNet4Byte = 239; private const byte RegTestByte = 239; private const byte CompressedByte = 1; // Don't rename, used by tests with reflection. @@ -177,6 +178,7 @@ protected byte GetWifFirstByte(NetworkType netType) { NetworkType.MainNet => MainNetByte, NetworkType.TestNet => TestNetByte, + NetworkType.TestNet4 => TestNet4Byte, NetworkType.RegTest => RegTestByte, _ => throw new ArgumentException("Network type is not defined!"), }; diff --git a/Src/Autarkysoft.Bitcoin/Encoders/Address.cs b/Src/Autarkysoft.Bitcoin/Encoders/Address.cs index eaeea3a..589bb1d 100644 --- a/Src/Autarkysoft.Bitcoin/Encoders/Address.cs +++ b/Src/Autarkysoft.Bitcoin/Encoders/Address.cs @@ -18,14 +18,17 @@ public static class Address { private const byte P2pkhVerMainNet = 0; private const byte P2pkhVerTestNet = 111; - private const byte P2pkhVerRegTest = 0; + private const byte P2pkhVerTestNet4 = 111; + private const byte P2pkhVerRegTest = 111; private const byte P2shVerMainNet = 5; private const byte P2shVerTestNet = 196; - private const byte P2shVerRegTest = 5; + private const byte P2shVerTestNet4 = 196; + private const byte P2shVerRegTest = 196; private const string HrpMainNet = "bc"; private const string HrpTestNet = "tb"; + private const string HrpTestNet4 = "tb"; private const string HrpRegTest = "bcrt"; @@ -55,6 +58,7 @@ public static AddressType GetAddressType(string address, NetworkType netType, ou { if ((netType == NetworkType.MainNet && decoded[0] == P2pkhVerMainNet) || (netType == NetworkType.TestNet && decoded[0] == P2pkhVerTestNet) || + (netType == NetworkType.TestNet4 && decoded[0] == P2pkhVerTestNet4) || (netType == NetworkType.RegTest && decoded[0] == P2pkhVerRegTest)) { data = decoded.SubArray(1); @@ -62,6 +66,7 @@ public static AddressType GetAddressType(string address, NetworkType netType, ou } else if ((netType == NetworkType.MainNet && decoded[0] == P2shVerMainNet) || (netType == NetworkType.TestNet && decoded[0] == P2shVerTestNet) || + (netType == NetworkType.TestNet4 && decoded[0] == P2shVerTestNet4) || (netType == NetworkType.RegTest && decoded[0] == P2shVerRegTest)) { data = decoded.SubArray(1); @@ -79,6 +84,7 @@ public static AddressType GetAddressType(string address, NetworkType netType, ou TransactionVerifier.IsNotZero20(decoded) && ((netType == NetworkType.MainNet && hrp == HrpMainNet) || (netType == NetworkType.TestNet && hrp == HrpTestNet) || + (netType == NetworkType.TestNet4 && hrp == HrpTestNet4) || (netType == NetworkType.RegTest && hrp == HrpRegTest))) { data = decoded; @@ -88,6 +94,7 @@ public static AddressType GetAddressType(string address, NetworkType netType, ou TransactionVerifier.IsNotZero32(decoded) && ((netType == NetworkType.MainNet && hrp == HrpMainNet) || (netType == NetworkType.TestNet && hrp == HrpTestNet) || + (netType == NetworkType.TestNet4 && hrp == HrpTestNet4) || (netType == NetworkType.RegTest && hrp == HrpRegTest))) { data = decoded; @@ -127,6 +134,7 @@ public static AddressType GetAddressType(string address, NetworkType netType, ou if (TransactionVerifier.IsNotZero32(decoded) && ((netType == NetworkType.MainNet && hrp == HrpMainNet) || (netType == NetworkType.TestNet && hrp == HrpTestNet) || + (netType == NetworkType.TestNet4 && hrp == HrpTestNet4) || (netType == NetworkType.RegTest && hrp == HrpRegTest))) { data = decoded; @@ -174,6 +182,7 @@ public static string GetP2pkh(in Point pubk, bool useCompressed = true, NetworkT { NetworkType.MainNet => P2pkhVerMainNet, NetworkType.TestNet => P2pkhVerTestNet, + NetworkType.TestNet4 => P2pkhVerTestNet4, NetworkType.RegTest => P2pkhVerRegTest, _ => throw new ArgumentException(Errors.InvalidNetwork.Convert()) }; @@ -202,6 +211,7 @@ public static string GetP2sh(IScript redeem, NetworkType netType = NetworkType.M { NetworkType.MainNet => P2shVerMainNet, NetworkType.TestNet => P2shVerTestNet, + NetworkType.TestNet4 => P2shVerTestNet4, NetworkType.RegTest => P2shVerRegTest, _ => throw new ArgumentException(Errors.InvalidNetwork.Convert()) }; @@ -231,6 +241,7 @@ public static string GetP2wpkh(in Point pubk, bool useCompressed = true, Network { NetworkType.MainNet => HrpMainNet, NetworkType.TestNet => HrpTestNet, + NetworkType.TestNet4 => HrpTestNet4, NetworkType.RegTest => HrpRegTest, _ => throw new ArgumentException(Errors.InvalidNetwork.Convert()), }; @@ -259,8 +270,11 @@ public static string GetP2wpkh(in Point pubk, bool useCompressed = true, Network /// The resulting address public static string GetP2sh_P2wpkh(in Point pubk, bool useCompressed = true, NetworkType netType = NetworkType.MainNet) { - if (netType != NetworkType.MainNet && netType != NetworkType.TestNet && netType != NetworkType.RegTest) + if (netType != NetworkType.MainNet && netType != NetworkType.TestNet && + netType != NetworkType.TestNet4 && netType != NetworkType.RegTest) + { throw new ArgumentException(Errors.InvalidNetwork.Convert()); + } var rdm = new RedeemScript(); rdm.SetToP2SH_P2WPKH(pubk, useCompressed); @@ -285,6 +299,7 @@ public static string GetP2wsh(IScript script, NetworkType netType = NetworkType. { NetworkType.MainNet => HrpMainNet, NetworkType.TestNet => HrpTestNet, + NetworkType.TestNet4 => HrpTestNet4, NetworkType.RegTest => HrpRegTest, _ => throw new ArgumentException(Errors.InvalidNetwork.Convert()), }; @@ -311,8 +326,11 @@ public static string GetP2sh_P2wsh(IScript script, NetworkType netType = Network { if (script is null) throw new ArgumentNullException(nameof(script), "Script can not be null."); - if (netType != NetworkType.MainNet && netType != NetworkType.TestNet && netType != NetworkType.RegTest) + if (netType != NetworkType.MainNet && netType != NetworkType.TestNet && + netType != NetworkType.TestNet4 && netType != NetworkType.RegTest) + { throw new ArgumentException(Errors.InvalidNetwork.Convert()); + } RedeemScript rdm = new RedeemScript(); rdm.SetToP2SH_P2WSH(script); @@ -342,6 +360,7 @@ public static string GetP2tr(byte[] data32, NetworkType netType = NetworkType.Ma { NetworkType.MainNet => HrpMainNet, NetworkType.TestNet => HrpTestNet, + NetworkType.TestNet4 => HrpTestNet4, NetworkType.RegTest => HrpRegTest, _ => throw new ArgumentException(Errors.InvalidNetwork.Convert()), }; @@ -388,6 +407,7 @@ public static bool VerifyType(string address, PubkeyScriptType scrType, out byte if (decoded.Length == 21 && (decoded[0] == P2pkhVerMainNet || decoded[0] == P2pkhVerTestNet || + decoded[0] == P2pkhVerTestNet4 || decoded[0] == P2pkhVerRegTest)) { hash = decoded.SubArray(1); @@ -402,6 +422,7 @@ public static bool VerifyType(string address, PubkeyScriptType scrType, out byte if (decoded.Length == 21 && (decoded[0] == P2shVerMainNet || decoded[0] == P2shVerTestNet || + decoded[0] == P2shVerTestNet4 || decoded[0] == P2shVerRegTest)) { hash = decoded.SubArray(1); @@ -414,7 +435,7 @@ public static bool VerifyType(string address, PubkeyScriptType scrType, out byte if (Bech32.TryDecode(address, Bech32.Mode.B32, out decoded, out byte witVer, out string hrp)) { if (witVer == 0 && decoded.Length == 20 && - (hrp == HrpMainNet || hrp == HrpTestNet || hrp == HrpRegTest)) + (hrp == HrpMainNet || hrp == HrpTestNet || hrp == HrpTestNet4 || hrp == HrpRegTest)) { if (!TransactionVerifier.IsNotZero20(decoded)) { @@ -431,7 +452,7 @@ public static bool VerifyType(string address, PubkeyScriptType scrType, out byte if (Bech32.TryDecode(address, Bech32.Mode.B32, out decoded, out witVer, out hrp)) { if (witVer == 0 && decoded.Length == 32 && - (hrp == HrpMainNet || hrp == HrpTestNet || hrp == HrpRegTest)) + (hrp == HrpMainNet || hrp == HrpTestNet || hrp == HrpTestNet4 || hrp == HrpRegTest)) { if (!TransactionVerifier.IsNotZero32(decoded)) { diff --git a/Src/Autarkysoft.Bitcoin/ImprovementProposals/BIP0178.cs b/Src/Autarkysoft.Bitcoin/ImprovementProposals/BIP0178.cs index 9c4d30e..fa1a25f 100644 --- a/Src/Autarkysoft.Bitcoin/ImprovementProposals/BIP0178.cs +++ b/Src/Autarkysoft.Bitcoin/ImprovementProposals/BIP0178.cs @@ -83,6 +83,7 @@ protected byte GetWifFirstByte(NetworkType netType) { NetworkType.MainNet => MainNetByte, NetworkType.TestNet => TestNetByte, + NetworkType.TestNet4 => TestNetByte, // TODO: should this be different? NetworkType.RegTest => RegTestByte, _ => throw new ArgumentException("Network type is not defined."), }; diff --git a/Src/Autarkysoft.Bitcoin/NetworkType.cs b/Src/Autarkysoft.Bitcoin/NetworkType.cs index 3132d27..f214f00 100644 --- a/Src/Autarkysoft.Bitcoin/NetworkType.cs +++ b/Src/Autarkysoft.Bitcoin/NetworkType.cs @@ -15,10 +15,14 @@ public enum NetworkType /// MainNet, /// - /// The test network + /// The test network (v3) /// TestNet, /// + /// The test network (v4) + /// + TestNet4, + /// /// The alternate network for testing /// RegTest diff --git a/Src/Autarkysoft.Bitcoin/P2PNetwork/MessageManager.cs b/Src/Autarkysoft.Bitcoin/P2PNetwork/MessageManager.cs index 13e6611..355c23a 100644 --- a/Src/Autarkysoft.Bitcoin/P2PNetwork/MessageManager.cs +++ b/Src/Autarkysoft.Bitcoin/P2PNetwork/MessageManager.cs @@ -39,6 +39,7 @@ public MessageManager(IClientSettings cs, IReplyManager repMan, INodeStatus ns) { NetworkType.MainNet => Base16.Decode(Constants.MainNetMagic), NetworkType.TestNet => Base16.Decode(Constants.TestNetMagic), + NetworkType.TestNet4 => Base16.Decode(Constants.TestNet4Magic), NetworkType.RegTest => Base16.Decode(Constants.RegTestMagic), _ => throw new ArgumentException(Errors.InvalidNetwork.Convert()) }; diff --git a/Src/Autarkysoft.Bitcoin/P2PNetwork/Messages/Message.cs b/Src/Autarkysoft.Bitcoin/P2PNetwork/Messages/Message.cs index cf5a968..3bec814 100644 --- a/Src/Autarkysoft.Bitcoin/P2PNetwork/Messages/Message.cs +++ b/Src/Autarkysoft.Bitcoin/P2PNetwork/Messages/Message.cs @@ -26,10 +26,11 @@ public Message(NetworkType netType) { networkMagic = netType switch { - // https://github.com/bitcoin/bitcoin/blob/b1b173994406158e5faa3c83b113da9d971ac104/src/chainparams.cpp + // https://github.com/bitcoin/bitcoin/blob/349632e022da22a457a85650360b5be41fa500dc/src/kernel/chainparams.cpp#L128-L131 // (pchMessageStart) NetworkType.MainNet => new byte[] { 0xf9, 0xbe, 0xb4, 0xd9 }, NetworkType.TestNet => new byte[] { 0x0b, 0x11, 0x09, 0x07 }, + NetworkType.TestNet4 => new byte[] { 0x1c, 0x16, 0x3f, 0x28 }, NetworkType.RegTest => new byte[] { 0xfa, 0xbf, 0xb5, 0xda }, _ => throw new ArgumentException("Invalid network type.") }; diff --git a/Src/Denovo/App.axaml.cs b/Src/Denovo/App.axaml.cs index 9b7724d..c35dc8c 100644 --- a/Src/Denovo/App.axaml.cs +++ b/Src/Denovo/App.axaml.cs @@ -39,6 +39,10 @@ public override void OnFrameworkInitializationCompleted() { network = NetworkType.TestNet; } + else if (value == "testnet4") + { + network = NetworkType.TestNet4; + } else if (value == "regtest") { network = NetworkType.RegTest; diff --git a/Src/Denovo/Models/Configuration.cs b/Src/Denovo/Models/Configuration.cs index e9fa60f..5a89416 100644 --- a/Src/Denovo/Models/Configuration.cs +++ b/Src/Denovo/Models/Configuration.cs @@ -29,6 +29,7 @@ public Configuration(NetworkType network) { NetworkType.MainNet => Constants.MainNetPort, NetworkType.TestNet => Constants.TestNetPort, + NetworkType.TestNet4 => Constants.TestNet4Port, NetworkType.RegTest => Constants.RegTestPort, _ => throw new ArgumentException("Undefined network type.") }; @@ -104,6 +105,7 @@ private string GetDnsList() { NetworkType.MainNet => string.Join(Environment.NewLine, Constants.GetMainNetDnsSeeds()), NetworkType.TestNet => string.Join(Environment.NewLine, Constants.GetTestNetDnsSeeds()), + NetworkType.TestNet4 => string.Join(Environment.NewLine, Constants.GetTestNet4DnsSeeds()), NetworkType.RegTest => "Not defined.", _ => "Not defined." }; diff --git a/Src/Denovo/ViewModels/PushTxViewModel.cs b/Src/Denovo/ViewModels/PushTxViewModel.cs index 4568b6e..c6c2dd3 100644 --- a/Src/Denovo/ViewModels/PushTxViewModel.cs +++ b/Src/Denovo/ViewModels/PushTxViewModel.cs @@ -9,7 +9,6 @@ using Autarkysoft.Bitcoin.Encoders; using Autarkysoft.Bitcoin.P2PNetwork.Messages; using Autarkysoft.Bitcoin.P2PNetwork.Messages.MessagePayloads; -using Denovo.Models; using Denovo.MVVM; using System; using System.Diagnostics; @@ -23,7 +22,7 @@ public PushTxViewModel() : base(450, 650) ConnectCommand = new BindableCommand(Connect, () => !IsConnected); PushCommand = new BindableCommand(Push, () => IsConnected); - NetworkList = new NetworkType[] { NetworkType.MainNet, NetworkType.TestNet }; + NetworkList = new NetworkType[] { NetworkType.MainNet, NetworkType.TestNet, NetworkType.TestNet4 }; } @@ -73,9 +72,27 @@ public void Connect() { settings = new(SelectedNetwork, 4, null) { - DnsSeeds = SelectedNetwork == NetworkType.MainNet ? Constants.GetMainNetDnsSeeds() : Constants.GetTestNetDnsSeeds(), UserAgent = "/Satoshi:0.22.0/", }; + + if (SelectedNetwork == NetworkType.MainNet) + { + settings.DnsSeeds = Constants.GetMainNetDnsSeeds(); + } + else if (SelectedNetwork == NetworkType.TestNet) + { + settings.DnsSeeds = Constants.GetTestNetDnsSeeds(); + } + else if (SelectedNetwork == NetworkType.TestNet4) + { + settings.DnsSeeds = Constants.GetTestNet4DnsSeeds(); + } + else + { + Result = "Network is not defined."; + return; + } + client = new(settings); client.Start(); IsConnected = true; diff --git a/Src/Tests/Bitcoin/Encoders/AddressTests.cs b/Src/Tests/Bitcoin/Encoders/AddressTests.cs index 097d0d8..b43b65d 100644 --- a/Src/Tests/Bitcoin/Encoders/AddressTests.cs +++ b/Src/Tests/Bitcoin/Encoders/AddressTests.cs @@ -33,22 +33,22 @@ public static IEnumerable GetTypeCases() yield return new object[] { " ", NetworkType.MainNet, AddressType.Invalid }; yield return new object[] { P2pkh_main, NetworkType.MainNet, AddressType.P2PKH }; yield return new object[] { P2pkh_main, NetworkType.TestNet, AddressType.Unknown }; - yield return new object[] { P2pkh_main, NetworkType.RegTest, AddressType.P2PKH }; + yield return new object[] { P2pkh_test, NetworkType.RegTest, AddressType.P2PKH }; yield return new object[] { "17VZNX1SN5NtKa8UQFxwQbFeFc3iqRYhe1", NetworkType.MainNet, AddressType.Unknown }; yield return new object[] { P2pkh_test, NetworkType.MainNet, AddressType.Unknown }; yield return new object[] { P2pkh_test, NetworkType.TestNet, AddressType.P2PKH }; - yield return new object[] { P2pkh_test, NetworkType.RegTest, AddressType.Unknown }; + yield return new object[] { P2pkh_main, NetworkType.RegTest, AddressType.Unknown }; yield return new object[] { "mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRf1", NetworkType.TestNet, AddressType.Unknown }; yield return new object[] { P2sh_main, NetworkType.MainNet, AddressType.P2SH }; yield return new object[] { P2sh_main, NetworkType.TestNet, AddressType.Unknown }; - yield return new object[] { P2sh_main, NetworkType.RegTest, AddressType.P2SH }; + yield return new object[] { P2sh_test, NetworkType.RegTest, AddressType.P2SH }; yield return new object[] { "3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQ1", NetworkType.MainNet, AddressType.Unknown }; yield return new object[] { P2sh_test, NetworkType.MainNet, AddressType.Unknown }; yield return new object[] { P2sh_test, NetworkType.TestNet, AddressType.P2SH }; - yield return new object[] { P2sh_test, NetworkType.RegTest, AddressType.Unknown }; + yield return new object[] { P2sh_main, NetworkType.RegTest, AddressType.Unknown }; yield return new object[] { "2MzQwSSnBHWHqSAqtTVQ6v47XtaisrJa1V1", NetworkType.TestNet, AddressType.Unknown }; yield return new object[] { P2wpkh_main, NetworkType.MainNet, AddressType.P2WPKH }; @@ -207,8 +207,8 @@ public static IEnumerable GetP2pkhCases() { yield return new object[] { KeyHelper.Pub1, true, NetworkType.MainNet, KeyHelper.Pub1CompAddr }; yield return new object[] { KeyHelper.Pub1, false, NetworkType.MainNet, KeyHelper.Pub1UnCompAddr }; - yield return new object[] { KeyHelper.Pub1, true, NetworkType.RegTest, KeyHelper.Pub1CompAddr }; - yield return new object[] { KeyHelper.Pub1, false, NetworkType.RegTest, KeyHelper.Pub1UnCompAddr }; + yield return new object[] { KeyHelper.Pub1, true, NetworkType.RegTest, "miYt1MwSMJbKF7LbRohHEfm4vAZnPCKArd" }; + yield return new object[] { KeyHelper.Pub1, false, NetworkType.RegTest, "mxD3KcWE9qwhv8hwXma75XDoYqrvHfxHtF" }; yield return new object[] { KeyHelper.Pub1, true, NetworkType.TestNet, "miYt1MwSMJbKF7LbRohHEfm4vAZnPCKArd" }; yield return new object[] { KeyHelper.Pub1, false, NetworkType.TestNet, "mxD3KcWE9qwhv8hwXma75XDoYqrvHfxHtF" }; @@ -251,7 +251,7 @@ public static IEnumerable GetP2shCases() { new MockSerializableRedeemScript(new byte[] { 1, 2, 3 }, 255), NetworkType.RegTest, - "3Fte5yfJErKGBSVMHpf93sdF6RmtSbTmL1" + "2N7Sr9ibKrJpcPE7txxH1fpcWJmz4FdhJiU" }; } [Theory] @@ -301,8 +301,8 @@ public static IEnumerable GetP2sh_P2wpkhCases() { yield return new object[] { KeyHelper.Pub1, true, NetworkType.MainNet, KeyHelper.Pub1NestedSegwit }; yield return new object[] { KeyHelper.Pub1, false, NetworkType.MainNet, KeyHelper.Pub1NestedSegwitUncomp }; - yield return new object[] { KeyHelper.Pub1, true, NetworkType.RegTest, KeyHelper.Pub1NestedSegwit }; - yield return new object[] { KeyHelper.Pub1, false, NetworkType.RegTest, KeyHelper.Pub1NestedSegwitUncomp }; + yield return new object[] { KeyHelper.Pub1, true, NetworkType.RegTest, "2N1UvtAhuV4nYsqVznNuYTPU2R9ajf49xaV" }; + yield return new object[] { KeyHelper.Pub1, false, NetworkType.RegTest, "2N6t2wK9J7Yi8NZgCV1nXHFKGFLK4xyDkQe" }; yield return new object[] { KeyHelper.Pub1, true, NetworkType.TestNet, "2N1UvtAhuV4nYsqVznNuYTPU2R9ajf49xaV" }; yield return new object[] { KeyHelper.Pub1, false, NetworkType.TestNet, "2N6t2wK9J7Yi8NZgCV1nXHFKGFLK4xyDkQe" }; yield return new object[] { KeyHelper.Pub2, true, NetworkType.MainNet, KeyHelper.Pub2NestedSegwit };