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

[WIP] Add protection tools #2787

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
c2757db
Merge branch 'fix-trade-peers-account-age' into delay-payout-if-fait-…
ManfredKarrer Apr 21, 2019
29ff2fc
Fix wrong display of ages with 1 at the end (e.g. 31 days)
ManfredKarrer Apr 22, 2019
a314416
Add min required buyers account age
ManfredKarrer Apr 22, 2019
72be262
Add warning popup to offer book
ManfredKarrer Apr 22, 2019
e74aad7
Remove rounded fiat amounts popup
ManfredKarrer Apr 22, 2019
4cae398
Add popup to offer maker
ManfredKarrer Apr 22, 2019
79ed168
Refactor
ManfredKarrer Apr 22, 2019
a1e58a4
Improve text
ManfredKarrer Apr 22, 2019
b46e98f
Handle trade period (WIP)
ManfredKarrer Apr 22, 2019
9e6989a
Add more keys
ManfredKarrer Apr 23, 2019
8eab3f3
Refactor: Move accountAgeWitness classes to new package
ManfredKarrer Apr 23, 2019
ca373ff
Refactor: Cleanup, no functionality change
ManfredKarrer Apr 23, 2019
b20a60e
Add SignedWitness domain (WIP)
ManfredKarrer Apr 23, 2019
0968861
Merge branch 'master' into delay-payout-if-fait-buyer-has-new-account
ManfredKarrer Apr 27, 2019
99c271a
Update strings
ManfredKarrer Apr 27, 2019
27d7656
Merge branch 'master' into sign-account-usage
ManfredKarrer Apr 27, 2019
ce99f56
Fix wrong imports
ManfredKarrer Apr 27, 2019
a28c728
Refactoring: Move classed to new package
ManfredKarrer Apr 27, 2019
e6d4709
Add Account score domain (WIP)
ManfredKarrer Apr 27, 2019
9c02ef8
Refactor: Move methods to domain (WIP)
ManfredKarrer Apr 27, 2019
ca6843c
Move account age related code to AccountCreationAgeService
ManfredKarrer Apr 28, 2019
eb1899f
Fix delay function, refactorings
ManfredKarrer Apr 28, 2019
765c708
Rename method
ManfredKarrer Apr 28, 2019
8d6267d
Add methods for getting the AccountScoreCategory
ManfredKarrer Apr 28, 2019
9a54dc3
Merge branch 'sign-account-usage' into add-protection-tools
ManfredKarrer Apr 28, 2019
cbdb472
Add arguments
ManfredKarrer Apr 28, 2019
f172fa6
Apply organize imports
ManfredKarrer Apr 28, 2019
e2b322f
Rename package
ManfredKarrer Apr 28, 2019
2c7b613
Handle AccountScoreCategory methods depending on signed witness state
ManfredKarrer Apr 28, 2019
60fcde6
Add verify check
ManfredKarrer Apr 28, 2019
26fb30c
Apply new delay function, add ScoreInfo class and methods
ManfredKarrer Apr 29, 2019
f9a756b
Add UI for score info
ManfredKarrer Apr 29, 2019
e6f7345
Fix deposit function
ManfredKarrer Apr 29, 2019
43b6238
Adjust create offer popup with new scoreInfo data
ManfredKarrer Apr 29, 2019
3fd133f
Add popup for taker
ManfredKarrer Apr 29, 2019
12a3d89
Change buyer sec. deposit
ManfredKarrer Apr 30, 2019
248df21
Change PERM_DELAY to 15 days, adjust tests
ManfredKarrer Apr 30, 2019
a2454ac
Add requireAuthorizedTaker to offer and preferences
ManfredKarrer Apr 30, 2019
8f519f3
Add check and popup for offers requiring authorized takers
ManfredKarrer Apr 30, 2019
c81142c
Adjust column width
ManfredKarrer Apr 30, 2019
74344a8
Show restrictions based on payment method
ManfredKarrer Apr 30, 2019
961870a
Improve restrictions settings in create offer
ripcurlx Apr 30, 2019
649c28a
Merge pull request #8 from ripcurlx/create-offer-improvements
ManfredKarrer Apr 30, 2019
a989438
Add comment
ManfredKarrer Apr 30, 2019
dbc1594
Add trade amount to SignedWitness
ManfredKarrer Apr 30, 2019
61d4d26
Rename put method to putIfAbsent to reflect behaviour better
ManfredKarrer Apr 30, 2019
e52707f
Rename put method to putIfAbsent to reflect behaviour better
ManfredKarrer Apr 30, 2019
c960520
Add more comments
ManfredKarrer Apr 30, 2019
a2d2fea
Add missing parameter
ripcurlx May 1, 2019
4ac64a1
Change icons
ripcurlx May 1, 2019
dedfd2e
Extend trade protocol to support payout delay
ManfredKarrer May 1, 2019
6cbc311
Add missing class
ManfredKarrer May 1, 2019
b176bd6
Fix fiatReceivedDate handling
ManfredKarrer May 2, 2019
997c032
Rename PeerInfoWithTagEditor to PeerInfoPopup
ManfredKarrer May 2, 2019
41b3f04
Handle delayed payout in trade protocol (WIP)
ManfredKarrer May 2, 2019
4494d07
Add verify task, improve UI
ManfredKarrer May 2, 2019
3c24644
Handle payout delay in trade process (WIP)
ManfredKarrer Jun 13, 2019
969c448
Merge pull request #9 from ripcurlx/change-icons
ManfredKarrer May 1, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ public boolean ignoreRestrictions(Coin tradeAmount) {
}

