Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add burningman accounting #6423

Merged
merged 86 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
09a1af8
Add allowEmpty flag to InputValidator and BtcAddressValidator
HenrikJannsen Nov 3, 2022
5c7a330
Add burningManReceiverAddress as extraMap entry to CompensationProposal.
HenrikJannsen Nov 3, 2022
ea5662f
Add new methods to DaoStateService and DaoFacade.
HenrikJannsen Nov 3, 2022
739ff8e
Add BurningMan domain
HenrikJannsen Nov 3, 2022
5167f60
Add new addTableViewWithHeaderAndFilterField method to FormBuilder (w…
HenrikJannsen Nov 3, 2022
39a49ad
Add Burningman UI
HenrikJannsen Nov 3, 2022
e2ce053
Add burningManSelectionHeight fields to OfferAvailabilityRequest, Inp…
HenrikJannsen Nov 3, 2022
eee0b69
Remove FeeReceiverSelector and test as not used anymore
HenrikJannsen Nov 3, 2022
7b280c4
Use Burningmen receivers for delayed payout tx.
HenrikJannsen Nov 4, 2022
060b9c4
Validate delayedPayoutTx outputs size and amount only if BurningManSe…
HenrikJannsen Nov 4, 2022
e16a9b0
Add verifyDelayedPayoutTxReceivers method in RefundManager.
HenrikJannsen Nov 4, 2022
02a163f
Fix handling of null entries in getBtcFeeReceiverAddress method
HenrikJannsen Nov 4, 2022
fa857b3
Make codacy happy
HenrikJannsen Nov 4, 2022
731363d
Sort getBtcFeeReceiverAddress by amount and address.
HenrikJannsen Nov 4, 2022
58cabfa
Add expectedRevenue to BurningManCandidate.
HenrikJannsen Nov 5, 2022
7407ab8
Subtract accumulatedDecayedBurnAmount from allowedBurnAmount
HenrikJannsen Nov 5, 2022
19067ac
Cleanup
HenrikJannsen Nov 6, 2022
559ba6e
Refactor BurningManService
HenrikJannsen Nov 6, 2022
40a03eb
Move getAverageDistributionPerCycle to BurningManService and use from…
HenrikJannsen Nov 6, 2022
22f7b08
Remove reference to delayedPayoutTxReceiverService and btcFeeReceiver…
HenrikJannsen Nov 6, 2022
24ccacd
Remove unused fields
HenrikJannsen Nov 6, 2022
3fda949
Add sorting for output index needed for genesis tx outputs.
HenrikJannsen Nov 6, 2022
ec25722
Split up calculateShare into 4 distinct methods
HenrikJannsen Nov 6, 2022
508081a
Rearrange methods
HenrikJannsen Nov 6, 2022
92b38ed
Move BurningManUtil.getLegacyBurningManAddress to BurningManService.
HenrikJannsen Nov 6, 2022
7724b5b
Rename getBtcFeeReceiverAddress to getAddress
HenrikJannsen Nov 6, 2022
f0faa44
Remove `Current` from method names
HenrikJannsen Nov 6, 2022
52d48eb
Rename getDelayedPayoutTxReceivers to getReceivers
HenrikJannsen Nov 6, 2022
befe166
Refactor out fields from BurningManCandidate which are not affecting …
HenrikJannsen Nov 6, 2022
9fa9fbf
Fix incorrect cycle index
HenrikJannsen Nov 7, 2022
fb51861
Use months and not cycles for burn target and average.
HenrikJannsen Nov 7, 2022
88cf28c
Add applyBlock method and call at constructor (some classes get not i…
HenrikJannsen Nov 7, 2022
5799fb2
Add balance listener for burn bsq input
HenrikJannsen Nov 7, 2022
78d3fd8
Fix wrong initial value.
HenrikJannsen Nov 7, 2022
402c407
Add option to add opReturn data at BSQ wallet send screen for non-BSQ…
HenrikJannsen Nov 7, 2022
4e25d2f
Add isDevMode check to set dev params
HenrikJannsen Nov 7, 2022
a6a0188
Add isDevTesting method for adjusting behaviour for dev testing purposes
HenrikJannsen Nov 7, 2022
625939b
Bugfix: set burningManSelectionHeight and tradeTxFee at dispute clone
HenrikJannsen Nov 7, 2022
1e8ec6f
Add details if donationAddressOfDelayedPayoutTx check fails
HenrikJannsen Nov 7, 2022
46776ee
Use null as default value for donationAddressString
HenrikJannsen Nov 7, 2022
516004d
Change ISSUANCE_BOOST_FACTOR to 3
HenrikJannsen Nov 8, 2022
2799cca
Add util class for cycle related methods with caching
HenrikJannsen Nov 8, 2022
683bc40
Use cycles for periods instead of blocks in months/years.
HenrikJannsen Nov 8, 2022
3213c5e
Avoid negative cycle index
HenrikJannsen Nov 9, 2022
c747a48
Fix duration calculations
HenrikJannsen Nov 9, 2022
3a7af07
Improve burn target calculation and display
HenrikJannsen Nov 10, 2022
c1b8871
Fix burn target calculations
HenrikJannsen Nov 10, 2022
b7a5b56
Add legacy burningman to btc fee distribution in case we do not reach…
HenrikJannsen Nov 10, 2022
2b4b6fe
Add logs for delayedPayoutTx receiver data
HenrikJannsen Nov 10, 2022
883b054
Fix getSnapshotHeight method
HenrikJannsen Nov 10, 2022
d4646cc
Add LegacyBurningMan to UI
HenrikJannsen Nov 11, 2022
7f2b62f
Don't show decayedAmount for LegacyBurningMan
HenrikJannsen Nov 11, 2022
d31493b
Use TradeWalletService.MIN_DELAYED_PAYOUT_TX_FEE as min value for min…
HenrikJannsen Nov 13, 2022
c1dc317
Remove unused methods
HenrikJannsen Nov 17, 2022
dff6d48
Refactoring: Move BM model classes into model package. Adjust visibil…
HenrikJannsen Nov 17, 2022
0e79582
Refactoring: Move isActivated method to BurningManService
HenrikJannsen Nov 17, 2022
8ab2582
Use check for isRegtest instead of test for isDevTesting to set dev p…
HenrikJannsen Nov 17, 2022
d30ec07
Cleanup/add comments
HenrikJannsen Nov 17, 2022
4e08bcd
Split up legacy BM into DPT and BTC fee BM
HenrikJannsen Nov 18, 2022
4ce6ce7
Add check for isActivated and if not return LEGACY_BURNING_MAN_BTC_FE…
HenrikJannsen Nov 18, 2022
7cbc5d6
Increase ISSUANCE_BOOST_FACTOR to 3
HenrikJannsen Nov 18, 2022
eeaafc1
Use HashSet instead Lists.
HenrikJannsen Nov 21, 2022
fa4c952
Apply code review feedback
HenrikJannsen Nov 27, 2022
97ba156
Improve receiver distribution to avoid that legacy BM gets outputs if…
HenrikJannsen Nov 27, 2022
d12c8b5
Remove TODO, rename method
HenrikJannsen Nov 27, 2022
adb0242
Remove unused var
HenrikJannsen Dec 9, 2022
ff55830
Add DateUtil and Hex.decodeLast4Bytes
HenrikJannsen Nov 21, 2022
2615309
Add Config options
HenrikJannsen Nov 21, 2022
bc9ccfd
Add `String formatCoin(long value)` API to CoinFormatter
HenrikJannsen Nov 21, 2022
e2f7c4e
Make AveragePriceUtil.getAveragePriceTuple mor flexible
HenrikJannsen Nov 21, 2022
a551a41
Add support for multiple clients calling the setup method.
HenrikJannsen Nov 21, 2022
f9db6e0
Add support for multiple clients adding a block handler.
HenrikJannsen Nov 22, 2022
d4a0032
Add new fields and methods
HenrikJannsen Nov 22, 2022
90550de
Add messages and domain data for accounting domain
HenrikJannsen Nov 22, 2022
22c4376
Add BurningManAccountingService to CorePersistedDataHost
HenrikJannsen Nov 22, 2022
a9bf52d
Add BurningMan accounting domain
HenrikJannsen Nov 22, 2022
446762f
Add BM account UI
HenrikJannsen Nov 22, 2022
a03b0ea
Make codacy happy
HenrikJannsen Nov 24, 2022
1bb4b55
Add BurningManAccountingStore resource file.
HenrikJannsen Nov 25, 2022
891685f
Update TAC text and layout
HenrikJannsen Nov 25, 2022
65eebef
Make copy icon in popups smaller
HenrikJannsen Nov 25, 2022
c8a9b9a
Improve TAC text
HenrikJannsen Nov 25, 2022
e3a0ae9
Use constants for opReturn data. Rename hash to opReturnData.
HenrikJannsen Dec 9, 2022
46b2cf9
Remove DevEnv.isDevTesting
HenrikJannsen Dec 9, 2022
b7d5af1
Add MAX_BURN_TARGET_LOWER_FLOOR to avoid cases where small burn amoun…
HenrikJannsen Dec 9, 2022
e57af6e
Update mediation popup text
HenrikJannsen Dec 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions common/src/main/java/bisq/common/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ public class Config {
public static final String BYPASS_MEMPOOL_VALIDATION = "bypassMempoolValidation";
public static final String DAO_NODE_API_URL = "daoNodeApiUrl";
public static final String DAO_NODE_API_PORT = "daoNodeApiPort";
public static final String IS_BM_FULL_NODE = "isBmFullNode";
public static final String BM_ORACLE_NODE_PUB_KEY = "bmOracleNodePubKey";
public static final String BM_ORACLE_NODE_PRIV_KEY = "bmOracleNodePrivKey";
public static final String SEED_NODE_REPORTING_SERVER_URL = "seedNodeReportingServerUrl";

// Default values for certain options
Expand Down Expand Up @@ -221,6 +224,9 @@ public class Config {
public final boolean bypassMempoolValidation;
public final String daoNodeApiUrl;
public final int daoNodeApiPort;
public final boolean isBmFullNode;
public final String bmOracleNodePubKey;
public final String bmOracleNodePrivKey;
public final String seedNodeReportingServerUrl;

// Properties derived from options but not exposed as options themselves
Expand Down Expand Up @@ -681,6 +687,23 @@ public Config(String defaultAppName, File defaultUserDataDir, String... args) {
.withRequiredArg()
.ofType(Integer.class)
.defaultsTo(8082);

ArgumentAcceptingOptionSpec<Boolean> isBmFullNode =
parser.accepts(IS_BM_FULL_NODE, "Run as Burningman full node")
.withRequiredArg()
.ofType(boolean.class)
.defaultsTo(false);

ArgumentAcceptingOptionSpec<String> bmOracleNodePubKey =
parser.accepts(BM_ORACLE_NODE_PUB_KEY, "Burningman oracle node public key")
.withRequiredArg()
.defaultsTo("");

ArgumentAcceptingOptionSpec<String> bmOracleNodePrivKey =
parser.accepts(BM_ORACLE_NODE_PRIV_KEY, "Burningman oracle node private key")
.withRequiredArg()
.defaultsTo("");

ArgumentAcceptingOptionSpec<String> seedNodeReportingServerUrlOpt =
parser.accepts(SEED_NODE_REPORTING_SERVER_URL, "URL of seed node reporting server")
.withRequiredArg()
Expand Down Expand Up @@ -806,6 +829,9 @@ public Config(String defaultAppName, File defaultUserDataDir, String... args) {
this.bypassMempoolValidation = options.valueOf(bypassMempoolValidationOpt);
this.daoNodeApiUrl = options.valueOf(daoNodeApiUrlOpt);
this.daoNodeApiPort = options.valueOf(daoNodeApiPortOpt);
this.isBmFullNode = options.valueOf(isBmFullNode);
this.bmOracleNodePubKey = options.valueOf(bmOracleNodePubKey);
this.bmOracleNodePrivKey = options.valueOf(bmOracleNodePrivKey);
this.seedNodeReportingServerUrl = options.valueOf(seedNodeReportingServerUrlOpt);
} catch (OptionException ex) {
throw new ConfigException("problem parsing option '%s': %s",
Expand Down
60 changes: 60 additions & 0 deletions common/src/main/java/bisq/common/util/DateUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.common.util;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class DateUtil {
/**
*
* @param date The date which should be reset to first day of month
* @return First day in given date with time set to zero.
*/
public static Date getStartOfMonth(Date date) {
Calendar calendar = new GregorianCalendar();
calendar.setTime(date);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
}

/**
*
* @param year The year
* @param month The month starts with 0 for January
* @return First day in given month with time set to zero.
*/
public static Date getStartOfMonth(int year, int month) {
Calendar calendar = new GregorianCalendar();
calendar.setTime(new Date());
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
Date time = calendar.getTime();
return time;
}
}
4 changes: 4 additions & 0 deletions common/src/main/java/bisq/common/util/Hex.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ public static byte[] decode(String hex) {
public static String encode(byte[] bytes) {
return BaseEncoding.base16().lowerCase().encode(bytes);
}

public static byte[] decodeLast4Bytes(String hex) {
return decode(hex.substring(hex.length() - 8));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ private Transaction getPreparedSendTx(String receiverAddress,
coinSelector.setUtxoCandidates(null); // We reuse the selectors. Reset the transactionOutputCandidates field
return tx;
} catch (InsufficientMoneyException e) {
log.error("getPreparedSendTx: tx={}", tx.toString());
log.error("getPreparedSendTx: tx={}", tx);
log.error(e.toString());
throw new InsufficientBsqException(e.missing);
}
Expand Down
23 changes: 19 additions & 4 deletions core/src/main/java/bisq/core/btc/wallet/TradeWalletService.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@

public class TradeWalletService {
private static final Logger log = LoggerFactory.getLogger(TradeWalletService.class);
private static final Coin MIN_DELAYED_PAYOUT_TX_FEE = Coin.valueOf(1000);
public static final Coin MIN_DELAYED_PAYOUT_TX_FEE = Coin.valueOf(1000);

private final WalletsSetup walletsSetup;
private final Preferences preferences;
Expand Down Expand Up @@ -696,16 +696,31 @@ public void sellerAddsBuyerWitnessesToDepositTx(Transaction myDepositTx,
// Delayed payout tx
///////////////////////////////////////////////////////////////////////////////////////////

public Transaction createDelayedUnsignedPayoutTx(Transaction depositTx,
List<Tuple2<Long, String>> receivers,
long lockTime)
throws AddressFormatException, TransactionVerificationException {
TransactionOutput depositTxOutput = depositTx.getOutput(0);
Transaction delayedPayoutTx = new Transaction(params);
delayedPayoutTx.addInput(depositTxOutput);
applyLockTime(lockTime, delayedPayoutTx);
checkArgument(!receivers.isEmpty(), "receivers must not be empty");
receivers.forEach(receiver -> delayedPayoutTx.addOutput(Coin.valueOf(receiver.first), Address.fromString(params, receiver.second)));
WalletService.printTx("Unsigned delayedPayoutTx ToDonationAddress", delayedPayoutTx);
WalletService.verifyTransaction(delayedPayoutTx);
return delayedPayoutTx;
}

public Transaction createDelayedUnsignedPayoutTx(Transaction depositTx,
String donationAddressString,
Coin minerFee,
long lockTime)
throws AddressFormatException, TransactionVerificationException {
TransactionOutput hashedMultiSigOutput = depositTx.getOutput(0);
TransactionOutput depositTxOutput = depositTx.getOutput(0);
Transaction delayedPayoutTx = new Transaction(params);
delayedPayoutTx.addInput(hashedMultiSigOutput);
delayedPayoutTx.addInput(depositTxOutput);
applyLockTime(lockTime, delayedPayoutTx);
Coin outputAmount = hashedMultiSigOutput.getValue().subtract(minerFee);
Coin outputAmount = depositTxOutput.getValue().subtract(minerFee);
delayedPayoutTx.addOutput(outputAmount, Address.fromString(params, donationAddressString));
WalletService.printTx("Unsigned delayedPayoutTx ToDonationAddress", delayedPayoutTx);
WalletService.verifyTransaction(delayedPayoutTx);
Expand Down
127 changes: 127 additions & 0 deletions core/src/main/java/bisq/core/dao/CyclesInDaoStateService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.core.dao;

import bisq.core.dao.governance.period.CycleService;
import bisq.core.dao.state.DaoStateService;
import bisq.core.dao.state.model.governance.Cycle;
import bisq.core.dao.state.model.governance.DaoPhase;

import javax.inject.Inject;
import javax.inject.Singleton;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

import lombok.extern.slf4j.Slf4j;

/**
* Utility methods for Cycle related methods.
* As they might be called often we use caching.
*/
@Slf4j
@Singleton
public class CyclesInDaoStateService {
private final DaoStateService daoStateService;
private final CycleService cycleService;

// Cached results
private final Map<Integer, Cycle> cyclesByHeight = new HashMap<>();
private final Map<Cycle, Integer> indexByCycle = new HashMap<>();
private final Map<Integer, Cycle> cyclesByIndex = new HashMap<>();

@Inject
public CyclesInDaoStateService(DaoStateService daoStateService, CycleService cycleService) {
this.daoStateService = daoStateService;
this.cycleService = cycleService;
}

public int getCycleIndexAtChainHeight(int chainHeight) {
return findCycleAtHeight(chainHeight)
.map(cycleService::getCycleIndex)
.orElse(-1);
}

public int getHeightOfFirstBlockOfResultPhaseOfPastCycle(int chainHeight, int numPastCycles) {
return findCycleAtHeight(chainHeight)
.map(cycle -> {
int cycleIndex = getIndexForCycle(cycle);
int targetIndex = Math.max(0, (cycleIndex - numPastCycles));
return getCycleAtIndex(targetIndex);
})
.map(cycle -> cycle.getFirstBlockOfPhase(DaoPhase.Phase.RESULT))
.orElse(daoStateService.getGenesisBlockHeight());
}

/**
*
* @param chainHeight Chain height from where we start
* @param numPastCycles Number of past cycles
* @return The height at the same offset from the first block of the cycle as in the current cycle minus the past cycles.
*/
public int getChainHeightOfPastCycle(int chainHeight, int numPastCycles) {
int firstBlockOfPastCycle = getHeightOfFirstBlockOfPastCycle(chainHeight, numPastCycles);
if (firstBlockOfPastCycle == daoStateService.getGenesisBlockHeight()) {
return firstBlockOfPastCycle;
}
return firstBlockOfPastCycle + getOffsetFromFirstBlockInCycle(chainHeight);
}

public Integer getOffsetFromFirstBlockInCycle(int chainHeight) {
return daoStateService.getCycle(chainHeight)
.map(c -> chainHeight - c.getHeightOfFirstBlock())
.orElse(0);
}

public int getHeightOfFirstBlockOfPastCycle(int chainHeight, int numPastCycles) {
return findCycleAtHeight(chainHeight)
.map(cycle -> getIndexForCycle(cycle) - numPastCycles)
.filter(targetIndex -> targetIndex > 0)
.map(targetIndex -> getCycleAtIndex(targetIndex).getHeightOfFirstBlock())
.orElse(daoStateService.getGenesisBlockHeight());
}

public Cycle getCycleAtIndex(int index) {
int cycleIndex = Math.max(0, index);
return Optional.ofNullable(cyclesByIndex.get(cycleIndex))
.orElseGet(() -> {
Cycle cycle = daoStateService.getCycleAtIndex(cycleIndex);
cyclesByIndex.put(cycleIndex, cycle);
return cycle;
});
}

public int getIndexForCycle(Cycle cycle) {
return Optional.ofNullable(indexByCycle.get(cycle))
.orElseGet(() -> {
int index = cycleService.getCycleIndex(cycle);
indexByCycle.put(cycle, index);
return index;
});
}

public Optional<Cycle> findCycleAtHeight(int chainHeight) {
return Optional.ofNullable(cyclesByHeight.get(chainHeight))
.or(() -> {
Optional<Cycle> optionalCycle = daoStateService.getCycle(chainHeight);
optionalCycle.ifPresent(cycle -> cyclesByHeight.put(chainHeight, cycle));
return optionalCycle;
});
}
}
6 changes: 4 additions & 2 deletions core/src/main/java/bisq/core/dao/DaoFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,13 @@ public ObservableList<Proposal> getActiveOrMyUnconfirmedProposals() {
// Creation of Proposal and proposalTransaction
public ProposalWithTransaction getCompensationProposalWithTransaction(String name,
String link,
Coin requestedBsq)
Coin requestedBsq,
Optional<String> burningManReceiverAddress)
throws ProposalValidationException, InsufficientMoneyException, TxException {
return compensationProposalFactory.createProposalWithTransaction(name,
link,
requestedBsq);
requestedBsq,
burningManReceiverAddress);
}

public ProposalWithTransaction getReimbursementProposalWithTransaction(String name,
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/bisq/core/dao/DaoModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ protected void configure() {
bindConstant().annotatedWith(named(Config.RPC_BLOCK_NOTIFICATION_HOST)).to(config.rpcBlockNotificationHost);
bindConstant().annotatedWith(named(Config.DUMP_BLOCKCHAIN_DATA)).to(config.dumpBlockchainData);
bindConstant().annotatedWith(named(Config.FULL_DAO_NODE)).to(config.fullDaoNode);
bindConstant().annotatedWith(named(Config.IS_BM_FULL_NODE)).to(config.isBmFullNode);
bindConstant().annotatedWith(named(Config.BM_ORACLE_NODE_PUB_KEY)).to(config.bmOracleNodePubKey);
bindConstant().annotatedWith(named(Config.BM_ORACLE_NODE_PRIV_KEY)).to(config.bmOracleNodePrivKey);
}
}

17 changes: 15 additions & 2 deletions core/src/main/java/bisq/core/dao/DaoSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

package bisq.core.dao;

import bisq.core.dao.burningman.accounting.BurningManAccountingService;
import bisq.core.dao.burningman.accounting.node.AccountingNode;
import bisq.core.dao.burningman.accounting.node.AccountingNodeProvider;
import bisq.core.dao.governance.asset.AssetService;
import bisq.core.dao.governance.ballot.BallotListService;
import bisq.core.dao.governance.blindvote.BlindVoteListService;
Expand Down Expand Up @@ -54,9 +57,11 @@
public class DaoSetup {
private final BsqNode bsqNode;
private final List<DaoSetupService> daoSetupServices = new ArrayList<>();
private final AccountingNode accountingNode;

@Inject
public DaoSetup(BsqNodeProvider bsqNodeProvider,
AccountingNodeProvider accountingNodeProvider,
DaoStateService daoStateService,
CycleService cycleService,
BallotListService ballotListService,
Expand All @@ -79,9 +84,11 @@ public DaoSetup(BsqNodeProvider bsqNodeProvider,
DaoStateMonitoringService daoStateMonitoringService,
ProposalStateMonitoringService proposalStateMonitoringService,
BlindVoteStateMonitoringService blindVoteStateMonitoringService,
DaoStateSnapshotService daoStateSnapshotService) {
DaoStateSnapshotService daoStateSnapshotService,
BurningManAccountingService burningManAccountingService) {

bsqNode = bsqNodeProvider.getBsqNode();
accountingNode = accountingNodeProvider.getAccountingNode();

// We need to take care of order of execution.
daoSetupServices.add(daoStateService);
Expand All @@ -107,15 +114,20 @@ public DaoSetup(BsqNodeProvider bsqNodeProvider,
daoSetupServices.add(proposalStateMonitoringService);
daoSetupServices.add(blindVoteStateMonitoringService);
daoSetupServices.add(daoStateSnapshotService);
daoSetupServices.add(burningManAccountingService);

daoSetupServices.add(bsqNodeProvider.getBsqNode());
daoSetupServices.add(bsqNode);
daoSetupServices.add(accountingNode);
}

public void onAllServicesInitialized(Consumer<String> errorMessageHandler,
Consumer<String> warnMessageHandler) {
bsqNode.setErrorMessageHandler(errorMessageHandler);
bsqNode.setWarnMessageHandler(warnMessageHandler);

accountingNode.setErrorMessageHandler(errorMessageHandler);
accountingNode.setWarnMessageHandler(warnMessageHandler);

// We add first all listeners at all services and then call the start methods.
// Some services are listening on others so we need to make sure that the
// listeners are set before we call start as that might trigger state change
Expand All @@ -126,5 +138,6 @@ public void onAllServicesInitialized(Consumer<String> errorMessageHandler,

public void shutDown() {
bsqNode.shutDown();
accountingNode.shutDown();
}
}
Loading