Skip to content

Commit

Permalink
Account Signing: Add information popups for signing state (#3374)
Browse files Browse the repository at this point in the history
* Add account signing icons to signing state in account display

* Remove not implemented notification part

* Hide time since signing column when not needed

* Remove fiat rounding popup as feature was introduced a long time ago already

* Add information popups for new signed states (only shown once for user) and minor clean-ups

* Update core/src/main/resources/i18n/displayStrings.properties

Co-Authored-By: sqrrm <[email protected]>
  • Loading branch information
ripcurlx and sqrrm committed Oct 9, 2019
1 parent 9bfe135 commit b714c83
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 89 deletions.
80 changes: 69 additions & 11 deletions core/src/main/java/bisq/core/app/BisqSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@

package bisq.core.app;

import bisq.core.account.sign.SignedWitness;
import bisq.core.account.sign.SignedWitnessService;
import bisq.core.account.witness.AccountAgeWitness;
import bisq.core.account.witness.AccountAgeWitnessService;
import bisq.core.alert.Alert;
import bisq.core.alert.AlertManager;
Expand All @@ -43,6 +45,7 @@
import bisq.core.offer.OpenOfferManager;
import bisq.core.payment.PaymentAccount;
import bisq.core.payment.TradeLimits;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.provider.fee.FeeService;
import bisq.core.provider.price.PriceFeedService;
import bisq.core.support.dispute.arbitration.ArbitrationManager;
Expand All @@ -63,6 +66,7 @@
import bisq.network.crypto.EncryptionService;
import bisq.network.p2p.P2PService;
import bisq.network.p2p.peers.keepalive.messages.Ping;
import bisq.network.p2p.storage.payload.PersistableNetworkPayload;

import bisq.common.ClockWatcher;
import bisq.common.Timer;
Expand Down Expand Up @@ -175,7 +179,8 @@ public interface BisqSetupCompleteListener {
private Consumer<String> cryptoSetupFailedHandler, chainFileLockedExceptionHandler,
spvFileCorruptedHandler, lockedUpFundsHandler, daoErrorMessageHandler, daoWarnMessageHandler,
filterWarningHandler, displaySecurityRecommendationHandler, displayLocalhostHandler,
wrongOSArchitectureHandler;
wrongOSArchitectureHandler, displaySignedByArbitratorHandler,
displaySignedByPeerHandler, displayPeerLimitLiftedHandler, displayPeerSignerHandler;
@Setter
@Nullable
private Consumer<Boolean> displayTorNetworkSettingsHandler;
Expand Down Expand Up @@ -339,6 +344,7 @@ private void step5() {
// in MainViewModel
maybeShowSecurityRecommendation();
maybeShowLocalhostRunningInfo();
maybeShowAccountSigningStateInfo();
}


Expand Down Expand Up @@ -579,9 +585,7 @@ private void initWallet() {
if (allBasicServicesInitialized)
checkForLockedUpFunds();
},
() -> {
walletInitialized.set(true);
});
() -> walletInitialized.set(true));
}


