Skip to content

Commit

Permalink
Fix warnings and bump
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasDorier committed Jan 17, 2024
1 parent bef7b21 commit 80092a5
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 18 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.21</Version>
<Version>3.0.22</Version>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\NBitcoin\NBitcoin.csproj" />
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.24</VersionPrefix>
<VersionPrefix>3.0.25</VersionPrefix>
<LangVersion>9.0</LangVersion>
<TargetFrameworks>netstandard1.6;net472;netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition="'$(BuildingInsideVisualStudio)' == 'true'">netstandard2.1</TargetFrameworks>
Expand Down
6 changes: 3 additions & 3 deletions NBitcoin.Tests/TaprootBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ public void CanHandleMultipleProofForSameScript()
var data = new byte[] { 0x01 };
var sc = new Script(OpcodeType.OP_RETURN, Op.GetPushOp(data));
var version = (byte)TaprootConstants.TAPROOT_LEAF_TAPSCRIPT;
var nodeInfoA = NodeInfo.NewLeafWithVersion(sc, version);
var nodeInfoB = NodeInfo.NewLeafWithVersion(sc, version);
var nodeInfoA = TaprootNodeInfo.NewLeafWithVersion(sc, version);
var nodeInfoB = TaprootNodeInfo.NewLeafWithVersion(sc, version);
var rootNode = nodeInfoA + nodeInfoB;
var info = TaprootSpendInfo.FromNodeInfo(internalKey, rootNode);
Assert.Single(info.ScriptToMerkleProofMap);
Expand Down Expand Up @@ -222,7 +222,7 @@ public void ScriptPathSpendUnitTest1()
Assert.Equal(info.MerkleRoot!, expectedMerkleRoot);

var output = internalKey.GetTaprootFullPubKey(info.MerkleRoot);
Assert.Equal(info.OutputPubKey.OutputKey.ToString(), "003cdb72825a12ea62f5834f3c47f9bf48d58d27f5ad1e6576ac613b093125f3");
Assert.Equal("003cdb72825a12ea62f5834f3c47f9bf48d58d27f5ad1e6576ac613b093125f3", info.OutputPubKey.OutputKey.ToString());
var spk = output.ScriptPubKey;
var expectedSpk = "5120003cdb72825a12ea62f5834f3c47f9bf48d58d27f5ad1e6576ac613b093125f3";
Assert.Equal( expectedSpk, spk.ToHex());
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.32</Version>
<Version Condition=" '$(Version)' == '' ">7.0.33</Version>
<LangVersion>9.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
Expand Down
8 changes: 5 additions & 3 deletions NBitcoin/PubKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ public enum ScriptPubKeyType
#endif
TaprootWithScript,

#if !HAS_SPAN
[Obsolete("TaprootRaw is unavailable in .net framework")]
#endif
/// <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
}
public class PubKey : IDestination, IComparable<PubKey>, IEquatable<PubKey>, IPubKey
Expand Down Expand Up @@ -338,7 +338,9 @@ public BitcoinAddress GetAddress(ScriptPubKeyType type, Network network)
#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
10 changes: 5 additions & 5 deletions NBitcoin/Scripting/OutputDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static (int, List<TaprootPubKey>)? FindMultiATemplate(this Script sc)
internal class TreeNode
{
internal uint256? Hash { get; set; }
internal ScriptLeaf? Leaf;
internal TaprootScriptLeaf? Leaf;
internal Tuple<TreeNode, TreeNode>? Sub;

/// <summary>
Expand Down Expand Up @@ -115,7 +115,7 @@ public static bool InferTaprootTree(this TaprootSpendInfo info, TaprootPubKey ou
continue;
}

var leafHash = new ScriptLeaf(script, leafVersion).LeafHash;
var leafHash = new TaprootScriptLeaf(script, leafVersion).LeafHash;

TreeNode node = root;
var levels = controlB.Length/ TaprootConstants.TAPROOT_CONTROL_NODE_SIZE;
Expand Down Expand Up @@ -163,7 +163,7 @@ public static bool InferTaprootTree(this TaprootSpendInfo info, TaprootPubKey ou
if (node.Sub?.Item1 is not null) return false;
node.Explored = true;
node.Inner = false;
node.Leaf = new ScriptLeaf(script, leafVersion);
node.Leaf = new TaprootScriptLeaf(script, leafVersion);
node.Hash = leafHash;
}
}
Expand Down Expand Up @@ -195,7 +195,7 @@ public static bool InferTaprootTree(this TaprootSpendInfo info, TaprootPubKey ou
}
else if (!node.Inner)
{
result.Add(new Tuple<int, Script, byte>((int)stack.Count - 1, node.Leaf.Script, node.Leaf.Version));
result.Add(new Tuple<int, Script, byte>((int)stack.Count - 1, node.Leaf!.Script, node.Leaf.Version));
node.Done = true;
stack.Pop();
}
Expand Down Expand Up @@ -608,7 +608,7 @@ public static OutputDescriptor NewRawTr(PubKeyProvider outputPubkeyProvider, Net
public bool TryExpand(
uint pos,
ISigningRepository repo,
out List<Script> outputScripts,
[MaybeNullWhen(false)] out List<Script> outputScripts,
IDictionary<uint, ExtPubKey>? cache = null
)
{
Expand Down
2 changes: 1 addition & 1 deletion NBitcoin/Scripting/OutputDescriptorParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ from _ in Parse.Char(',')
from tapTree in PTapScript(repo, n)
select OutputDescriptor.NewTr(internalPk, n, tapTree);

private static P PTapRootNoScriptInner(ISigningRepository repo, Network n) =>
private static P PTapRootNoScriptInner(ISigningRepository? repo, Network n) =>
from internalPk in PPubKeyProviderForTaproot(repo, n, PubKeyContext.TaprootInternalKey)
select OutputDescriptor.NewTr(internalPk, n);

Expand Down
3 changes: 0 additions & 3 deletions NBitcoin/TaprootFullPubKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
using System.Text;
using System.Threading.Tasks;
using NBitcoin.DataEncoders;
#if HAS_SPAN
using NBitcoin.Secp256k1;
#endif

namespace NBitcoin
{
Expand Down

0 comments on commit 80092a5

Please sign in to comment.