Add bannedPrivilegedDevPubKeys field

This commit is contained in:
chimp1984 2020-08-31 12:51:01 -05:00
parent 1b5e449114
commit 9a142be86e
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3
4 changed files with 33 additions and 15 deletions

View File

@ -77,6 +77,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
private final long creationDate;
private final List<String> bannedPrivilegedDevPubKeys;
// Should be only used in emergency case if we need to add data but do not want to break backward compatibility
// at the P2P network storage checks. The hash of the object will be used to verify if the data is valid. Any new
// field in a class would break that hash and therefore break the storage mechanism.
@ -108,7 +110,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
filter.getCreationDate(),
filter.getExtraDataMap(),
signatureAsBase64,
filter.getSignerPubKeyAsHex());
filter.getSignerPubKeyAsHex(),
filter.getBannedPrivilegedDevPubKeys());
}
// Used for signature verification as we created the sig without the signatureAsBase64 field we set it to null again
@ -134,7 +137,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
filter.getCreationDate(),
filter.getExtraDataMap(),
null,
filter.getSignerPubKeyAsHex());
filter.getSignerPubKeyAsHex(),
filter.getBannedPrivilegedDevPubKeys());
}
public Filter(List<String> bannedOfferIds,
@ -155,7 +159,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
List<String> bannedSignerPubKeys,
List<String> btcFeeReceiverAddresses,
PublicKey ownerPubKey,
String signerPubKeyAsHex) {
String signerPubKeyAsHex,
List<String> bannedPrivilegedDevPubKeys) {
this(bannedOfferIds,
bannedNodeAddress,
bannedPaymentAccounts,
@ -177,7 +182,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
System.currentTimeMillis(),
null,
null,
signerPubKeyAsHex);
signerPubKeyAsHex,
bannedPrivilegedDevPubKeys);
}
@ -207,7 +213,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
long creationDate,
@Nullable Map<String, String> extraDataMap,
@Nullable String signatureAsBase64,
String signerPubKeyAsHex) {
String signerPubKeyAsHex,
List<String> bannedPrivilegedDevPubKeys) {
this.bannedOfferIds = bannedOfferIds;
this.bannedNodeAddress = bannedNodeAddress;
this.bannedPaymentAccounts = bannedPaymentAccounts;
@ -230,6 +237,7 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
this.extraDataMap = ExtraDataMapValidator.getValidatedExtraDataMap(extraDataMap);
this.signatureAsBase64 = signatureAsBase64;
this.signerPubKeyAsHex = signerPubKeyAsHex;
this.bannedPrivilegedDevPubKeys = bannedPrivilegedDevPubKeys;
// ownerPubKeyBytes can be null when called from tests
if (ownerPubKeyBytes != null) {
@ -264,7 +272,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
.addAllBtcFeeReceiverAddresses(btcFeeReceiverAddresses)
.setOwnerPubKeyBytes(ByteString.copyFrom(ownerPubKeyBytes))
.setSignerPubKeyAsHex(signerPubKeyAsHex)
.setCreationDate(creationDate);
.setCreationDate(creationDate)
.addAllBannedPrivilegedDevPubKeys(bannedPrivilegedDevPubKeys);
Optional.ofNullable(signatureAsBase64).ifPresent(builder::setSignatureAsBase64);
Optional.ofNullable(extraDataMap).ifPresent(builder::putAllExtraData);
@ -299,7 +308,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
proto.getCreationDate(),
CollectionUtils.isEmpty(proto.getExtraDataMap()) ? null : proto.getExtraDataMap(),
proto.getSignatureAsBase64(),
proto.getSignerPubKeyAsHex()
proto.getSignerPubKeyAsHex(),
ProtoUtil.protocolStringListToList(proto.getBannedPrivilegedDevPubKeysList())
);
}
@ -334,7 +344,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
",\n disableTradeBelowVersion='" + disableTradeBelowVersion + '\'' +
",\n mediators=" + mediators +
",\n refundAgents=" + refundAgents +
",\n bannedSignerPubKeys=" + bannedSignerPubKeys +
",\n bannedAccountWitnessSignerPubKeys=" + bannedSignerPubKeys +
",\n bannedPrivilegedDevPubKeys=" + bannedPrivilegedDevPubKeys +
",\n btcFeeReceiverAddresses=" + btcFeeReceiverAddresses +
",\n creationDate=" + creationDate +
",\n extraDataMap=" + extraDataMap +

View File

@ -2434,7 +2434,8 @@ filterWindow.onions=Filtered onion addresses (comma sep.)
filterWindow.accounts=Filtered trading account data:\nFormat: comma sep. list of [payment method id | data field | value]
filterWindow.bannedCurrencies=Filtered currency codes (comma sep.)
filterWindow.bannedPaymentMethods=Filtered payment method IDs (comma sep.)
filterWindow.bannedSignerPubKeys=Filtered signer pubkeys (comma sep. hex of pubkeys)
filterWindow.bannedAccountWitnessSignerPubKeys=Filtered account witness signer pub keys (comma sep. hex of pub keys)
filterWindow.bannedPrivilegedDevPubKeys=Filtered privileged dev pub keys (comma sep. hex of pub keys)
filterWindow.arbitrators=Filtered arbitrators (comma sep. onion addresses)
filterWindow.mediators=Filtered mediators (comma sep. onion addresses)
filterWindow.refundAgents=Filtered refund agents (comma sep. onion addresses)

