From 1e1a51c0cf31f0ad03f5798b7c542c766a00285d Mon Sep 17 00:00:00 2001 From: premek <1145361+premek@users.noreply.github.com> Date: Wed, 12 May 2021 19:33:11 +0200 Subject: [PATCH] use XMR formatter in XMR BaseCurrencyNetworks --- .../common/config/BaseCurrencyNetwork.java | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/bisq/common/config/BaseCurrencyNetwork.java b/common/src/main/java/bisq/common/config/BaseCurrencyNetwork.java index f35b9ffb16..80291c3e9c 100644 --- a/common/src/main/java/bisq/common/config/BaseCurrencyNetwork.java +++ b/common/src/main/java/bisq/common/config/BaseCurrencyNetwork.java @@ -21,13 +21,14 @@ import org.bitcoinj.core.NetworkParameters; import org.bitcoinj.params.MainNetParams; import org.bitcoinj.params.RegTestParams; import org.bitcoinj.params.TestNet3Params; +import org.bitcoinj.utils.MonetaryFormat; import lombok.Getter; public enum BaseCurrencyNetwork { - XMR_MAINNET(MainNetParams.get(), "XMR", "MAINNET", "Monero"), - XMR_TESTNET(TestNet3Params.get(), "XMR", "TESTNET", "Monero"), - XMR_STAGENET(RegTestParams.get(), "XMR", "STAGENET", "Monero"), + XMR_MAINNET(new XmrMainNetParams(), "XMR", "MAINNET", "Monero"), + XMR_TESTNET(new XmrTestNet3Params(), "XMR", "TESTNET", "Monero"), + XMR_STAGENET(new XmrRegTestParams(), "XMR", "STAGENET", "Monero"), BTC_DAO_TESTNET(RegTestParams.get(), "XMR", "STAGENET", "Monero"), BTC_DAO_BETANET(MainNetParams.get(), "XMR", "MAINNET", "Monero"), // mainnet test genesis BTC_DAO_REGTEST(RegTestParams.get(), "XMR", "STAGENET", "Monero"); @@ -75,4 +76,27 @@ public enum BaseCurrencyNetwork { public long getDefaultMinFeePerVbyte() { return 15; // 2021-02-22 due to mempool congestion, increased from 2 } + + private static final MonetaryFormat XMR_MONETARY_FORMAT = new MonetaryFormat().minDecimals(2).repeatOptionalDecimals(2, 3).noCode().code(0, "XMR"); + + private static class XmrMainNetParams extends MainNetParams { + @Override + public MonetaryFormat getMonetaryFormat() { + return XMR_MONETARY_FORMAT; + } + } + + private static class XmrTestNet3Params extends TestNet3Params { + @Override + public MonetaryFormat getMonetaryFormat() { + return XMR_MONETARY_FORMAT; + } + } + + private static class XmrRegTestParams extends RegTestParams { + @Override + public MonetaryFormat getMonetaryFormat() { + return XMR_MONETARY_FORMAT; + } + } }