mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Adjust to changing minimum tx fee rates
- Append minFeeServiceRate to TxFeeRateInfo proto. - Display min rate in CLI console. - Fix broken test due to changing min fee rate.
This commit is contained in:
parent
40e76fb4ee
commit
2308afb41b
@ -17,7 +17,6 @@ import org.junit.jupiter.api.TestMethodOrder;
|
||||
import static bisq.apitest.Scaffold.BitcoinCoreApp.bitcoind;
|
||||
import static bisq.apitest.config.BisqAppConfig.alicedaemon;
|
||||
import static bisq.apitest.config.BisqAppConfig.seednode;
|
||||
import static bisq.common.config.BaseCurrencyNetwork.BTC_DAO_REGTEST;
|
||||
import static java.lang.String.format;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
@ -56,22 +55,25 @@ public class BtcTxFeeRateTest extends MethodTest {
|
||||
@Test
|
||||
@Order(2)
|
||||
public void testSetInvalidTxFeeRateShouldThrowException(final TestInfo testInfo) {
|
||||
var currentTxFeeRateInfo = TxFeeRateInfo.fromProto(aliceClient.getTxFeeRate());
|
||||
Throwable exception = assertThrows(StatusRuntimeException.class, () ->
|
||||
aliceClient.setTxFeeRate(10));
|
||||
String expectedExceptionMessage =
|
||||
format("UNKNOWN: tx fee rate preference must be >= %d sats/byte",
|
||||
BTC_DAO_REGTEST.getDefaultMinFeePerVbyte());
|
||||
currentTxFeeRateInfo.getMinFeeServiceRate());
|
||||
assertEquals(expectedExceptionMessage, exception.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
public void testSetValidTxFeeRate(final TestInfo testInfo) {
|
||||
var txFeeRateInfo = TxFeeRateInfo.fromProto(aliceClient.setTxFeeRate(15));
|
||||
var currentTxFeeRateInfo = TxFeeRateInfo.fromProto(aliceClient.getTxFeeRate());
|
||||
var customFeeRate = currentTxFeeRateInfo.getMinFeeServiceRate() + 5;
|
||||
var txFeeRateInfo = TxFeeRateInfo.fromProto(aliceClient.setTxFeeRate(customFeeRate));
|
||||
log.debug("{} -> Fee rates with custom preference: {}", testName(testInfo), txFeeRateInfo);
|
||||
|
||||
assertTrue(txFeeRateInfo.isUseCustomTxFeeRate());
|
||||
assertEquals(15, txFeeRateInfo.getCustomTxFeeRate());
|
||||
assertEquals(customFeeRate, txFeeRateInfo.getCustomTxFeeRate());
|
||||
assertTrue(txFeeRateInfo.getFeeServiceRate() > 0);
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class WalletTest extends MethodTest {
|
||||
@BeforeAll
|
||||
public static void setUp() {
|
||||
startSupportingApps(true,
|
||||
true,
|
||||
false,
|
||||
bitcoind,
|
||||
seednode,
|
||||
arbdaemon,
|
||||
|
@ -67,12 +67,14 @@ public class CurrencyFormat {
|
||||
|
||||
public static String formatTxFeeRateInfo(TxFeeRateInfo txFeeRateInfo) {
|
||||
if (txFeeRateInfo.getUseCustomTxFeeRate())
|
||||
return format("custom tx fee rate: %s sats/byte, network rate: %s sats/byte",
|
||||
return format("custom tx fee rate: %s sats/byte, network rate: %s sats/byte, min network rate: %s sats/byte",
|
||||
formatFeeSatoshis(txFeeRateInfo.getCustomTxFeeRate()),
|
||||
formatFeeSatoshis(txFeeRateInfo.getFeeServiceRate()));
|
||||
formatFeeSatoshis(txFeeRateInfo.getFeeServiceRate()),
|
||||
formatFeeSatoshis(txFeeRateInfo.getMinFeeServiceRate()));
|
||||
else
|
||||
return format("tx fee rate: %s sats/byte",
|
||||
formatFeeSatoshis(txFeeRateInfo.getFeeServiceRate()));
|
||||
return format("tx fee rate: %s sats/byte, min tx fee rate: %s sats/byte",
|
||||
formatFeeSatoshis(txFeeRateInfo.getFeeServiceRate()),
|
||||
formatFeeSatoshis(txFeeRateInfo.getMinFeeServiceRate()));
|
||||
}
|
||||
|
||||
public static String formatAmountRange(long minAmount, long amount) {
|
||||
|
@ -373,10 +373,7 @@ class CoreWalletsService {
|
||||
|
||||
void setTxFeeRatePreference(long txFeeRate,
|
||||
ResultHandler resultHandler) {
|
||||
long minFeePerVbyte = BTC_DAO_REGTEST.getDefaultMinFeePerVbyte();
|
||||
// TODO Replace line above with line below, after commit
|
||||
// c33ac1b9834fb9f7f14e553d09776f94efc9d13d is merged.
|
||||
// long minFeePerVbyte = feeService.getMinFeePerVByte();
|
||||
long minFeePerVbyte = feeService.getMinFeePerVByte();
|
||||
if (txFeeRate < minFeePerVbyte)
|
||||
throw new IllegalStateException(
|
||||
format("tx fee rate preference must be >= %d sats/byte", minFeePerVbyte));
|
||||
@ -396,6 +393,7 @@ class CoreWalletsService {
|
||||
return new TxFeeRateInfo(
|
||||
preferences.isUseCustomWithdrawalTxFee(),
|
||||
preferences.getWithdrawalTxFeeInVbytes(),
|
||||
feeService.getMinFeePerVByte(),
|
||||
feeService.getTxFeePerVbyte().value,
|
||||
feeService.getLastRequest());
|
||||
}
|
||||
|
@ -28,15 +28,18 @@ public class TxFeeRateInfo implements Payload {
|
||||
|
||||
private final boolean useCustomTxFeeRate;
|
||||
private final long customTxFeeRate;
|
||||
private final long minFeeServiceRate;
|
||||
private final long feeServiceRate;
|
||||
private final long lastFeeServiceRequestTs;
|
||||
|
||||
public TxFeeRateInfo(boolean useCustomTxFeeRate,
|
||||
long customTxFeeRate,
|
||||
long minFeeServiceRate,
|
||||
long feeServiceRate,
|
||||
long lastFeeServiceRequestTs) {
|
||||
this.useCustomTxFeeRate = useCustomTxFeeRate;
|
||||
this.customTxFeeRate = customTxFeeRate;
|
||||
this.minFeeServiceRate = minFeeServiceRate;
|
||||
this.feeServiceRate = feeServiceRate;
|
||||
this.lastFeeServiceRequestTs = lastFeeServiceRequestTs;
|
||||
}
|
||||
@ -50,6 +53,7 @@ public class TxFeeRateInfo implements Payload {
|
||||
return bisq.proto.grpc.TxFeeRateInfo.newBuilder()
|
||||
.setUseCustomTxFeeRate(useCustomTxFeeRate)
|
||||
.setCustomTxFeeRate(customTxFeeRate)
|
||||
.setMinFeeServiceRate(minFeeServiceRate)
|
||||
.setFeeServiceRate(feeServiceRate)
|
||||
.setLastFeeServiceRequestTs(lastFeeServiceRequestTs)
|
||||
.build();
|
||||
@ -59,6 +63,7 @@ public class TxFeeRateInfo implements Payload {
|
||||
public static TxFeeRateInfo fromProto(bisq.proto.grpc.TxFeeRateInfo proto) {
|
||||
return new TxFeeRateInfo(proto.getUseCustomTxFeeRate(),
|
||||
proto.getCustomTxFeeRate(),
|
||||
proto.getMinFeeServiceRate(),
|
||||
proto.getFeeServiceRate(),
|
||||
proto.getLastFeeServiceRequestTs());
|
||||
}
|
||||
@ -68,6 +73,7 @@ public class TxFeeRateInfo implements Payload {
|
||||
return "TxFeeRateInfo{" + "\n" +
|
||||
" useCustomTxFeeRate=" + useCustomTxFeeRate + "\n" +
|
||||
", customTxFeeRate=" + customTxFeeRate + " sats/byte" + "\n" +
|
||||
", minFeeServiceRate=" + minFeeServiceRate + " sats/byte" + "\n" +
|
||||
", feeServiceRate=" + feeServiceRate + " sats/byte" + "\n" +
|
||||
", lastFeeServiceRequestTs=" + lastFeeServiceRequestTs + "\n" +
|
||||
'}';
|
||||
|
@ -407,6 +407,7 @@ message TxFeeRateInfo {
|
||||
uint64 customTxFeeRate = 2;
|
||||
uint64 feeServiceRate = 3;
|
||||
uint64 lastFeeServiceRequestTs = 4;
|
||||
uint64 minFeeServiceRate = 5;
|
||||
}
|
||||
|
||||
message TxInfo {
|
||||
|
Loading…
Reference in New Issue
Block a user