Skip to content

Commit eb592e0

Browse files
committed
Fix some warnings (which appeared after previous commit)
1 parent f1438b5 commit eb592e0

File tree

3 files changed

+52
-11
lines changed

3 files changed

+52
-11
lines changed

NBitcoin/BIP174/PartiallySignedTransaction.cs

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,24 @@ public class PSBT : IEquatable<PSBT>
108108
public PSBTOutputList Outputs { get; }
109109

110110
internal UnKnownKVMap unknown = new UnKnownKVMap(BytesComparer.Instance);
111+
112+
[Obsolete("Use Parse(_,_,RBF)")]
111113
public static PSBT Parse(string hexOrBase64, Network network)
114+
{
115+
return Parse(hexOrBase64, network, false);
116+
}
117+
[Obsolete("Use Parse(_,_,RBF)")]
118+
public static PSBT Parse(string hexOrBase64, ConsensusFactory consensusFactory)
119+
{
120+
return Parse(hexOrBase64, consensusFactory, false);
121+
}
122+
public static PSBT Parse(string hexOrBase64, Network network, bool RBF)
112123
{
113124
if (network == null)
114125
throw new ArgumentNullException(nameof(network));
115-
return Parse(hexOrBase64, network.Consensus.ConsensusFactory);
126+
return Parse(hexOrBase64, network.Consensus.ConsensusFactory, RBF);
116127
}
117-
public static PSBT Parse(string hexOrBase64, ConsensusFactory consensusFactory)
128+
public static PSBT Parse(string hexOrBase64, ConsensusFactory consensusFactory, bool RBF)
118129
{
119130
if (hexOrBase64 == null)
120131
throw new ArgumentNullException(nameof(hexOrBase64));
@@ -126,21 +137,31 @@ public static PSBT Parse(string hexOrBase64, ConsensusFactory consensusFactory)
126137
else
127138
raw = Encoders.Base64.DecodeData(hexOrBase64);
128139

129-
return Load(raw, consensusFactory);
140+
return Load(raw, consensusFactory, RBF);
130141
}
142+
[Obsolete("Use Load(_,_,RBF)")]
131143
public static PSBT Load(byte[] rawBytes, Network network)
144+
{
145+
return Load(rawBytes, network, false);
146+
}
147+
public static PSBT Load(byte[] rawBytes, Network network, bool RBF)
132148
{
133149
if (network == null)
134150
throw new ArgumentNullException(nameof(network));
135-
return Load(rawBytes, network.Consensus.ConsensusFactory);
151+
return Load(rawBytes, network.Consensus.ConsensusFactory, RBF);
136152
}
153+
[Obsolete("Use Load(_,_,RBF)")]
137154
public static PSBT Load(byte[] rawBytes, ConsensusFactory consensusFactory)
155+
{
156+
return Load(rawBytes, consensusFactory, false);
157+
}
158+
public static PSBT Load(byte[] rawBytes, ConsensusFactory consensusFactory, bool RBF)
138159
{
139160
if (rawBytes == null)
140161
throw new ArgumentNullException(nameof(rawBytes));
141162
var stream = new BitcoinStream(rawBytes);
142163
stream.ConsensusFactory = consensusFactory;
143-
var ret = new PSBT(stream);
164+
var ret = new PSBT(stream, RBF);
144165
return ret;
145166
}
146167

@@ -162,7 +183,7 @@ private PSBT(Transaction transaction)
162183
}
163184
}
164185

165-
internal PSBT(BitcoinStream stream)
186+
internal PSBT(BitcoinStream stream, bool RBF)
166187
{
167188
Inputs = new PSBTInputList();
168189
Outputs = new PSBTOutputList();
@@ -186,7 +207,7 @@ internal PSBT(BitcoinStream stream)
186207
throw new FormatException("Invalid PSBT. Contains illegal value in key global tx");
187208
if (tx != null)
188209
throw new FormatException("Duplicate Key, unsigned tx already provided");
189-
tx = stream.ConsensusFactory.CreateTransaction();
210+
tx = stream.ConsensusFactory.CreateTransaction(RBF);
190211
uint size = 0;
191212
stream.ReadWriteAsVarInt(ref size);
192213
var pos = stream.Counter.ReadenBytes;

NBitcoin/ConsensusFactory.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,16 @@ public virtual BlockHeader CreateBlockHeader()
106106
#pragma warning restore CS0618 // Type or member is obsolete
107107
}
108108

109+
[Obsolete("Use CreateTransaction(RBF)")]
109110
public virtual Transaction CreateTransaction()
110111
{
112+
return CreateTransaction(false);
113+
}
114+
115+
public virtual Transaction CreateTransaction(bool RBF)
116+
{
111117
#pragma warning disable CS0618 // Type or member is obsolete
112-
return new Transaction();
118+
return new Transaction(RBF);
113119
#pragma warning restore CS0618 // Type or member is obsolete
114120
}
115121

NBitcoin/Transaction.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ public bool RBF
12581258
{
12591259
get
12601260
{
1261-
return Inputs.Any(i => i.Sequence < 0xffffffff - 1);
1261+
return this._RBF;
12621262
}
12631263
}
12641264

@@ -1279,17 +1279,31 @@ public uint Version
12791279
protected TxOutList vout;
12801280
protected LockTime nLockTime;
12811281

1282+
private bool _RBF;
1283+
12821284

12831285
[Obsolete("You should better use Transaction.Create(Network network)")]
1284-
public Transaction()
1286+
public Transaction(): this(false)
12851287
{
1288+
}
1289+
1290+
[Obsolete("You should better use Transaction.Create(Network network, bool RBF)")]
1291+
public Transaction(bool RBF)
1292+
{
12861293
vin = new TxInList(this);
12871294
vout = new TxOutList(this);
1295+
this._RBF = RBF;
12881296
}
12891297

1298+
[Obsolete("You should better use Transaction.Create(Network network, bool RBF)")]
12901299
public static Transaction Create(Network network)
12911300
{
12921301
return network.Consensus.ConsensusFactory.CreateTransaction();
1302+
}
1303+
1304+
public static Transaction Create(Network network, bool RBF)
1305+
{
1306+
return network.Consensus.ConsensusFactory.CreateTransaction(RBF);
12931307
}
12941308

12951309
[Obsolete("You should instantiate Transaction from Transaction.Parse(string hex, Network network)")]
@@ -1667,7 +1681,7 @@ public void Sign(ISecret[] secrets, ICoin[] coins)
16671681
/// <param name="coins">Coins to sign</param>
16681682
public void Sign(Key[] keys, ICoin[] coins)
16691683
{
1670-
TransactionBuilder builder = this.GetConsensusFactory().CreateTransactionBuilder();
1684+
TransactionBuilder builder = this.GetConsensusFactory().CreateTransactionBuilder(_RBF);
16711685
builder.AddKeys(keys);
16721686
builder.AddCoins(coins);
16731687
builder.SignTransactionInPlace(this);

0 commit comments

Comments
 (0)