Skip to content

Commit b3169a7

Browse files
authored
Add max fee to network (#140)
1 parent 80a668f commit b3169a7

8 files changed

Lines changed: 18 additions & 5 deletions

File tree

src/Blockcore/Configuration/NodeSettings.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ public class NodeSettings : IDisposable
9191
/// <summary>The minimum fee for a kB of transactions on the node.</summary>
9292
public FeeRate MinTxFeeRate { get; private set; }
9393

94+
/// <summary>The optional maximum fee for a kB of transactions on the node.</summary>
95+
public FeeRate MaxTxFeeRate { get; private set; }
96+
9497
/// <summary>The default fee for a kB of transactions on the node. This value is used if no fee is specified for
9598
/// a transaction.
9699
/// </summary>
@@ -302,6 +305,7 @@ private void LoadConfiguration()
302305
this.MinTxFeeRate = new FeeRate(config.GetOrDefault("mintxfee", this.Network.MinTxFee, this.Logger));
303306
this.FallbackTxFeeRate = new FeeRate(config.GetOrDefault("fallbackfee", this.Network.FallbackFee, this.Logger));
304307
this.MinRelayTxFeeRate = new FeeRate(config.GetOrDefault("minrelaytxfee", this.Network.MinRelayTxFee, this.Logger));
308+
this.MaxTxFeeRate = new FeeRate(config.GetOrDefault("maxtxfee", this.Network.MaxTxFee, this.Logger));
305309
}
306310

307311
/// <summary>
@@ -400,6 +404,7 @@ public static void BuildDefaultConfigurationFile(StringBuilder builder, Network
400404
builder.AppendLine($"regtest={(network.IsRegTest() ? 1 : 0)}");
401405
builder.AppendLine($"#Minimum fee rate. Defaults to {network.MinTxFee}.");
402406
builder.AppendLine($"#mintxfee={network.MinTxFee}");
407+
builder.AppendLine($"#maxtxfee={network.MaxTxFee}");
403408
builder.AppendLine($"#Fallback fee rate. Defaults to {network.FallbackFee}.");
404409
builder.AppendLine($"#fallbackfee={network.FallbackFee}");
405410
builder.AppendLine($"#Minimum relay fee rate. Defaults to {network.MinRelayTxFee}.");

src/External/NBitcoin/Network.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ public abstract class Network
8383
/// </summary>
8484
public int MaxTipAge { get; protected set; }
8585

86+
/// <summary>
87+
/// The total fee this node will allow
88+
/// </summary>
89+
public long MaxTxFee { get; protected set; }
90+
8691
/// <summary>
8792
/// Mininum fee rate for all transactions.
8893
/// Fees smaller than this are considered zero fee for transaction creation.
@@ -503,7 +508,6 @@ public static T Parse<T>(string str, Network expectedNetwork) where T : IBitcoin
503508
continue;
504509
}
505510
}
506-
507511
}
508512

509513
throw new FormatException("Invalid string");

src/External/NBitcoin/Policy/StandardTransactionPolicy.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ public class StandardTransactionPolicy : ITransactionPolicy
99
/// <summary>
1010
/// Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed keys
1111
/// (remember the 520 byte limit on redeemScript size).
12-
/// That works out to a (15*(33+1))+3=513 byte redeemScript, 513+1+15*(73+1)+3=1627 bytes of scriptSig,
13-
/// which we round off to 1650 bytes for some minor future-proofing.
12+
/// That works out to a (15*(33+1))+3=513 byte redeemScript, 513+1+15*(73+1)+3=1627 bytes of scriptSig,
13+
/// which we round off to 1650 bytes for some minor future-proofing.
1414
/// That's also enough to spend a 20-of-20 CHECKMULTISIG scriptPubKey, though such a scriptPubKey is not considered standard.
1515
/// </summary>
1616
public const int MaxScriptSigLength = 1650;
@@ -55,8 +55,7 @@ public StandardTransactionPolicy(Network network)
5555
this.network = network;
5656
this.ScriptVerify = NBitcoin.ScriptVerify.Standard;
5757
this.MaxTransactionSize = 100000;
58-
// TODO: replace fee params with whats in Network.
59-
this.MaxTxFee = new FeeRate(Money.Coins(0.1m));
58+
this.MaxTxFee = new FeeRate(Money.Satoshis(network.MaxTxFee));
6059
this.MinRelayTxFee = new FeeRate(Money.Satoshis(network.MinRelayTxFee));
6160
this.CheckFee = true;
6261
this.CheckScriptPubKey = true;

src/Networks/Bitcoin/Blockcore.Networks.Bitcoin/BitcoinMain.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public BitcoinMain()
3535
this.MaxTimeOffsetSeconds = BitcoinMaxTimeOffsetSeconds;
3636
this.MaxTipAge = BitcoinDefaultMaxTipAgeInSeconds;
3737
this.MinTxFee = 1000;
38+
this.MaxTxFee = Money.Coins(0.1m).Satoshi;
3839
this.FallbackFee = 20000;
3940
this.MinRelayTxFee = 1000;
4041
this.CoinTicker = "BTC";

src/Networks/City/City/Networks/CityMain.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public CityMain()
5353
DefaultMaxInboundConnections = 109;
5454
MaxTipAge = 2 * 60 * 60;
5555
MinTxFee = 4333;
56+
MaxTxFee = Money.Coins(1).Satoshi;
5657
FallbackFee = 4333;
5758
MinRelayTxFee = 4333;
5859
MaxTimeOffsetSeconds = 25 * 60;

src/Networks/Stratis/Blockcore.Networks.Stratis/StratisMain.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public StratisMain()
5151
this.DefaultAPIPort = 37221;
5252
this.MaxTipAge = 2 * 60 * 60;
5353
this.MinTxFee = 10000;
54+
this.MaxTxFee = Money.Coins(1).Satoshi;
5455
this.FallbackFee = 10000;
5556
this.MinRelayTxFee = 10000;
5657
this.RootFolderName = StratisRootFolderName;

src/Networks/Xds/Blockcore.Networks.Xds/XdsMain.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public XdsMain()
4444
this.DefaultBanTimeSeconds = 8000;
4545
this.MaxTipAge = 2 * 60 * 60;
4646
this.MinTxFee = Money.Coins(0.00001m).Satoshi;
47+
this.MaxTxFee = Money.Coins(1).Satoshi;
4748
this.FallbackFee = this.MinTxFee;
4849
this.MinRelayTxFee = this.MinTxFee;
4950
this.AbsoluteMinTxFee = Money.Coins(0.01m).Satoshi;

src/Networks/x42/x42/Networks/x42Main.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public x42Main()
5353
this.DefaultMaxInboundConnections = 109;
5454
this.MaxTipAge = 2 * 60 * 60;
5555
this.MinTxFee = Money.Zero;
56+
this.MaxTxFee = Money.Coins(1).Satoshi;
5657
this.FallbackFee = Money.Zero;
5758
this.MinRelayTxFee = Money.Zero;
5859
this.MaxTimeOffsetSeconds = 25 * 60;

0 commit comments

Comments
 (0)