Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions NBitcoin/Network.cs
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,7 @@ public BitcoinScriptAddress CreateBitcoinScriptAddress(string base58)
{
return GetBase58Type(NetworkStringParser.GetBase58CheckEncoder().DecodeData(base58), out _);
}

private Base58Type? GetBase58Type(byte[] bytes, out int prefixLength)
{
for (int i = 0; i < base58Prefixes.Length; i++)
Expand All @@ -1005,7 +1006,6 @@ public BitcoinScriptAddress CreateBitcoinScriptAddress(string base58)
return null;
}


internal static Network? GetNetworkFromBase58Data(string base58, Base58Type? expectedType = null)
{
foreach (var network in GetNetworks())
Expand Down Expand Up @@ -1035,10 +1035,12 @@ public T Parse<T>(string str) where T : IBitcoinString
{
return (T)Parse(str, typeof(T));
}

public IBitcoinString Parse(string str)
{
return Parse(str, null);
}

public IBitcoinString Parse(string str, Type? targetType)
{
if (str == null)
Expand Down Expand Up @@ -1067,9 +1069,8 @@ public IBitcoinString Parse(string str, Type? targetType)
}

int i = -1;
#if !NO_TUPLE
(Bech32Encoder? encoder, byte[]? bytes, byte witVersion) cache = (null, null, 0);
#endif

foreach (var encoder in bech32Encoders)
{
i++;
Expand All @@ -1078,7 +1079,6 @@ public IBitcoinString Parse(string str, Type? targetType)
var type = (Bech32Type)i;
try
{
#if !NO_TUPLE
byte witVersion;
byte[] bytes;
if (cache.encoder == encoder && cache.bytes is not null)
Expand All @@ -1091,9 +1091,7 @@ public IBitcoinString Parse(string str, Type? targetType)
bytes = encoder.Decode(str, out witVersion);
cache = (encoder, bytes, witVersion);
}
#else
byte[] bytes = encoder.Decode(str, out var witVersion);
#endif

IBitcoinString? candidate = null;
if (witVersion == 0 && bytes.Length == 20 && type == Bech32Type.WITNESS_PUBKEY_ADDRESS)
candidate = new BitcoinWitPubKeyAddress(str.ToLowerInvariant(), bytes, this);
Expand Down
3 changes: 2 additions & 1 deletion NBitcoin/PriorityQueue.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#if !NET10_0_OR_GREATER && !NO_TUPLE
#if !NET10_0_OR_GREATER
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;

namespace NBitcoin
{

Expand Down
Loading