Add new extraMap entry for offer.

If maker is seller and is a xmr offer and has autoConf enabled we set a flag ("1")
This commit is contained in:
chimp1984 2020-09-28 23:26:29 -05:00
parent 20135a1662
commit 7280fb822d
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3
3 changed files with 16 additions and 2 deletions

View File

@ -203,7 +203,9 @@ public class CreateOfferService {
Map<String, String> extraDataMap = OfferUtil.getExtraDataMap(accountAgeWitnessService,
referralIdService,
paymentAccount,
currencyCode);
currencyCode,
preferences,
direction);
OfferUtil.validateOfferData(filterManager,
p2PService,

View File

@ -85,6 +85,8 @@ public final class OfferPayload implements ProtectedStoragePayload, ExpirablePay
// Capability.SIGNED_ACCOUNT_AGE_WITNESS is 11 and Capability.MEDIATION is 12 so if we want to signal that maker
// of the offer supports both capabilities we add "11, 12" to capabilities.
public static final String CAPABILITIES = "capabilities";
// If maker is seller and has xmrAutoConf enabled it is set to "1" otherwise it is not set
public static final String XMR_AUTO_CONF = "xmrAutoConf";
///////////////////////////////////////////////////////////////////////////////////////////

View File

@ -31,6 +31,7 @@ import bisq.core.provider.fee.FeeService;
import bisq.core.provider.price.MarketPrice;
import bisq.core.provider.price.PriceFeedService;
import bisq.core.trade.statistics.ReferralIdService;
import bisq.core.user.AutoConfirmSettings;
import bisq.core.user.Preferences;
import bisq.core.util.coin.CoinFormatter;
import bisq.core.util.coin.CoinUtil;
@ -333,7 +334,9 @@ public class OfferUtil {
public static Map<String, String> getExtraDataMap(AccountAgeWitnessService accountAgeWitnessService,
ReferralIdService referralIdService,
PaymentAccount paymentAccount,
String currencyCode) {
String currencyCode,
Preferences preferences,
OfferPayload.Direction direction) {
Map<String, String> extraDataMap = new HashMap<>();
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
String myWitnessHashAsHex = accountAgeWitnessService.getMyWitnessHashAsHex(paymentAccount.getPaymentAccountPayload());
@ -351,6 +354,13 @@ public class OfferUtil {
extraDataMap.put(OfferPayload.CAPABILITIES, Capabilities.app.toStringList());
if (currencyCode.equals("XMR") && direction == OfferPayload.Direction.SELL) {
preferences.getAutoConfirmSettingsList().stream()
.filter(e -> e.getCurrencyCode().equals("XMR"))
.filter(AutoConfirmSettings::isEnabled)
.forEach(e -> extraDataMap.put(OfferPayload.XMR_AUTO_CONF, "1"));
}
return extraDataMap.isEmpty() ? null : extraDataMap;
}