public boolean ignoreRestrictions(Offer offer) {
return ignoreRestrictions(offer.getPaymentMethod()) || ignoreRestrictions(offer.getAmount());
return ignoreRestrictionsByPaymentMethod(offer.getPaymentMethod()) || ignoreRestrictions(offer.getAmount());
}

public boolean ignoreRestrictions(PaymentMethod paymentMethod) {
public boolean ignoreRestrictionsByPaymentMethod(PaymentMethod paymentMethod) {
switch (paymentMethod.getId()) {
case PaymentMethod.BLOCK_CHAINS_ID:
case PaymentMethod.BLOCK_CHAINS_INSTANT_ID:
Expand Down Expand Up @@ -142,7 +142,7 @@ public boolean offerRequirePayoutDelay(Offer offer) {

public boolean tradeRequirePayoutDelay(Trade trade) {
//TODO add signature domain
return accountCreationAgeService.tradeRequirePayoutDelay(trade);
return !ignoreRestrictions(trade.getOffer()) && accountCreationAgeService.tradeRequirePayoutDelay(trade);
}


Expand Down Expand Up @@ -210,13 +210,15 @@ public Optional<ScoreInfo> getScoreInfoForMaker(Offer offer) {
if (CurrencyUtil.isCryptoCurrency(offer.getCurrencyCode())) {
return Optional.empty();
}
if (ignoreRestrictionsByPaymentMethod(offer.getPaymentMethod())) {
return Optional.empty();
}

Optional<AccountScoreCategory> accountScoreCategory = getAccountScoreCategoryForMaker(offer);
checkArgument(accountScoreCategory.isPresent(), "accountScoreCategory must be present");
long accountAge = accountAgeWitnessService.getMakersAccountAge(offer);

Optional<Long> signedTradeAge = Optional.empty();
;
Optional<String> accountAgeWitnessHash = offer.getAccountAgeWitnessHashAsHex();
Optional<AccountAgeWitness> witnessByHashAsHex = accountAgeWitnessHash.isPresent() ?
accountAgeWitnessService.getWitnessByHashAsHex(accountAgeWitnessHash.get()) :
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/bisq/core/trade/SellerTrade.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public abstract class SellerTrade extends Trade {
super(offer, txFee, takeOfferFee, isCurrencyForTakerFeeBtc, arbitratorNodeAddress, storage, btcWalletService, accountScoreService);
}

public void onSendFiatPaymentReceivedMessage(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
public void sendFiatPaymentReceivedMessage(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
setFiatReceivedDate(new Date().getTime());
checkArgument(tradeProtocol instanceof SellerProtocol, "tradeProtocol NOT instanceof SellerProtocol");
((SellerProtocol) tradeProtocol).onSendFiatPaymentReceivedMessage(resultHandler, errorMessageHandler);
((SellerProtocol) tradeProtocol).sendFiatPaymentReceivedMessage(resultHandler, errorMessageHandler);
}

public void onFiatPaymentReceived(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/bisq/core/trade/TradeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,8 @@ private void updateTradePeriodState() {
if (now.after(releaseBtcEndDate)) {
// We are over the time
trade.setTradePeriodState(Trade.TradePeriodState.TRADE_PERIOD_OVER);
} else if ((trade instanceof BuyerTrade && trade.getState() == Trade.State.BUYER_RECEIVED_SELLERS_FIAT_PAYMENT_RECEIPT_CONFIRMATION) ||
} else if (!accountScoreService.ignoreRestrictions(trade.getOffer()) &&
(trade instanceof BuyerTrade && trade.getState() == Trade.State.BUYER_RECEIVED_SELLERS_FIAT_PAYMENT_RECEIPT_CONFIRMATION) ||
(trade instanceof SellerTrade && trade.getState() == Trade.State.SELLER_CONFIRMED_IN_UI_FIAT_PAYMENT_RECEIPT)) {
// Seller has confirmed receipt but we are in delay phase or release phase
if (now.after(payoutDelayEndDate)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private void handle(CounterCurrencyTransferStartedMessage tradeMessage, NodeAddr
// payout tx yet but only notify the peer about the receipt as well as sign their account witness in case we are
// authorized to sign.
@Override
public void onSendFiatPaymentReceivedMessage(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
public void sendFiatPaymentReceivedMessage(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
sellerAsMakerTrade.setState(Trade.State.SELLER_CONFIRMED_IN_UI_FIAT_PAYMENT_RECEIPT);
TradeTaskRunner taskRunner = new TradeTaskRunner(sellerAsMakerTrade,
() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private void handle(CounterCurrencyTransferStartedMessage tradeMessage, NodeAddr
// payout tx yet but only notify the peer about the receipt as well as sign their account witness in case we are
// authorized to sign.
@Override
public void onSendFiatPaymentReceivedMessage(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
public void sendFiatPaymentReceivedMessage(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler) {
sellerAsTakerTrade.setState(Trade.State.SELLER_CONFIRMED_IN_UI_FIAT_PAYMENT_RECEIPT);
TradeTaskRunner taskRunner = new TradeTaskRunner(sellerAsTakerTrade,
() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import bisq.common.handlers.ResultHandler;

public interface SellerProtocol {
void onSendFiatPaymentReceivedMessage(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler);
void sendFiatPaymentReceivedMessage(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler);

void onFiatPaymentReceived(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler);
}
31 changes: 16 additions & 15 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,14 @@ offerbook.warning.tradeLimitNotMatching=Your payment account has been created {0
Your trade limit is: {1}\n\
The min. trade amount of the offer is: {2}.\n\n\
You cannot take that offer at the moment. Once your account is older than 2 months this restriction gets removed.
offerbook.warning.takerOffer.restrictedBuyerAccount=The peer''s account has not reached the required account level for unrestricted trading.\n\n\
offerbook.warning.takerOffer.restrictedBuyerAccount=The peer''s account has not reached account level ''Silver'' required for unrestricted trading.\n\n\
You can still take this offer, but the payout of the bitcoin will be delayed for {0}. Those extra restrictions have \
been introduced as protection against bank chargeback fraud.\n\n\
The peer''s account level is composed of following parameters:{1}{2}
offerbook.warning.takerOffer.restrictedBuyerAccount.confirm=Ok, I understand and still want to take this offer.
offerbook.warning.noAuthorizedAccount=You cannot take that offer because the offer requires a taker who is authorized for attesting trades.\n\n\
You have to trade first with a trader who can attest your trade and after 30 days you are authorized to attest others as well.
offerbook.warning.takerOffer.restrictedBuyerAccount.confirm=I understand and want to take this offer
offerbook.warning.noAuthorizedAccount=You cannot take that offer because the offer requires a taker with account level ''Silver''.\n\n\
You have to trade first with a trader who can attest your trade and after {0} your account is upgraded to account level ''Silver''. \
With account level ''Silver'' you will be authorized to attest other traders as well.

offerbook.info.sellAtMarketPrice=You will sell at market price (updated every minute).
offerbook.info.buyAtMarketPrice=You will buy at market price (updated every minute).
Expand Down Expand Up @@ -405,11 +406,11 @@ createOffer.warning.buyAboveMarketPrice=You will always pay {0}% more than the c
createOffer.tradeFee.descriptionBTCOnly=Trade fee
createOffer.tradeFee.descriptionBSQEnabled=Select trade fee currency
createOffer.tradeFee.fiatAndPercent=≈ {0} / {1} of trade amount
createOffer.takerRestriction.canSign=Require taker with account level silver or higher
createOffer.takerRestriction.canSign.seller=Require seller with account level silver or higher
createOffer.takerRestriction.canSign.buyer=Require buyer with account level silver or higher
createOffer.takerRestriction.canSign=Require taker with min. account level 'Silver'
createOffer.takerRestriction.canSign.seller=Require seller with min. account level 'Silver'
createOffer.takerRestriction.canSign.buyer=Require buyer with min. account level 'Silver'
createOffer.takerRestriction.canSign.info=Having your payment account attested by an authorized trader, \
will update your account level to silver after 30 days. With account level silver there is no payout delay in case you are the \
will update your account level to ''Silver'' after {0}. With account level ''Silver'' there is no payout delay in case you are the \
buyer and you are authorized to attest other traders.
createOffer.takerRestriction.delay=Tolerate payout delay
createOffer.takerRestriction=Restrictions for taker
Expand Down Expand Up @@ -644,7 +645,7 @@ portfolio.pending.step3_seller.westernUnion=The buyer has to send you the MTCN (
portfolio.pending.step3_seller.halCash=The buyer has to send you the HalCash code as text message. Beside that you will receive a message from HalCash with the required information to withdraw the EUR from a HalCash supporting ATM.\n\n\
After you have picked up the money from the ATM please confirm here the receipt of the payment!

portfolio.pending.step3_seller.bankCheck=\n\nPlease also verify that the sender's name in your bank statement matches that one from the trade contract:\nSender's name: {0}\n\n\
portfolio.pending.step3_seller.bankCheck=\n\nPlease also verify that the sender''s name in your bank statement matches that one from the trade contract:\nSender''s name: {0}\n\n\
If the name is not the same as the one displayed here, {1}
portfolio.pending.step3_seller.openDispute=please don't confirm but open a dispute by entering \"alt + o\" or \"option + o\".
portfolio.pending.step3_seller.confirmPaymentReceipt=Confirm payment receipt
Expand All @@ -667,7 +668,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.
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 All @@ -679,7 +680,7 @@ In case you get a chargeback request from your bank, open a dispute with Cmd + o


portfolio.pending.step3_seller.button.release=Release Bitcoin
portfolio.pending.step3_seller.status.confirmRelease=The buyer''s account is now {0} days old. Please confirm to release the bitcoin.
portfolio.pending.step3_seller.status.confirmRelease=Please confirm to release the bitcoin.

portfolio.pending.step5_buyer.groupTitle=Summary of completed trade
portfolio.pending.step5_buyer.tradeFee=Trade fee
Expand Down Expand Up @@ -2332,19 +2333,19 @@ popup.shutDownInProgress.headline=Shut down in progress
popup.shutDownInProgress.msg=Shutting down application can take a few seconds.\nPlease don't interrupt this process.

popup.attention.forTradeWithId=Attention required for trade with ID {0}
popup.restrictedBuyerAccount.createOffer.msg=Your account has not reached the required account level for unrestricted trading.\n\n\
popup.restrictedBuyerAccount.createOffer.msg=Your account has not reached account level ''Silver'' required for unrestricted trading.\n\n\
You can still create this offer, but the payout of the bitcoin will be delayed for {0}. Those extra restrictions have \
been introduced as protection against bank chargeback fraud.\n\n\
Your account level is composed of following parameters:{1}{2}\n\n\
Once you have traded with a trader who is authorized to attest your trade your restrictions will get removed after {3}. After that period you will be also authorized to attest your future trade peers.\n\n\
Once you have traded with a trader who is authorized to attest your trade your account level will be upgraded to ''Silver'' after {3}. After that period you will be also authorized to attest your trade peers.\n\n\
You can see the account level parameters of other peers and if they are authorized to attest other traders by clicking on the peer''s avatar icon.\n\n\
Offers with trade amounts of 0.01 BTC or below do not require a delayed payout.

popup.restrictedBuyerAccount.takeOffer.msg=Your account has not reached the required account level for unrestricted trading.\n\n\
popup.restrictedBuyerAccount.takeOffer.msg=Your account has not reached account level ''Silver'' required for unrestricted trading.\n\n\
You can still take this offer, but the payout of the bitcoin will be delayed for {0}. Those extra restrictions have \
been introduced as protection against bank chargeback fraud.\n\n\
Your account level is composed of following parameters:{1}{2}\n\n\
Once you have traded with a trader who is authorized to attest your trade your restrictions will get removed after {3}. After that period you will be also authorized to attest your future trade peers.\n\n\
Once you have traded with a trader who is authorized to attest your trade your account level will be upgraded to ''Silver'' after {3}. After that period you will be also authorized to attest your trade peers.\n\n\
You can see the account level parameters of other peers and if they are authorized to attest other traders by clicking on the peer''s avatar icon.\n\n\
Offers with trade amounts of 0.01 BTC or below do not require a delayed payout.

Expand Down
Loading