Skip to content

Commit

Permalink
Remove non resolvable ScriptPubKeyType enums
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasDorier committed Jan 17, 2024
1 parent 4579d07 commit a613abf
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 46 deletions.
2 changes: 1 addition & 1 deletion NBitcoin.Altcoins/NBitcoin.Altcoins.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<TargetFrameworks Condition="'$(TargetFrameworkOverride)' != ''">$(TargetFrameworkOverride)</TargetFrameworks>
<NoWarn>1591;1573;1572;1584;1570;3021</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Version>3.0.22</Version>
<Version>3.0.23</Version>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\NBitcoin\NBitcoin.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion NBitcoin.Secp256k1/NBitcoin.Secp256k1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>
<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.1</TargetFrameworks>
<Version Condition=" '$(Version)' == '' ">3.1.2</Version>
<Version Condition=" '$(Version)' == '' ">3.1.3</Version>
</PropertyGroup>
<PropertyGroup>
<DefineConstants>$(DefineConstants);SECP256K1_LIB;HAS_SPAN</DefineConstants>
Expand Down
2 changes: 1 addition & 1 deletion NBitcoin.TestFramework/NBitcoin.TestFramework.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<VersionPrefix>3.0.25</VersionPrefix>
<VersionPrefix>3.0.26</VersionPrefix>
<LangVersion>9.0</LangVersion>
<TargetFrameworks>netstandard1.6;net472;netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition="'$(BuildingInsideVisualStudio)' == 'true'">netstandard2.1</TargetFrameworks>
Expand Down
10 changes: 5 additions & 5 deletions NBitcoin.Tests/OutputDescriptorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,17 @@ public void DescriptorTests()