View File

@ -113,8 +113,9 @@ public class FilterWindow extends Overlay<FilterWindow> {
gridPane.getColumnConstraints().get(0).setHalignment(HPos.LEFT);
InputTextField keyInputTextField = addInputTextField(gridPane, ++rowIndex, Res.get("shared.unlock"), 10);
if (useDevPrivilegeKeys)
if (useDevPrivilegeKeys) {
keyInputTextField.setText(DevEnv.DEV_PRIVILEGE_PRIV_KEY);
}
InputTextField offerIdsInputTextField = addInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.offers"));
InputTextField nodesInputTextField = addTopLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.onions")).second;
@ -125,8 +126,8 @@ public class FilterWindow extends Overlay<FilterWindow> {
InputTextField bannedCurrenciesInputTextField = addInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.bannedCurrencies"));
InputTextField bannedPaymentMethodsInputTextField = addTopLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.bannedPaymentMethods")).second;
bannedPaymentMethodsInputTextField.setPromptText("E.g. PERFECT_MONEY"); // Do not translate
InputTextField bannedSignerPubKeysInputTextField = addTopLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.bannedSignerPubKeys")).second;
bannedSignerPubKeysInputTextField.setPromptText("E.g. 7f66117aa084e5a2c54fe17d29dd1fee2b241257"); // Do not translate
InputTextField bannedAccountWitnessSignerPubKeysInputTextField = addTopLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.bannedAccountWitnessSignerPubKeys")).second;
bannedAccountWitnessSignerPubKeysInputTextField.setPromptText("E.g. 7f66117aa084e5a2c54fe17d29dd1fee2b241257"); // Do not translate
InputTextField arbitratorsInputTextField = addInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.arbitrators"));
InputTextField mediatorsInputTextField = addInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.mediators"));
InputTextField refundAgentsInputTextField = addInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.refundAgents"));
@ -138,6 +139,7 @@ public class FilterWindow extends Overlay<FilterWindow> {
CheckBox disableDaoCheckBox = addLabelCheckBox(gridPane, ++rowIndex, Res.get("filterWindow.disableDao"));
InputTextField disableDaoBelowVersionInputTextField = addInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.disableDaoBelowVersion"));
InputTextField disableTradeBelowVersionInputTextField = addInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.disableTradeBelowVersion"));
InputTextField bannedPrivilegedDevPubKeysInputTextField = addTopLabelInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.bannedPrivilegedDevPubKeys")).second;
Filter filter = filterManager.getDevFilter();
if (filter != null) {
@ -146,7 +148,7 @@ public class FilterWindow extends Overlay<FilterWindow> {
setupFieldFromPaymentAccountFiltersList(paymentAccountFilterInputTextField, filter.getBannedPaymentAccounts());
setupFieldFromList(bannedCurrenciesInputTextField, filter.getBannedCurrencies());
setupFieldFromList(bannedPaymentMethodsInputTextField, filter.getBannedPaymentMethods());
setupFieldFromList(bannedSignerPubKeysInputTextField, filter.getBannedSignerPubKeys());
setupFieldFromList(bannedAccountWitnessSignerPubKeysInputTextField, filter.getBannedSignerPubKeys());
setupFieldFromList(arbitratorsInputTextField, filter.getArbitrators());
setupFieldFromList(mediatorsInputTextField, filter.getMediators());
setupFieldFromList(refundAgentsInputTextField, filter.getRefundAgents());
@ -154,6 +156,8 @@ public class FilterWindow extends Overlay<FilterWindow> {
setupFieldFromList(seedNodesInputTextField, filter.getSeedNodes());
setupFieldFromList(priceRelayNodesInputTextField, filter.getPriceRelayNodes());
setupFieldFromList(btcNodesInputTextField, filter.getBtcNodes());
setupFieldFromList(btcNodesInputTextField, filter.getBtcNodes());
setupFieldFromList(bannedPrivilegedDevPubKeysInputTextField, filter.getBannedPrivilegedDevPubKeys());
preventPublicBtcNetworkCheckBox.setSelected(filter.isPreventPublicBtcNetwork());
disableDaoCheckBox.setSelected(filter.isDisableDao());
@ -185,10 +189,11 @@ public class FilterWindow extends Overlay<FilterWindow> {
disableTradeBelowVersionInputTextField.getText(),
readAsList(mediatorsInputTextField),
readAsList(refundAgentsInputTextField),
readAsList(bannedSignerPubKeysInputTextField),
readAsList(bannedAccountWitnessSignerPubKeysInputTextField),
readAsList(btcFeeReceiverAddressesInputTextField),
filterManager.getOwnerPubKey(),
signerPubKeyAsHex
signerPubKeyAsHex,
readAsList(bannedPrivilegedDevPubKeysInputTextField)
);
filterManager.addDevFilter(newFilter, privKeyString);

View File

@ -640,6 +640,7 @@ message Filter {
repeated string btc_fee_receiver_addresses = 20;
int64 creation_date = 21;
string signer_pub_key_as_hex = 22;
repeated string bannedPrivilegedDevPubKeys = 23;
}
// not used anymore from v0.6 on. But leave it for receiving TradeStatistics objects from older