diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index d5ab189b01..524d3397d1 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -7,62 +7,47 @@ env: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: net60: - name: '6.0' + name: '8.0' runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0.x' + dotnet-version: '8.0.x' - run: ./Build/CI/tests.sh env: BUILD_ARGS: /p:AdditionalDefineConstants=SECP256K1_VERIFY - Framework: net6.0 - dotnetcore31: - name: '3.1' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '6.0.x' - - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '3.1.x' - - run: ./Build/CI/tests.sh - env: - BUILD_ARGS: /p:AdditionalDefineConstants=SECP256K1_VERIFY - Framework: netcoreapp3.1 + Framework: net8.0 dotnetcore60standard20: - name: '6.0 with netstandard2.0' + name: '8.0 with netstandard2.0' runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0.x' + dotnet-version: '8.0.x' - run: ./Build/CI/tests.sh env: BUILD_ARGS: /p:TargetFrameworkOverride=netstandard2.0 - Framework: net6.0 + Framework: net8.0 dotnetcore60macos: - name: '6.0 on Mac-OS' + name: '8.0 on Mac-OS' runs-on: macOS-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0.x' + dotnet-version: '8.0.x' - run: ./Build/CI/tests.sh env: - Framework: net6.0 + Framework: net8.0 dotnetcore60winfx: - name: '6.0 on Windows NetFramework472' + name: '8.0 on Windows NetFramework472' runs-on: windows-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0.x' + dotnet-version: '8.0.x' - run: dotnet clean -c Release ./NBitcoin.Tests/NBitcoin.Tests.csproj && dotnet nuget locals all --clear - run: dotnet test -c Release -v n ./NBitcoin.Tests/NBitcoin.Tests.csproj --filter "RestClient=RestClient|RPCClient=RPCClient|Protocol=Protocol|Core=Core|UnitTest=UnitTest|Altcoins=Altcoins|PropertyTest=PropertyTest" -p:ParallelizeTestCollections=false -f net472 diff --git a/NBitcoin.Altcoins/NBitcoin.Altcoins.csproj b/NBitcoin.Altcoins/NBitcoin.Altcoins.csproj index 03900d32a2..fcf291ee02 100644 --- a/NBitcoin.Altcoins/NBitcoin.Altcoins.csproj +++ b/NBitcoin.Altcoins/NBitcoin.Altcoins.csproj @@ -12,7 +12,7 @@ git - net6.0;net472;netstandard1.3;netstandard2.0;netstandard2.1 + net8.0;net472;netstandard1.3;netstandard2.0;netstandard2.1 netstandard2.1 $(TargetFrameworkOverride) 1591;1573;1572;1584;1570;3021 @@ -22,7 +22,7 @@ - + $(DefineConstants);HAS_SPAN true diff --git a/NBitcoin.Bench/NBitcoin.Bench.csproj b/NBitcoin.Bench/NBitcoin.Bench.csproj index cfd187a5d5..7b58f0f8bf 100644 --- a/NBitcoin.Bench/NBitcoin.Bench.csproj +++ b/NBitcoin.Bench/NBitcoin.Bench.csproj @@ -2,7 +2,7 @@ Exe - net6.0;netcoreapp3.1 + net8.0 pdbonly true diff --git a/NBitcoin.Secp256k1/NBitcoin.Secp256k1.csproj b/NBitcoin.Secp256k1/NBitcoin.Secp256k1.csproj index c5837e99c5..c4a7a52e4d 100644 --- a/NBitcoin.Secp256k1/NBitcoin.Secp256k1.csproj +++ b/NBitcoin.Secp256k1/NBitcoin.Secp256k1.csproj @@ -11,7 +11,7 @@ git - net6.0;netstandard2.1 + net8.0;netstandard2.1 3.1.4 diff --git a/NBitcoin.Tests/NBitcoin.Tests.csproj b/NBitcoin.Tests/NBitcoin.Tests.csproj index 06a46c31ad..e3310bd3fb 100644 --- a/NBitcoin.Tests/NBitcoin.Tests.csproj +++ b/NBitcoin.Tests/NBitcoin.Tests.csproj @@ -7,8 +7,8 @@ 9.0 - net6.0;netcoreapp3.1;net472 - net6.0 + net8.0;netcoreapp3.1;net472 + net8.0 @@ -25,7 +25,7 @@ $(DefineConstants);NETCORE;NOTRACESOURCE;NOCUSTOMSSLVALIDATION;NOHTTPSERVER - + $(DefineConstants);NETCORE;HAS_SPAN;NO_BC true diff --git a/NBitcoin.Tests/OutputDescriptorTests.cs b/NBitcoin.Tests/OutputDescriptorTests.cs index 9279e12a21..4e223cfa13 100644 --- a/NBitcoin.Tests/OutputDescriptorTests.cs +++ b/NBitcoin.Tests/OutputDescriptorTests.cs @@ -411,17 +411,18 @@ private void CheckDescriptorCore( Assert.Equal(spksInferred[0], spks[n]); Assert.Equal(((flags & UNSOLVABLE) == 0), OutputDescriptor.InferFromScript(spksInferred[0], providerInferred, Network.RegTest).IsSolvable()); - var originalKeyOrigins = scriptProvider.KeyOrigins; - var inferredKeyOrigins = - providerInferred.KeyOrigins; - Assert.Equal(originalKeyOrigins, inferredKeyOrigins); + AssertSameKeyOrigins(scriptProvider, providerInferred); } // Test whether the observed key path is present in the 'paths' variable (which contains expected, // unobserved paths), and then removed it from the set. if (pathIndex != null) { - var rootedKPs = scriptProvider.KeyOrigins; +#if HAS_SPAN + var rootedKPs = scriptProvider.TaprootKeyOrigins.Values.Concat(scriptProvider.KeyIdToKeyOrigins.Values); +#else + var rootedKPs = scriptProvider.KeyIdToKeyOrigins.Values; +#endif foreach (var rootedKP in rootedKPs) { Assert.Contains(pathIndex, p => p.SequenceEqual(rootedKP.KeyPath.Indexes)); @@ -443,6 +444,26 @@ private void CheckDescriptorCore( } } + private void AssertSameKeyOrigins(FlatSigningRepository expected, FlatSigningRepository actual) + { +#if HAS_SPAN + Assert.Equal(expected.TaprootKeyOrigins.Count, actual.TaprootKeyOrigins.Count); + foreach (var k in expected.TaprootKeyOrigins) + { + Assert.True(actual.TaprootKeyOrigins.TryGetValue(k.Key, out var v)); + Assert.Equal(k.Value.KeyPath, v.KeyPath); + Assert.Equal(k.Value.MasterFingerprint, v.MasterFingerprint); + } +#endif + Assert.Equal(expected.KeyIdToKeyOrigins.Count, actual.KeyIdToKeyOrigins.Count); + foreach (var k in expected.KeyIdToKeyOrigins) + { + Assert.True(actual.KeyIdToKeyOrigins.TryGetValue(k.Key, out var v)); + Assert.Equal(k.Value.KeyPath, v.KeyPath); + Assert.Equal(k.Value.MasterFingerprint, v.MasterFingerprint); + } + } + private void CheckUnparsable(Network network, string prv, string pub, string maybeErrorMsg = null) { var keysPrv = new FlatSigningRepository(); diff --git a/NBitcoin/NBitcoin.csproj b/NBitcoin/NBitcoin.csproj index 5bc0482a2f..7dd4383ca1 100644 --- a/NBitcoin/NBitcoin.csproj +++ b/NBitcoin/NBitcoin.csproj @@ -20,7 +20,7 @@ true - net472;netstandard1.3;netstandard1.1;netstandard2.1;netstandard2.0;net6.0 + net472;netstandard1.3;netstandard1.1;netstandard2.1;netstandard2.0;net8.0 $(TargetFrameworkOverride) 1591;1573;1572;1584;1570;3021 true @@ -33,10 +33,10 @@ $(DefineConstants);CLASSICDOTNET;NO_ARRAY_FILL;NULLABLE_SHIMS;NO_SOCKETASYNC - + $(DefineConstants);NOCUSTOMSSLVALIDATION;NO_NATIVERIPEMD160 - + $(DefineConstants);NETCORE;HAS_SPAN;NO_BC true @@ -57,7 +57,7 @@ - + diff --git a/NBitcoin/Scripting/OutputDescriptor.cs b/NBitcoin/Scripting/OutputDescriptor.cs index cac3ad94a2..17f6880a51 100644 --- a/NBitcoin/Scripting/OutputDescriptor.cs +++ b/NBitcoin/Scripting/OutputDescriptor.cs @@ -653,7 +653,8 @@ private bool ExpandPkHelper( return false; if (keyOrigin1 != null) { - repo.SetKeyOrigin(pubkey1.Hash, keyOrigin1); + if (!isTaproot) + repo.SetKeyOrigin(pubkey1.Hash, keyOrigin1); #if HAS_SPAN repo.SetKeyOrigin(pubkey1.TaprootPubKey, keyOrigin1); #endif diff --git a/NBitcoin/SigningRepository.cs b/NBitcoin/SigningRepository.cs index 3770928f09..1d4740056d 100644 --- a/NBitcoin/SigningRepository.cs +++ b/NBitcoin/SigningRepository.cs @@ -169,13 +169,6 @@ public class FlatSigningRepository : ISigningRepository public ConcurrentDictionary TaprootKeysToSecret { get; } #endif - public RootedKeyPath [] KeyOrigins => - KeyIdToKeyOrigins.Values.ToArray() -#if HAS_SPAN - .Concat(this.TaprootKeyOrigins.Values.ToArray()).ToArray() -#endif - ; - public FlatSigningRepository() { Secrets = new ConcurrentDictionary(); diff --git a/NBitcoin/TaprootPubKey.cs b/NBitcoin/TaprootPubKey.cs index 591d56e3cd..a31eb650bc 100644 --- a/NBitcoin/TaprootPubKey.cs +++ b/NBitcoin/TaprootPubKey.cs @@ -225,6 +225,11 @@ public bool CheckTapTweak(TaprootInternalPubKey internalPubKey, uint256? merkleR TaprootFullPubKey.ComputeTapTweak(internalPubKey, merkleRoot, tweak32); return this.pubkey.CheckIsTweakedWith(internalPubKey.pubkey, tweak32, parity); } + + public string ToHex() + { + return ToString(); + } #endif } }