Change base networks from btc to xmr, e.g. BTC_REGTEST -> XMR_STAGENET (#55)

change base networks from btc to xmr, e.g. BTC_REGTEST -> XMR_STAGENET

add xmr seed node files
This commit is contained in:
woodser 2021-05-08 13:57:32 -04:00 committed by GitHub
parent de5bbf4a85
commit 9903821b18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
62 changed files with 353 additions and 181 deletions

View file

@ -174,6 +174,9 @@ public class CliMain {
case "BTC":
out.println(formatBtcBalanceInfoTbl(balances.getBtc()));
break;
case "XMR":
out.println(formatXmrBalanceInfoTbl(balances.getXmr()));
break;
case "":
default:
out.println(formatBalancesTbls(balances));

View file

@ -31,6 +31,7 @@ class ColumnHeaderConstants {
// lengths are expected to be greater than any column value length.
static final String COL_HEADER_ADDRESS = padEnd("%-3s Address", 52, ' ');
static final String COL_HEADER_AMOUNT = "BTC(min - max)";
static final String COL_HEADER_BALANCE = "Balance";
static final String COL_HEADER_AVAILABLE_BALANCE = "Available Balance";
static final String COL_HEADER_AVAILABLE_CONFIRMED_BALANCE = "Available Confirmed Balance";
static final String COL_HEADER_UNCONFIRMED_CHANGE_BALANCE = "Unconfirmed Change Balance";

View file

@ -51,6 +51,8 @@ public class CurrencyFormat {
static final DecimalFormat SEND_BSQ_FORMAT = new DecimalFormat("###########0.00");
static final BigDecimal SECURITY_DEPOSIT_MULTIPLICAND = new BigDecimal("0.01");
// TODO: (woodser): replace formatSatoshis(), formatBsq() with formatXmr()
@SuppressWarnings("BigDecimalMethodWithoutRoundingCalled")
public static String formatSatoshis(long sats) {

View file

@ -30,19 +30,19 @@ import static protobuf.OfferPayload.Direction.SELL;
class DirectionFormat {
static int getLongestDirectionColWidth(List<OfferInfo> offers) {
if (offers.isEmpty() || offers.get(0).getBaseCurrencyCode().equals("BTC"))
if (offers.isEmpty() || offers.get(0).getBaseCurrencyCode().equals("XMR"))
return COL_HEADER_DIRECTION.length();
else
return 18; // .e.g., "Sell BSQ (Buy BTC)".length()
return 18; // .e.g., "Sell BSQ (Buy XMR)".length()
}
static final Function<OfferInfo, String> directionFormat = (offer) -> {
String baseCurrencyCode = offer.getBaseCurrencyCode();
boolean isCryptoCurrencyOffer = !baseCurrencyCode.equals("BTC");
boolean isCryptoCurrencyOffer = !baseCurrencyCode.equals("XMR");
if (!isCryptoCurrencyOffer) {
return baseCurrencyCode;
} else {
// Return "Sell BSQ (Buy BTC)", or "Buy BSQ (Sell BTC)".
// Return "Sell BSQ (Buy XMR)", or "Buy BSQ (Sell XMR)".
String direction = offer.getDirection();
String mirroredDirection = getMirroredDirection(direction);
Function<String, String> mixedCase = (word) -> word.charAt(0) + word.substring(1).toLowerCase();

View file

@ -64,6 +64,7 @@ import bisq.proto.grpc.UnlockWalletRequest;
import bisq.proto.grpc.UnsetTxFeeRatePreferenceRequest;
import bisq.proto.grpc.VerifyBsqSentToAddressRequest;
import bisq.proto.grpc.WithdrawFundsRequest;
import bisq.proto.grpc.XmrBalanceInfo;
import protobuf.PaymentAccount;
import protobuf.PaymentMethod;
@ -107,6 +108,10 @@ public final class GrpcClient {
return getBalances("BTC").getBtc();
}
public XmrBalanceInfo getXmrBalances() {
return getBalances("XMR").getXmr();
}
public BalancesInfo getBalances(String currencyCode) {
var request = GetBalancesRequest.newBuilder()
.setCurrencyCode(currencyCode)
@ -299,7 +304,7 @@ public final class GrpcClient {
}
public List<OfferInfo> getCryptoCurrencyOffers(String direction, String currencyCode) {
return getOffers(direction, "BTC").stream()
return getOffers(direction, "XMR").stream()
.filter(o -> o.getBaseCurrencyCode().equalsIgnoreCase(currencyCode))
.collect(toList());
}

View file

@ -22,6 +22,7 @@ import bisq.proto.grpc.BalancesInfo;
import bisq.proto.grpc.BsqBalanceInfo;
import bisq.proto.grpc.BtcBalanceInfo;
import bisq.proto.grpc.OfferInfo;
import bisq.proto.grpc.XmrBalanceInfo;
import protobuf.PaymentAccount;
@ -56,7 +57,7 @@ public class TableFormat {
+ COL_HEADER_AVAILABLE_BALANCE + COL_HEADER_DELIMITER
+ COL_HEADER_CONFIRMATIONS + COL_HEADER_DELIMITER
+ COL_HEADER_IS_USED_ADDRESS + COL_HEADER_DELIMITER + "\n";
String headerLine = format(headerFormatString, "BTC");
String headerLine = format(headerFormatString, "XMR");
String colDataFormat = "%-" + COL_HEADER_ADDRESS.length() + "s" // lt justify
+ " %" + (COL_HEADER_AVAILABLE_BALANCE.length() - 1) + "s" // rt justify
@ -73,7 +74,7 @@ public class TableFormat {
}
public static String formatBalancesTbls(BalancesInfo balancesInfo) {
return "BTC" + "\n"
return "XMR" + "\n"
+ formatBtcBalanceInfoTbl(balancesInfo.getBtc()) + "\n"
+ "BSQ" + "\n"
+ formatBsqBalanceInfoTbl(balancesInfo.getBsq());
@ -117,6 +118,24 @@ public class TableFormat {
formatSatoshis(btcBalanceInfo.getLockedBalance()));
}
public static String formatXmrBalanceInfoTbl(XmrBalanceInfo xmrBalanceInfo) {
String headerLine = COL_HEADER_BALANCE + COL_HEADER_DELIMITER
+ COL_HEADER_AVAILABLE_BALANCE + COL_HEADER_DELIMITER
+ COL_HEADER_RESERVED_BALANCE + COL_HEADER_DELIMITER
+ COL_HEADER_TOTAL_AVAILABLE_BALANCE + COL_HEADER_DELIMITER // TODO (woodser): column names are not quite right for XMR (balance, available balance, locked balance, reserved balance, total balance)
+ COL_HEADER_LOCKED_BALANCE + COL_HEADER_DELIMITER + "\n";
String colDataFormat = "%" + COL_HEADER_BALANCE.length() + "s" // rt justify
+ " %" + (COL_HEADER_AVAILABLE_BALANCE.length() + 1) + "s" // rt justify
+ " %" + (COL_HEADER_RESERVED_BALANCE.length() + 1) + "s" // rt justify
+ " %" + (COL_HEADER_TOTAL_AVAILABLE_BALANCE.length() + 1) + "s" // rt justify
+ " %" + (COL_HEADER_LOCKED_BALANCE.length() + 1) + "s"; // rt justify
return headerLine + format(colDataFormat,
formatSatoshis(xmrBalanceInfo.getAvailableBalance()),
formatSatoshis(xmrBalanceInfo.getReservedBalance()),
formatSatoshis(xmrBalanceInfo.getTotalBalance()),
formatSatoshis(xmrBalanceInfo.getLockedBalance()));
}
public static String formatPaymentAcctTbl(List<PaymentAccount> paymentAccounts) {
// Some column values might be longer than header, so we need to calculate them.
int nameColWidth = getLongestColumnSize(
@ -150,7 +169,7 @@ public class TableFormat {
throw new IllegalArgumentException(format("%s offers argument is empty", currencyCode.toLowerCase()));
String baseCurrencyCode = offers.get(0).getBaseCurrencyCode();
return baseCurrencyCode.equalsIgnoreCase("BTC")
return baseCurrencyCode.equalsIgnoreCase("XMR")
? formatFiatOfferTable(offers, currencyCode)
: formatCryptoCurrencyOfferTable(offers, baseCurrencyCode);
}

View file

@ -135,13 +135,13 @@ public class TradeFormat {
bsqReceiveAddress.apply(tradeInfo, showBsqBuyerAddress));
}
private static final Function<TradeInfo, String> priceHeader = (t) -> // TODO (woodser): update these to XMR
t.getOffer().getBaseCurrencyCode().equals("BTC")
private static final Function<TradeInfo, String> priceHeader = (t) ->
t.getOffer().getBaseCurrencyCode().equals("XMR")
? COL_HEADER_PRICE
: COL_HEADER_PRICE_OF_ALTCOIN;
private static final Function<TradeInfo, String> priceHeaderCurrencyCode = (t) ->
t.getOffer().getBaseCurrencyCode().equals("BTC")
t.getOffer().getBaseCurrencyCode().equals("XMR")
? t.getOffer().getCounterCurrencyCode()
: t.getOffer().getBaseCurrencyCode();
@ -150,18 +150,18 @@ public class TradeFormat {
};
private static final Function<TradeInfo, String> paymentStatusHeaderCurrencyCode = (t) ->
t.getOffer().getBaseCurrencyCode().equals("BTC")
t.getOffer().getBaseCurrencyCode().equals("XMR")
? t.getOffer().getCounterCurrencyCode()
: t.getOffer().getBaseCurrencyCode();
private static final Function<TradeInfo, String> priceFormat = (t) ->
t.getOffer().getBaseCurrencyCode().equals("BTC")
t.getOffer().getBaseCurrencyCode().equals("XMR")
? formatPrice(t.getTradePrice())
: formatCryptoCurrencyPrice(t.getOffer().getPrice());
private static final Function<TradeInfo, String> amountFormat = (t) ->
t.getOffer().getBaseCurrencyCode().equals("BTC")
? formatSatoshis(t.getTradeAmountAsLong()) // TODO (woodser): delete formatSatoshis(), formatBsq() and change base currency code to XMR
t.getOffer().getBaseCurrencyCode().equals("XMR")
? formatXmr(ParsingUtils.satoshisToXmrAtomicUnits(t.getTradeAmountAsLong()))
: formatCryptoCurrencyOfferVolume(t.getOffer().getVolume());
private static final BiFunction<TradeInfo, Boolean, String> makerTakerMinerTxFeeFormat = (t, isTaker) -> {
@ -177,15 +177,15 @@ public class TradeFormat {
};
private static final Function<TradeInfo, String> tradeCostFormat = (t) ->
t.getOffer().getBaseCurrencyCode().equals("BTC")
t.getOffer().getBaseCurrencyCode().equals("XMR")
? formatOfferVolume(t.getOffer().getVolume())
: formatSatoshis(t.getTradeAmountAsLong());
: formatXmr(ParsingUtils.satoshisToXmrAtomicUnits(t.getTradeAmountAsLong()));
private static final BiFunction<TradeInfo, Boolean, String> bsqReceiveAddress = (t, showBsqBuyerAddress) -> {
if (showBsqBuyerAddress) {
ContractInfo contract = t.getContract();
boolean isBuyerMakerAndSellerTaker = contract.getIsBuyerMakerAndSellerTaker();
return isBuyerMakerAndSellerTaker // (is BTC buyer / maker)
return isBuyerMakerAndSellerTaker // (is XMR buyer / maker)
? contract.getTakerPaymentAccountPayload().getAddress()
: contract.getMakerPaymentAccountPayload().getAddress();
} else {
@ -194,12 +194,12 @@ public class TradeFormat {
};
private static boolean shouldShowBsqBuyerAddress(TradeInfo tradeInfo, boolean isTaker) {
if (tradeInfo.getOffer().getBaseCurrencyCode().equals("BTC")) {
if (tradeInfo.getOffer().getBaseCurrencyCode().equals("XMR")) {
return false;
} else {
ContractInfo contract = tradeInfo.getContract();
// Do not forget buyer and seller refer to BTC buyer and seller, not BSQ
// buyer and seller. If you are buying BSQ, you are the (BTC) seller.
// Do not forget buyer and seller refer to XMR buyer and seller, not BSQ
// buyer and seller. If you are buying BSQ, you are the XMR seller.
boolean isBuyerMakerAndSellerTaker = contract.getIsBuyerMakerAndSellerTaker();
if (isTaker) {
return !isBuyerMakerAndSellerTaker;