From 4ecbf69b47b18d094766935c043822bac56b5d6b Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Sun, 4 Mar 2018 22:37:42 +0800 Subject: [PATCH 1/2] TX Inputs to be RBF-enabled by default When creating an input, there was a need to explicitly use the Sequence property setter in order to enable RBF on it. Bitcoin Core has recently enabled RBF by default even from the GUI [1], so it should be safe to assume that this feature is stable enough to be enabled by default in NBitcoin too. The implementation to make this possible needs to use a Nullable type for the backing field because the C# compiler doesn't allow structs with parameterless ctors or default values to be assigned to their fields. [1] https://bitcoin.org/en/release/v0.16.0 --- NBitcoin.Tests/transaction_tests.cs | 6 +++--- NBitcoin/NBitcoin.csproj | 2 +- NBitcoin/Sequence.cs | 10 +++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/NBitcoin.Tests/transaction_tests.cs b/NBitcoin.Tests/transaction_tests.cs index 62e8904f7f..a16de88915 100644 --- a/NBitcoin.Tests/transaction_tests.cs +++ b/NBitcoin.Tests/transaction_tests.cs @@ -2890,9 +2890,9 @@ ScriptVerify ParseFlags(string strFlags) [Trait("UnitTest", "UnitTest")] public void SequenceStructParsedCorrectly() { - Assert.True(new Sequence() == 0xFFFFFFFFU); - Assert.False(new Sequence().IsRelativeLock); - Assert.False(new Sequence().IsRBF); + Assert.True(new Sequence() == 0x000000000); + Assert.True(new Sequence().IsRelativeLock); + Assert.True(new Sequence().IsRBF); Assert.True(new Sequence(1) == 1U); Assert.True(new Sequence(1).IsRelativeLock); diff --git a/NBitcoin/NBitcoin.csproj b/NBitcoin/NBitcoin.csproj index 5912096b57..29c94a2025 100644 --- a/NBitcoin/NBitcoin.csproj +++ b/NBitcoin/NBitcoin.csproj @@ -12,7 +12,7 @@ git - 4.0.0.59 + 4.0.0.60 net461;net452;netstandard1.3;netstandard1.1 diff --git a/NBitcoin/Sequence.cs b/NBitcoin/Sequence.cs index 1f387be2ea..2bcbc46de6 100644 --- a/NBitcoin/Sequence.cs +++ b/NBitcoin/Sequence.cs @@ -59,15 +59,19 @@ public static Sequence Final /// internal const int SEQUENCE_LOCKTIME_GRANULARITY = 9; - - uint _ValueInv; + uint? _ValueInv; public uint Value { get { - return 0xFFFFFFFF - _ValueInv; + if (_ValueInv.HasValue) + return 0xFFFFFFFF - _ValueInv.Value; + + // enable RBF by default (see BIP125) + return 0x00000000; } } + public Sequence(uint value) { _ValueInv = 0xFFFFFFFF - value; From 8901e1b3cb8f8bed425c865b208fd8f8a9fa9bb6 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Sun, 4 Mar 2018 22:39:10 +0800 Subject: [PATCH 2/2] gitignore: add DS_Store (macOS) --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index b632ff8ad1..453fa48928 100644 --- a/.gitignore +++ b/.gitignore @@ -191,3 +191,6 @@ project.lock.json *.zip /dotnet-tpl35/ /dotnet-tpl35 + +# folders in macOS +.DS_Store