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

Account Signing: Add information popups for signing state #3374

Merged
merged 6 commits into from
Oct 9, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
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()
ripcurlx marked this conversation as resolved.
Show resolved Hide resolved
.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);
}
}
}
16 changes: 12 additions & 4 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 @@ -2538,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. You''re initial limit will be lifted within 30 days from now. \
ripcurlx marked this conversation as resolved.
Show resolved Hide resolved
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