Skip to content

Commit ea172b1

Browse files
juanmigdrfarukterzioglu
authored andcommitted
Fix: Incorrect Fee Estimation Due to Omitted estimate_mode in Bitcoin Core 28.0
1 parent 4c5b2ac commit ea172b1

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

NBitcoin/RPC/RPCClient.cs

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ async static Task CheckSegwitCapabilitiesAsync(RPCClient rpc, Action<bool> setRe
395395
return;
396396
}
397397
#endif
398-
var address = new Key().GetAddress(type, rpc.Network);
398+
var address = new Key().GetAddress(type, rpc.Network);
399399
if (address == null)
400400
{
401401
setResult(false);
@@ -1059,7 +1059,7 @@ private async Task<Stream> ToMemoryStreamAsync(Stream stream)
10591059
return ms;
10601060
}
10611061

1062-
#region P2P Networking
1062+
#region P2P Networking
10631063
#if !NOSOCKET
10641064
public PeerInfo[] GetPeersInfo()
10651065
{
@@ -1211,9 +1211,9 @@ public async Task<AddedNodeInfo> GetAddedNodeInfoAync(bool detailed, EndPoint no
12111211
}
12121212
#endif
12131213

1214-
#endregion
1214+
#endregion
12151215

1216-
#region Block chain and UTXO
1216+
#region Block chain and UTXO
12171217

12181218
public async Task<BlockchainInfo> GetBlockchainInfoAsync(CancellationToken cancellationToken = default)
12191219
{
@@ -1868,13 +1868,13 @@ public IEnumerable<Transaction> GetTransactions(int height)
18681868
return GetTransactions(GetBlockHash(height));
18691869
}
18701870

1871-
#endregion
1871+
#endregion
18721872

1873-
#region Coin generation
1873+
#region Coin generation
18741874

1875-
#endregion
1875+
#endregion
18761876

1877-
#region Raw Transaction
1877+
#region Raw Transaction
18781878

18791879
public Transaction DecodeRawTransaction(string rawHex)
18801880
{
@@ -2011,15 +2011,15 @@ public async Task<BumpResponse> BumpFeeAsync(uint256 txid, CancellationToken can
20112011
}
20122012

20132013

2014-
#endregion
2014+
#endregion
20152015

2016-
#region Utility functions
2016+
#region Utility functions
20172017

20182018
// Estimates the approximate fee per kilobyte needed for a transaction to begin
20192019
// confirmation within conf_target blocks if possible and return the number of blocks
20202020
// for which the estimate is valid.Uses virtual transaction size as defined
20212021
// in BIP 141 (witness data is discounted).
2022-
#region Fee Estimation
2022+
#region Fee Estimation
20232023

20242024
/// <summary>
20252025
/// (>= Bitcoin Core v0.14) Get the estimated fee per kb for being confirmed in nblock
@@ -2081,13 +2081,9 @@ private async Task<EstimateSmartFeeResponse> EstimateSmartFeeImplAsync(int confi
20812081
{
20822082
if (Capabilities == null || Capabilities.SupportEstimateSmartFee)
20832083
{
2084-
var parameters = new List<object>() { confirmationTarget };
2085-
if (estimateMode != EstimateSmartFeeMode.Conservative)
2086-
{
2087-
parameters.Add(estimateMode.ToString().ToUpperInvariant());
2088-
}
2084+
var parameters = new object[] { confirmationTarget, estimateMode.ToString().ToUpperInvariant() };
20892085

2090-
var request = new RPCRequest(RPCOperations.estimatesmartfee.ToString(), parameters.ToArray());
2086+
var request = new RPCRequest(RPCOperations.estimatesmartfee.ToString(), parameters);
20912087
request.ThrowIfRPCError = false;
20922088
var response = await SendCommandAsync(request, cancellationToken: cancellationToken).ConfigureAwait(false);
20932089

@@ -2132,7 +2128,7 @@ private async Task<EstimateSmartFeeResponse> EstimateSmartFeeImplAsync(int confi
21322128
}
21332129
}
21342130

2135-
#endregion
2131+
#endregion
21362132

21372133

21382134
#nullable enable
@@ -2318,7 +2314,7 @@ public bool SetTxFee(FeeRate feeRate, CancellationToken cancellationToken = defa
23182314
return SendCommand(RPCOperations.settxfee, cancellationToken, new[] { feeRate.FeePerK.ToString() }).Result.ToString() == "true";
23192315
}
23202316

2321-
#endregion
2317+
#endregion
23222318

23232319
public async Task<uint256[]> GenerateAsync(int nBlocks, CancellationToken cancellationToken = default)
23242320
{
@@ -2369,7 +2365,7 @@ public uint256[] GenerateToAddress(int nBlocks, BitcoinAddress address)
23692365
return GenerateToAddressAsync(nBlocks, address).GetAwaiter().GetResult();
23702366
}
23712367

2372-
#region Region Hidden Methods
2368+
#region Region Hidden Methods
23732369

23742370
/// <summary>
23752371
/// Permanently marks a block as invalid, as if it violated a consensus rule.
@@ -2415,7 +2411,7 @@ public async Task<bool> AddPeerAddressAsync(IPAddress ip, int port, Cancellation
24152411

24162412
#endif
24172413

2418-
#endregion
2414+
#endregion
24192415
}
24202416

24212417
#if !NOSOCKET

0 commit comments

Comments
 (0)