Skip to content

Commit c22cfa5

Browse files
committed
RBF is not disabled by default anymore
But it's not enabled by default either: the developer is forced to make a decision if he wants to avoid the compile-time warnings. This way we avoid the potential problems that could have been caused by simply switching the default to be RFB-enabled, as discussed originally here: MetacoSA#355
1 parent c17142e commit c22cfa5

3 files changed

Lines changed: 34 additions & 8 deletions

File tree

NBitcoin/ConsensusFactory.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,27 @@ public virtual TxOut CreateTxOut()
120120
#pragma warning restore CS0618 // Type or member is obsolete
121121
}
122122

123+
protected virtual TransactionBuilder CreateTransactionBuilderCore(bool RBF)
124+
{
125+
return new TransactionBuilder(RBF);
126+
}
127+
128+
[Obsolete("Use CreateTransactionBuilder(bool RBF)")]
123129
protected virtual TransactionBuilder CreateTransactionBuilderCore()
124130
{
125131
#pragma warning disable CS0618 // Type or member is obsolete
126132
return new TransactionBuilder();
127133
#pragma warning restore CS0618 // Type or member is obsolete
128134
}
129135

136+
public TransactionBuilder CreateTransactionBuilder(bool RBF)
137+
{
138+
var builder = CreateTransactionBuilderCore(RBF);
139+
builder.SetConsensusFactory(this);
140+
return builder;
141+
}
142+
143+
[Obsolete("Use CreateTransactionBuilder(bool RBF)")]
130144
public TransactionBuilder CreateTransactionBuilder()
131145
{
132146
#pragma warning disable CS0618 // Type or member is obsolete

NBitcoin/Network.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2513,7 +2513,13 @@ internal NetworkStringParser NetworkStringParser
25132513
get;
25142514
set;
25152515
} = new NetworkStringParser();
2516+
2517+
public TransactionBuilder CreateTransactionBuilder(bool RBF)
2518+
{
2519+
return consensus.ConsensusFactory.CreateTransactionBuilder(RBF);
2520+
}
25162521

2522+
[Obsolete("Use CreateTransactionBuilder(bool RBF)")]
25172523
public TransactionBuilder CreateTransactionBuilder()
25182524
{
25192525
return consensus.ConsensusFactory.CreateTransactionBuilder();

NBitcoin/TransactionBuilder.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -555,17 +555,22 @@ internal BuilderGroup CurrentGroup
555555
return _CurrentGroup;
556556
}
557557
}
558-
[Obsolete("Use Network.CreateTransactionBuilder() or ConsensusFactory.CreateTransactionBuilder() instead")]
559-
public TransactionBuilder()
558+
559+
internal TransactionBuilder(bool RBF)
560560
{
561561
ShuffleRandom = new Random();
562562
CoinSelector = new DefaultCoinSelector(ShuffleRandom);
563563
StandardTransactionPolicy = new StandardTransactionPolicy();
564564
DustPrevention = true;
565-
OptInRBF = false;
565+
this.RBF = RBF;
566566
InitExtensions();
567567
}
568568

569+
[Obsolete("Use Network.CreateTransactionBuilder() or ConsensusFactory.CreateTransactionBuilder() instead")]
570+
public TransactionBuilder() : this(false)
571+
{
572+
}
573+
569574
private void InitExtensions()
570575
{
571576
Extensions.Add(new P2PKHBuilderExtension());
@@ -602,17 +607,18 @@ public bool DustPrevention
602607
{
603608
get;
604609
set;
605-
}
610+
}
606611

612+
[Obsolete("Use Network.CreateTransactionBuilder(RBF) or ConsensusFactory.CreateTransactionBuilder(RBF) instead")]
607613
/// <summary>
608-
/// If true, it will signal the transaction replaceability in every input. (Default: false)
614+
/// If true, it will signal the transaction replaceability in every input.
609615
/// </summary>
610-
public bool OptInRBF
616+
public bool RBF
611617
{
612618
get;
613619
set;
614-
}
615-
620+
}
621+
616622
/// <summary>
617623
/// If true and the transaction has two outputs sending to the same scriptPubKey, those will be merged into a single output. (Default: true)
618624
/// </summary>

0 commit comments

Comments
 (0)