#if HAS_SPAN
CheckDescriptor(Network.Main, "tr(L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1)", "tr(a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd)", "tr(a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd)", SIGNABLE | XONLY_KEYS, new [] { new [] {"512077aab6e066f8a7419c5ab714c12c67d25007ed55a43cadcacb4d7a970a093f11"}}, ScriptPubKeyType.TaprootBIP86);
CheckDescriptor(Network.Main, "tr(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5,{pk(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5),{pk(L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1),pk(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5)}})", "tr(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5,{pk(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5),{pk(a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd),pk(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5)}})", "tr(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5,{pk(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5),{pk(a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd),pk(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5)}})", XONLY_KEYS | MISSING_PRIVKEYS, new []{ new []{"51201497ae16f30dacb88523ed9301bff17773b609e8a90518a3f96ea328a47d1500"}}, ScriptPubKeyType.TaprootWithScript);
CheckDescriptor(Network.Main, "tr(xprvA1RpRA33e1JQ7ifknakTFpgNXPmW2YvmhqLQYMmrj4xJXXWYpDPS3xz7iAxn8L39njGVyuoseXzU6rcxFLJ8HFsTjSyQbLYnMpCqE2VbFWc/0/*,pk(xprvA1RpRA33e1JQ7ifknakTFpgNXPmW2YvmhqLQYMmrj4xJXXWYpDPS3xz7iAxn8L39njGVyuoseXzU6rcxFLJ8HFsTjSyQbLYnMpCqE2VbFWc/1/*))", "tr(xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/0/*,pk(xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/1/*))", "tr(xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/0/*,pk(xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/1/*))", XONLY_KEYS | RANGE, new []{new []{"512078bc707124daa551b65af74de2ec128b7525e10f374dc67b64e00ce0ab8b3e12"}, new[] {"512001f0a02a17808c20134b78faab80ef93ffba82261ccef0a2314f5d62b6438f11"}, new[]{"512021024954fcec88237a9386fce80ef2ced5f1e91b422b26c59ccfc174c8d1ad25"}}, ScriptPubKeyType.TaprootWithScript, new []{ new uint[]{0, 0}, new uint[]{0, 1}, new uint[]{0, 2}, new uint[]{1, 0}, new uint[]{1, 1}, new uint[]{1, 2}});
CheckDescriptor(Network.Main, "tr(L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1,pk(KzoAz5CanayRKex3fSLQ2BwJpN7U52gZvxMyk78nDMHuqrUxuSJy))", "tr(a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd,pk(669b8afcec803a0d323e9a17f3ea8e68e8abe5a278020a929adbec52421adbd0))", "tr(a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd,pk(669b8afcec803a0d323e9a17f3ea8e68e8abe5a278020a929adbec52421adbd0))", XONLY_KEYS, new []{new []{"512017cf18db381d836d8923b1bdb246cfcd818da1a9f0e6e7907f187f0b2f937754"}}, ScriptPubKeyType.TaprootWithScript);
CheckDescriptor(Network.Main, "tr(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5,{pk(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5),{pk(L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1),pk(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5)}})", "tr(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5,{pk(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5),{pk(a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd),pk(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5)}})", "tr(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5,{pk(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5),{pk(a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd),pk(03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5)}})", XONLY_KEYS | MISSING_PRIVKEYS, new []{ new []{"51201497ae16f30dacb88523ed9301bff17773b609e8a90518a3f96ea328a47d1500"}}, null);
CheckDescriptor(Network.Main, "tr(xprvA1RpRA33e1JQ7ifknakTFpgNXPmW2YvmhqLQYMmrj4xJXXWYpDPS3xz7iAxn8L39njGVyuoseXzU6rcxFLJ8HFsTjSyQbLYnMpCqE2VbFWc/0/*,pk(xprvA1RpRA33e1JQ7ifknakTFpgNXPmW2YvmhqLQYMmrj4xJXXWYpDPS3xz7iAxn8L39njGVyuoseXzU6rcxFLJ8HFsTjSyQbLYnMpCqE2VbFWc/1/*))", "tr(xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/0/*,pk(xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/1/*))", "tr(xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/0/*,pk(xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/1/*))", XONLY_KEYS | RANGE, new []{new []{"512078bc707124daa551b65af74de2ec128b7525e10f374dc67b64e00ce0ab8b3e12"}, new[] {"512001f0a02a17808c20134b78faab80ef93ffba82261ccef0a2314f5d62b6438f11"}, new[]{"512021024954fcec88237a9386fce80ef2ced5f1e91b422b26c59ccfc174c8d1ad25"}}, null, new []{ new uint[]{0, 0}, new uint[]{0, 1}, new uint[]{0, 2}, new uint[]{1, 0}, new uint[]{1, 1}, new uint[]{1, 2}});
CheckDescriptor(Network.Main, "tr(L4rK1yDtCWekvXuE6oXD9jCYfFNV2cWRpVuPLBcCU2z8TrisoyY1,pk(KzoAz5CanayRKex3fSLQ2BwJpN7U52gZvxMyk78nDMHuqrUxuSJy))", "tr(a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd,pk(669b8afcec803a0d323e9a17f3ea8e68e8abe5a278020a929adbec52421adbd0))", "tr(a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd,pk(669b8afcec803a0d323e9a17f3ea8e68e8abe5a278020a929adbec52421adbd0))", XONLY_KEYS, new []{new []{"512017cf18db381d836d8923b1bdb246cfcd818da1a9f0e6e7907f187f0b2f937754"}}, null);
CheckDescriptor(
Network.Main,
"rawtr(xprv9vHkqa6EV4sPZHYqZznhT2NPtPCjKuDKGY38FBWLvgaDx45zo9WQRUT3dKYnjwih2yJD9mkrocEZXo1ex8G81dwSM1fwqWpWkeS3v86pgKt/86'/1'/0'/1/*)#a5gn3t7k",
"rawtr(xpub69H7F5d8KSRgmmdJg2KhpAK8SR3DjMwAdkxj3ZuxV27CprR9LgpeyGmXUbC6wb7ERfvrnKZjXoUmmDznezpbZb7ap6r1D3tgFxHmwMkQTPH/86'/1'/0'/1/*)#4ur3xhft",
"rawtr([5a61ff8e/86'/1'/0']xpub6DtZpc9PRL2B6pwoNGysmHAaBofDmWv5S6KQEKKGPKhf5fV62ywDtSziSApYVK3JnYY5KUSgiCwiXW5wtd8z7LNBxT9Mu5sEro8itdGfTeA/1/*)#llheyd9x",
RANGE | HARDENED | XONLY_KEYS,
new []{ new []{"51205172af752f057d543ce8e4a6f8dcf15548ec6be44041bfa93b72e191cfc8c1ee"}, new []{"51201b66f20b86f700c945ecb9ad9b0ad1662b73084e2bfea48bee02126350b8a5b1"}, new []{"512063e70f66d815218abcc2306aa930aaca07c5cde73b75127eb27b5e8c16b58a25"}},
ScriptPubKeyType.TaprootRaw,
null,
new []{ new uint []{0x80000056, 0x80000001, 0x80000000, 1, 0}, new uint []{0x80000056, 0x80000001, 0x80000000, 1, 1}, new uint []{0x80000056, 0x80000001, 0x80000000, 1, 2}});

