Use static fields for addresses

This commit is contained in:
chimp1984 2021-11-09 20:31:52 +01:00
parent e2bf77fb59
commit beb4590ef7
No known key found for this signature in database
GPG key ID: 9801B4EC591F90E3
5 changed files with 26 additions and 16 deletions

View file

@ -73,6 +73,7 @@ import bisq.core.dao.state.model.governance.Role;
import bisq.core.dao.state.model.governance.RoleProposal;
import bisq.core.dao.state.model.governance.Vote;
import bisq.core.dao.state.storage.DaoStateStorageService;
import bisq.core.trade.DelayedPayoutAddressProvider;
import bisq.asset.Asset;
@ -799,9 +800,9 @@ public class DaoFacade implements DaoSetupService {
if (Config.baseCurrencyNetwork().isMainnet()) {
// If Dao is deactivated we need to add the past addresses used as well.
// This list need to be updated once a new address gets defined.
allPastParamValues.add("3EtUWqsGThPtjwUczw27YCo6EWvQdaPUyp"); // burning man 2019
allPastParamValues.add("3A8Zc1XioE2HRzYfbb5P8iemCS72M6vRJV"); // burningman2
allPastParamValues.add("34VLFgtFKAtwTdZ5rengTT2g2zC99sWQLC"); // burningman3 (https://github.com/bisq-network/roles/issues/80#issuecomment-723577776)
allPastParamValues.add(DelayedPayoutAddressProvider.BM2019_ADDRESS);
allPastParamValues.add(DelayedPayoutAddressProvider.BM2_ADDRESS);
allPastParamValues.add(DelayedPayoutAddressProvider.BM3_ADDRESS);
}
return allPastParamValues;

View file

@ -148,7 +148,6 @@ public class DaoStateSnapshotService implements DaoSetupService, DaoStateListene
}
}
@Override
public void onParseBlockChainComplete() {
isParseBlockChainComplete = true;

View file

@ -24,24 +24,30 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class DelayedPayoutAddressProvider {
public static final String INITIAL_BM_ADDRESS = "1BVxNn3T12veSK6DgqwU4Hdn7QHcDDRag7"; // Initial DAO donation address
public static final String BM2019_ADDRESS = "3EtUWqsGThPtjwUczw27YCo6EWvQdaPUyp"; // burning2019
public static final String BM2_ADDRESS = "3A8Zc1XioE2HRzYfbb5P8iemCS72M6vRJV"; // burningman2
// burningman3 https://github.com/bisq-network/roles/issues/80#issuecomment-723577776
public static final String BM3_ADDRESS = "34VLFgtFKAtwTdZ5rengTT2g2zC99sWQLC";
public static String getDelayedPayoutAddress(DaoFacade daoFacade) {
String address = daoFacade.getParamValue(Param.RECIPIENT_BTC_ADDRESS);
if (isOutdatedAddress(address)) {
log.warn("Outdated delayed payout address. " +
"This can be the case if the DAO is deactivated or if the user has an invalid DAO state." +
"We set the address to the recent one (34VLFgtFKAtwTdZ5rengTT2g2zC99sWQLC).");
"We set the address to the recent one (BM3_ADDRESS).");
return getAddress();
}
return address;
}
public static boolean isOutdatedAddress(String address) {
return address.equals("1BVxNn3T12veSK6DgqwU4Hdn7QHcDDRag7") || // Initial DAO donation address
address.equals("3EtUWqsGThPtjwUczw27YCo6EWvQdaPUyp") || // burning2019
address.equals("3A8Zc1XioE2HRzYfbb5P8iemCS72M6vRJV"); // burningman2
return address.equals(INITIAL_BM_ADDRESS) ||
address.equals(BM2019_ADDRESS) ||
address.equals(BM2_ADDRESS);
}
public static String getAddress() {
return "34VLFgtFKAtwTdZ5rengTT2g2zC99sWQLC";
return BM3_ADDRESS;
}
}

View file

@ -32,8 +32,10 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class FeeReceiverSelector {
public static final String BTC_FEE_RECEIVER_ADDRESS = "38bZBj5peYS3Husdz7AH3gEUiUbYRD951t";
public static String getMostRecentAddress() {
return "38bZBj5peYS3Husdz7AH3gEUiUbYRD951t";
return BTC_FEE_RECEIVER_ADDRESS;
}
public static String getAddress(FilterManager filterManager) {

View file

@ -19,15 +19,17 @@ package bisq.core.provider.mempool;
import bisq.core.dao.governance.param.Param;
import bisq.core.dao.state.DaoStateService;
import bisq.core.trade.DelayedPayoutAddressProvider;
import bisq.core.util.FeeReceiverSelector;
import bisq.core.util.ParsingUtils;
import bisq.core.util.coin.BsqFormatter;
import org.bitcoinj.core.Coin;
import com.google.gson.Gson;
import org.apache.commons.io.IOUtils;
import org.bitcoinj.core.Coin;
import java.io.IOException;
import java.util.ArrayList;
@ -43,8 +45,8 @@ import org.slf4j.LoggerFactory;
import org.mockito.Mockito;
import org.mockito.stubbing.Answer;
import org.junit.Test;
import org.junit.Assert;
import org.junit.Test;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@ -61,11 +63,11 @@ public class TxValidatorTest {
btcFeeReceivers.add("13sxMq8mTw7CTSqgGiMPfwo6ZDsVYrHLmR");
btcFeeReceivers.add("19qA2BVPoyXDfHKVMovKG7SoxGY7xrBV8c");
btcFeeReceivers.add("19BNi5EpZhgBBWAt5ka7xWpJpX2ZWJEYyq");
btcFeeReceivers.add("38bZBj5peYS3Husdz7AH3gEUiUbYRD951t");
btcFeeReceivers.add("3EtUWqsGThPtjwUczw27YCo6EWvQdaPUyp");
btcFeeReceivers.add(FeeReceiverSelector.BTC_FEE_RECEIVER_ADDRESS);
btcFeeReceivers.add(DelayedPayoutAddressProvider.BM2019_ADDRESS);
btcFeeReceivers.add("1BVxNn3T12veSK6DgqwU4Hdn7QHcDDRag7");
btcFeeReceivers.add("3A8Zc1XioE2HRzYfbb5P8iemCS72M6vRJV");
btcFeeReceivers.add("34VLFgtFKAtwTdZ5rengTT2g2zC99sWQLC");
btcFeeReceivers.add(DelayedPayoutAddressProvider.BM3_ADDRESS);
log.warn("Known BTC fee receivers: {}", btcFeeReceivers.toString());
}