Add fee fields to filter

This commit is contained in:
chimp1984 2021-11-14 14:17:10 +01:00
parent 17d4d425a7
commit a082fd4a84
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3
6 changed files with 97 additions and 10 deletions

View File

@ -109,6 +109,13 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
// See ProofOfWorkTest for more info.
private final int powDifficulty;
// Added at v 1.8.0
// BSQ fee gets updated in proposals repo (e.g. https://github.com/bisq-network/proposals/issues/345)
private final long makerFeeBtc;
private final long takerFeeBtc;
private final long makerFeeBsq;
private final long takerFeeBsq;
// After we have created the signature from the filter data we clone it and apply the signature
static Filter cloneWithSig(Filter filter, String signatureAsBase64) {
return new Filter(filter.getBannedOfferIds(),
@ -140,7 +147,11 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
filter.isDisableMempoolValidation(),
filter.isDisableApi(),
filter.isDisablePowMessage(),
filter.getPowDifficulty());
filter.getPowDifficulty(),
filter.getMakerFeeBtc(),
filter.getTakerFeeBtc(),
filter.getMakerFeeBsq(),
filter.getTakerFeeBsq());
}
// Used for signature verification as we created the sig without the signatureAsBase64 field we set it to null again
@ -174,7 +185,11 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
filter.isDisableMempoolValidation(),
filter.isDisableApi(),
filter.isDisablePowMessage(),
filter.getPowDifficulty());
filter.getPowDifficulty(),
filter.getMakerFeeBtc(),
filter.getTakerFeeBtc(),
filter.getMakerFeeBsq(),
filter.getTakerFeeBsq());
}
public Filter(List<String> bannedOfferIds,
@ -203,7 +218,11 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
boolean disableMempoolValidation,
boolean disableApi,
boolean disablePowMessage,
int powDifficulty) {
int powDifficulty,
long makerFeeBtc,
long takerFeeBtc,
long makerFeeBsq,
long takerFeeBsq) {
this(bannedOfferIds,
nodeAddressesBannedFromTrading,
bannedPaymentAccounts,
@ -233,7 +252,11 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
disableMempoolValidation,
disableApi,
disablePowMessage,
powDifficulty);
powDifficulty,
makerFeeBtc,
takerFeeBtc,
makerFeeBsq,
takerFeeBsq);
}
@ -271,7 +294,11 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
boolean disableMempoolValidation,
boolean disableApi,
boolean disablePowMessage,
int powDifficulty) {
int powDifficulty,
long makerFeeBtc,
long takerFeeBtc,
long makerFeeBsq,
long takerFeeBsq) {
this.bannedOfferIds = bannedOfferIds;
this.nodeAddressesBannedFromTrading = nodeAddressesBannedFromTrading;
this.bannedPaymentAccounts = bannedPaymentAccounts;
@ -302,6 +329,10 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
this.disableApi = disableApi;
this.disablePowMessage = disablePowMessage;
this.powDifficulty = powDifficulty;
this.makerFeeBtc = makerFeeBtc;
this.takerFeeBtc = takerFeeBtc;
this.makerFeeBsq = makerFeeBsq;
this.takerFeeBsq = takerFeeBsq;
// ownerPubKeyBytes can be null when called from tests
if (ownerPubKeyBytes != null) {
@ -344,7 +375,11 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
.setDisableMempoolValidation(disableMempoolValidation)
.setDisableApi(disableApi)
.setDisablePowMessage(disablePowMessage)
.setPowDifficulty(powDifficulty);
.setPowDifficulty(powDifficulty)
.setMakerFeeBtc(makerFeeBtc)
.setTakerFeeBtc(takerFeeBtc)
.setMakerFeeBsq(makerFeeBsq)
.setTakerFeeBsq(takerFeeBsq);
Optional.ofNullable(signatureAsBase64).ifPresent(builder::setSignatureAsBase64);
Optional.ofNullable(extraDataMap).ifPresent(builder::putAllExtraData);
@ -357,7 +392,6 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
.map(PaymentAccountFilter::fromProto)
.collect(Collectors.toList());
return new Filter(ProtoUtil.protocolStringListToList(proto.getBannedOfferIdsList()),
ProtoUtil.protocolStringListToList(proto.getNodeAddressesBannedFromTradingList()),
bannedPaymentAccountsList,
@ -387,7 +421,11 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
proto.getDisableMempoolValidation(),
proto.getDisableApi(),
proto.getDisablePowMessage(),
proto.getPowDifficulty()
proto.getPowDifficulty(),
proto.getMakerFeeBtc(),
proto.getTakerFeeBtc(),
proto.getMakerFeeBsq(),
proto.getTakerFeeBsq()
);
}
@ -435,6 +473,10 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
",\n disableApi=" + disableApi +
",\n disablePowMessage=" + disablePowMessage +
",\n powDifficulty=" + powDifficulty +
",\n makerFeeBtc=" + makerFeeBtc +
",\n takerFeeBtc=" + takerFeeBtc +
",\n makerFeeBsq=" + makerFeeBsq +
",\n takerFeeBsq=" + takerFeeBsq +
"\n}";
}
}

View File