CheckDescriptor(
Expand All @@ -249,7 +249,7 @@ public void DescriptorTests()
"rawtr(a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd)",
XONLY_KEYS,
new[] { new[] { "5120a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd" } },
ScriptPubKeyType.TaprootRaw
null
);

CheckUnparsable(
Expand Down
5 changes: 1 addition & 4 deletions NBitcoin.Tests/RPCClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -730,13 +730,10 @@ public void CanCalculateDustCorrectly()
{
#if !HAS_SPAN
#pragma warning disable CS0618
if (scriptPubKeyType == ScriptPubKeyType.TaprootBIP86 ||
scriptPubKeyType == ScriptPubKeyType.TaprootRaw)
if (scriptPubKeyType == ScriptPubKeyType.TaprootBIP86)
continue;
#pragma warning restore CS0618
#endif
if (scriptPubKeyType == ScriptPubKeyType.TaprootWithScript)
continue;
Transaction paid = builder.Network.CreateTransaction();
paid.Inputs.Add(coin.Outpoint);
var dest = new Key().GetAddress(scriptPubKeyType, builder.Network);
Expand Down
2 changes: 1 addition & 1 deletion NBitcoin/NBitcoin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<RepositoryType>git</RepositoryType>
</PropertyGroup>
<PropertyGroup>
<Version Condition=" '$(Version)' == '' ">7.0.33</Version>
<Version Condition=" '$(Version)' == '' ">7.0.34</Version>
<LangVersion>9.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
Expand Down
32 changes: 1 addition & 31 deletions NBitcoin/PubKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,7 @@ public enum ScriptPubKeyType
#if !HAS_SPAN
[Obsolete("TaprootBIP86 is unavailable in .net framework")]
#endif
TaprootBIP86,

/// <summary>
/// Taproot with possible script-spend.
/// </summary>
#if !HAS_SPAN
[Obsolete("TaprootWithScript is unavailable in .net framework")]
#endif
TaprootWithScript,

/// <summary>
/// Taproot output that we don't know if the script path exists or not.
/// </summary>
#if !HAS_SPAN
[Obsolete("TaprootRaw is unavailable in .net framework")]
#endif
TaprootRaw
TaprootBIP86
}
public class PubKey : IDestination, IComparable<PubKey>, IEquatable<PubKey>, IPubKey
{
Expand Down Expand Up @@ -328,20 +312,6 @@ public BitcoinAddress GetAddress(ScriptPubKeyType type, Network network)
#else
return GetTaprootFullPubKey().GetAddress(network);
#endif
#pragma warning disable CS0618 // Type or member is obsolete
case ScriptPubKeyType.TaprootRaw:
#pragma warning restore CS0618 // Type or member is obsolete
if (!network.Consensus.SupportTaproot)
throw new NotSupportedException("This network does not support taproot");
#if !HAS_SPAN
throw new NotSupportedException("This feature of taproot is not supported in .NET Framework");
#else
return GetTaprootFullPubKey().GetAddress(network);
#endif
#pragma warning disable CS0618 // Type or member is obsolete
case ScriptPubKeyType.TaprootWithScript:
#pragma warning restore CS0618 // Type or member is obsolete
throw new NotSupportedException("Can not get address from pubkey without script.");
default:
throw new NotSupportedException("Unsupported ScriptPubKeyType");
}
Expand Down
3 changes: 1 addition & 2 deletions NBitcoin/Scripting/OutputDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -925,8 +925,7 @@ private static PubKeyProvider InferPubKey(PubKey pk, ISigningRepository repo)
Tr self =>
self.TapLeafs is null ?
ScriptPubKeyType.TaprootBIP86 :
ScriptPubKeyType.TaprootWithScript,
RawTr => ScriptPubKeyType.TaprootRaw,
null,
#endif
_ => null
};
Expand Down

0 comments on commit a613abf

Please sign in to comment.