Expand Down Expand Up @@ -703,9 +707,7 @@ private void initDomainServices() {
voteResultService.getVoteResultExceptions().addListener((ListChangeListener<VoteResultException>) c -> {
c.next();
if (c.wasAdded() && voteResultExceptionHandler != null) {
c.getAddedSubList().forEach(e -> {
voteResultExceptionHandler.accept(e);
});
c.getAddedSubList().forEach(e -> voteResultExceptionHandler.accept(e));
}
});

Expand All @@ -729,9 +731,65 @@ private void maybeShowSecurityRecommendation() {
}

private void maybeShowLocalhostRunningInfo() {
String key = "bitcoinLocalhostNode";
if (bisqEnvironment.isBitcoinLocalhostNodeRunning() && preferences.showAgain(key) &&
displayLocalhostHandler != null)
displayLocalhostHandler.accept(key);
maybeTriggerDisplayHandler("bitcoinLocalhostNode", displayLocalhostHandler, bisqEnvironment.isBitcoinLocalhostNodeRunning());
}

private void maybeShowAccountSigningStateInfo() {
String keySignedByArbitrator = "accountSignedByArbitrator";
String keySignedByPeer = "accountSignedByPeer";
String keyPeerLimitedLifted = "accountLimitLifted";
String keyPeerSigner = "accountPeerSigner";

// check signed witness on startup
checkSigningState(AccountAgeWitnessService.SignState.ARBITRATOR, keySignedByArbitrator, displaySignedByArbitratorHandler);
checkSigningState(AccountAgeWitnessService.SignState.PEER_INITIAL, keySignedByPeer, displaySignedByPeerHandler);
checkSigningState(AccountAgeWitnessService.SignState.PEER_LIMIT_LIFTED, keyPeerLimitedLifted, displayPeerLimitLiftedHandler);
checkSigningState(AccountAgeWitnessService.SignState.PEER_SIGNER, keyPeerSigner, displayPeerSignerHandler);

// check signed witness during runtime
p2PService.getP2PDataStorage().addAppendOnlyDataStoreListener(
payload -> {
maybeTriggerDisplayHandler(keySignedByArbitrator, displaySignedByArbitratorHandler,
isSignedWitnessOfMineWithState(payload, AccountAgeWitnessService.SignState.ARBITRATOR));
maybeTriggerDisplayHandler(keySignedByPeer, displaySignedByPeerHandler,
isSignedWitnessOfMineWithState(payload, AccountAgeWitnessService.SignState.PEER_INITIAL));
maybeTriggerDisplayHandler(keyPeerLimitedLifted, displayPeerLimitLiftedHandler,
isSignedWitnessOfMineWithState(payload, AccountAgeWitnessService.SignState.PEER_LIMIT_LIFTED));
maybeTriggerDisplayHandler(keyPeerSigner, displayPeerSignerHandler,
isSignedWitnessOfMineWithState(payload, AccountAgeWitnessService.SignState.PEER_SIGNER));
});
}

private void checkSigningState(AccountAgeWitnessService.SignState state,
String key, Consumer<String> displayHandler) {
boolean signingStateFound = p2PService.getP2PDataStorage().getAppendOnlyDataStoreMap().values().stream()
.anyMatch(payload -> isSignedWitnessOfMineWithState(payload, state));

maybeTriggerDisplayHandler(key, displayHandler, signingStateFound);
}

private boolean isSignedWitnessOfMineWithState(PersistableNetworkPayload payload,
AccountAgeWitnessService.SignState state) {
if (payload instanceof SignedWitness && user.getPaymentAccounts() != null) {
// We know at this point that it is already added to the signed witness list
// Check if new signed witness is for one of my own accounts

return user.getPaymentAccounts().stream()
.filter(a -> PaymentMethod.hasChargebackRisk(a.getPaymentMethod(), a.getTradeCurrencies()))
.anyMatch(a -> {
AccountAgeWitness myWitness = accountAgeWitnessService.getMyWitness(a.getPaymentAccountPayload());
AccountAgeWitnessService.SignState signState = accountAgeWitnessService.getSignState(myWitness);

return (signState.equals(state));
});
}
return false;
}

private void maybeTriggerDisplayHandler(String key, Consumer<String> displayHandler, boolean signingStateFound) {
if (signingStateFound && preferences.showAgain(key) &&
displayHandler != null) {
displayHandler.accept(key);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@ public static boolean hasChargebackRisk(PaymentMethod paymentMethod, List<TradeC
.anyMatch(tradeCurrency -> hasChargebackRisk(paymentMethod, tradeCurrency.getCode()));
}

public static boolean hasChargebackRisk(PaymentMethod paymentMethod) {
return hasChargebackRisk(paymentMethod, CurrencyUtil.getMatureMarketCurrencies());
}

public static boolean hasChargebackRisk(PaymentMethod paymentMethod, String currencyCode) {
if (paymentMethod == null)
return false;
Expand Down
19 changes: 12 additions & 7 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,9 @@ offerbook.warning.sellOfferAndAnyTakerPaymentAccountForOfferMature=This offer ca

offerbook.warning.counterpartyTradeRestrictions=This offer cannot be taken due to counterparty trade restrictions

offerbook.warning.newVersionAnnouncement=We needed to deploy this restriction as a short-term measure for enhanced security.\n\n\
The next software release will provide more robust protection tools so that offers with this risk profile can be traded again.
offerbook.warning.newVersionAnnouncement=With this version of the software trading peers can verify and sign each other to create a network of trusted accounts.\n\n\
By trading with a peer that has already been verified your account will be signed after a successful trade as well and the limits will be lifted after a certain time frame based on the verification method.\n\n\
For more information on account signing, please visit our documentation section on docs.bisq.network/account-signing.

popup.warning.tradeLimitDueAccountAgeRestriction.seller=The allowed trade amount is limited to 0.01 BTC because of security restrictions based on the following criteria:\n\
- The buyers account was created after March 1st 2019\n\
Expand Down Expand Up @@ -724,7 +725,7 @@ portfolio.pending.step3_seller.onPaymentReceived.part1=Have you received the {0}
# suppress inspection "TrailingSpacesInProperty"
portfolio.pending.step3_seller.onPaymentReceived.fiat=The trade ID (\"reason for payment\" text) of the transaction is: \"{0}\"\n\n
# suppress inspection "TrailingSpacesInProperty"
portfolio.pending.step3_seller.onPaymentReceived.name=Please also verify that the sender's name in your bank statement matches that one from the trade contract:\nSender's name: {0}\n\nIf the name is not the same as the one displayed here, please don't confirm but open a dispute by entering \"alt + o\" or \"option + o\".\n\n
portfolio.pending.step3_seller.onPaymentReceived.name=Please also verify that the sender''s name in your bank statement matches that one from the trade contract:\nSender''s name: {0}\n\nIf the name is not the same as the one displayed here, please don''t confirm but open a dispute by entering \"alt + o\" or \"option + o\".\n\n
portfolio.pending.step3_seller.onPaymentReceived.note=Please note, that as soon you have confirmed the receipt, the locked trade amount will be released to the BTC buyer and the security deposit will be refunded.\n\n
portfolio.pending.step3_seller.onPaymentReceived.confirm.headline=Confirm that you have received the payment
portfolio.pending.step3_seller.onPaymentReceived.confirm.yes=Yes, I have received the payment
Expand Down Expand Up @@ -1163,7 +1164,7 @@ account.arbitratorRegistration.pubKey=Public key
account.arbitratorRegistration.register=Register
account.arbitratorRegistration.registration={0} registration
account.arbitratorRegistration.revoke=Revoke
account.arbitratorRegistration.info.msg=Please note that you need to stay available for 15 days after revoking as there might be trades which are using you as {0}}. The max. allowed trade period is 8 days and the dispute process might take up to 7 days.
account.arbitratorRegistration.info.msg=Please note that you need to stay available for 15 days after revoking as there might be trades which are using you as {0}. The max. allowed trade period is 8 days and the dispute process might take up to 7 days.
account.arbitratorRegistration.warn.min1Language=You need to set at least 1 language.\nWe added the default language for you.
account.arbitratorRegistration.removedSuccess=You have successfully removed your registration from the Bisq network.
account.arbitratorRegistration.removedFailed=Could not remove registration.{0}
Expand Down Expand Up @@ -2511,9 +2512,6 @@ popup.shutDownInProgress.msg=Shutting down application can take a few seconds.\n

popup.attention.forTradeWithId=Attention required for trade with ID {0}

popup.roundedFiatValues.headline=New privacy feature: Rounded fiat values
popup.roundedFiatValues.msg=To increase privacy of your trade the {0} amount was rounded.\n\nDepending on the client version you''ll pay or receive either values with decimals or rounded ones.\n\nBoth values do comply from now on with the trade protocol.\n\nAlso be aware that BTC values are changed automatically to match the rounded fiat amount as close as possible.

popup.info.multiplePaymentAccounts.headline=Multiple payment accounts available
popup.info.multiplePaymentAccounts.msg=You have multiple payment accounts available for this offer. Please make sure you've picked the right one.

Expand Down Expand Up @@ -2541,6 +2539,13 @@ popup.accountSigning.signAccounts.ECKey.error=Bad arbitrator ECKey

popup.accountSigning.success.headline=Congratulations
popup.accountSigning.success.description=All {0} payment accounts were successfully signed!
popup.accountSigning.generalInformation=You'll find the signing state of all your accounts in the account section.\n\n\
For further information please visit docs.bisq.network/account-signing.html.
popup.accountSigning.signedByArbitrator=One of your payment accounts has been verified and signed by an arbitrator. Trading with this account will automatically sign your trading peer''s account after a successful trade.\n\n{0}
popup.accountSigning.signedByPeer=One of your payment accounts has been verified and signed by a trading peer. Your initial limit will be lifted within 30 days from now. \
After 60 days you are able to sign other accounts as well.\n\n{0}
popup.accountSigning.peerLimitLifted=The initial limit for one of your accounts has been lifted.\n\n{0}
popup.accountSigning.peerSigner=One of your accounts is mature enough to sign other payment accounts as well.\n\n{0}

####################################################################
# Notifications
Expand Down
Loading

0 comments on commit b714c83

Please sign in to comment.