@ -2780,6 +2780,10 @@ filterWindow.disableApi=Disable API
filterWindow.disableMempoolValidation=Disable Mempool Validation
filterWindow.disablePowMessage=Disable messages requiring Proof of Work
filterWindow.powDifficulty=Proof of work difficulty (BSQ swap offers)
filterWindow.makerFeeBtc=Min. BTC maker fee (e.g. 0.001)
filterWindow.takerFeeBtc=Min. BTC taker fee (e.g. 0.007)
filterWindow.makerFeeBsq=Min. BSQ maker fee (e.g. 15.14)
filterWindow.takerFeeBsq=Min. BSQ taker fee (e.g. 105.97)
offerDetailsWindow.minBtcAmount=Min. BTC amount
offerDetailsWindow.min=(min. {0})
@ -3417,7 +3421,7 @@ payment.swift.account=Account No. (or IBAN)
payment.swift.use.intermediary=Use Intermediary Bank
payment.swift.showPaymentInfo=Show Payment Information...
payment.account.owner.address=Account owner address
payment.transferwiseUsd.address= (must be US-based, consider using bank address)
payment.transferwiseUsd.address=(must be US-based, consider using bank address)
payment.amazon.site=Buy giftcard at
payment.ask=Ask in Trader Chat

View File

@ -71,6 +71,10 @@ public class UserPayloadModelVOTest {
false,
false,
false,
0,
0,
0,
0,
0));
vo.setRegisteredArbitrator(ArbitratorTest.getArbitratorMock());

View File

@ -132,6 +132,10 @@ public class FeeReceiverSelectorTest {
false,
false,
false,
0,
0,
0,
0,
0);
}
}

View File

@ -26,11 +26,17 @@ import bisq.core.filter.Filter;
import bisq.core.filter.FilterManager;
import bisq.core.filter.PaymentAccountFilter;
import bisq.core.locale.Res;
import bisq.core.util.FormattingUtils;
import bisq.core.util.ParsingUtils;
import bisq.core.util.coin.BsqFormatter;
import bisq.core.util.coin.CoinFormatter;
import bisq.common.UserThread;
import bisq.common.app.DevEnv;
import bisq.common.config.Config;
import org.bitcoinj.core.Coin;
import com.google.inject.Inject;
import javax.inject.Named;
@ -63,13 +69,19 @@ import static bisq.desktop.util.FormBuilder.addTopLabelInputTextField;
public class FilterWindow extends Overlay<FilterWindow> {
private final FilterManager filterManager;
private final BsqFormatter bsqFormatter;
private final CoinFormatter btcFormatter;
private final boolean useDevPrivilegeKeys;
private ScrollPane scrollPane;
@Inject
public FilterWindow(FilterManager filterManager,
BsqFormatter bsqFormatter,
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter btcFormatter,
@Named(Config.USE_DEV_PRIVILEGE_KEYS) boolean useDevPrivilegeKeys) {
this.filterManager = filterManager;
this.bsqFormatter = bsqFormatter;
this.btcFormatter = btcFormatter;
this.useDevPrivilegeKeys = useDevPrivilegeKeys;
type = Type.Attention;
}
@ -178,6 +190,14 @@ public class FilterWindow extends Overlay<FilterWindow> {
InputTextField powDifficultyTF = addInputTextField(gridPane, ++rowIndex,
Res.get("filterWindow.powDifficulty"));
powDifficultyTF.setText("0");
InputTextField makerFeeBtcTF = addInputTextField(gridPane, ++rowIndex,
Res.get("filterWindow.makerFeeBtc"));
InputTextField takerFeeBtcTF = addInputTextField(gridPane, ++rowIndex,
Res.get("filterWindow.takerFeeBtc"));
InputTextField makerFeeBsqTF = addInputTextField(gridPane, ++rowIndex,
Res.get("filterWindow.makerFeeBsq"));
InputTextField takerFeeBsqTF = addInputTextField(gridPane, ++rowIndex,
Res.get("filterWindow.takerFeeBsq"));
Filter filter = filterManager.getDevFilter();
if (filter != null) {
@ -207,6 +227,11 @@ public class FilterWindow extends Overlay<FilterWindow> {
disableApiCheckBox.setSelected(filter.isDisableApi());
disablePowMessage.setSelected(filter.isDisablePowMessage());
powDifficultyTF.setText(String.valueOf(filter.getPowDifficulty()));
makerFeeBtcTF.setText(btcFormatter.formatCoin(Coin.valueOf(filter.getMakerFeeBtc())));
takerFeeBtcTF.setText(btcFormatter.formatCoin(Coin.valueOf(filter.getTakerFeeBtc())));
makerFeeBsqTF.setText(bsqFormatter.formatBSQSatoshis(filter.getMakerFeeBsq()));
takerFeeBsqTF.setText(bsqFormatter.formatBSQSatoshis(filter.getTakerFeeBsq()));
}
Button removeFilterMessageButton = new AutoTooltipButton(Res.get("filterWindow.remove"));
@ -244,7 +269,11 @@ public class FilterWindow extends Overlay<FilterWindow> {
disableMempoolValidationCheckBox.isSelected(),
disableApiCheckBox.isSelected(),
disablePowMessage.isSelected(),
Integer.parseInt(powDifficultyTF.getText())
Integer.parseInt(powDifficultyTF.getText()),
ParsingUtils.parseToCoin(makerFeeBtcTF.getText(), btcFormatter).value,
ParsingUtils.parseToCoin(takerFeeBtcTF.getText(), btcFormatter).value,
ParsingUtils.parseToCoin(makerFeeBsqTF.getText(), bsqFormatter).value,
ParsingUtils.parseToCoin(takerFeeBsqTF.getText(), bsqFormatter).value
);
// We remove first the old filter

View File

@ -770,6 +770,10 @@ message Filter {
bool disable_mempool_validation = 28;
bool disable_pow_message = 29;
int32 pow_difficulty = 30;
int64 maker_fee_btc = 31;
int64 taker_fee_btc = 32;
int64 maker_fee_bsq = 33;
int64 taker_fee_bsq = 34;
}
// Deprecated