Open jjeffryes opened 6 years ago
I've reviewed the code and it seems like the only way it could have calculated the wrong amount is if the exchange rates returned incorrect from the API. @pinheadmz if you try the same action again, does it give the same error?
Yes, and the dispute is still open if you want me to try something. Been able to settle other disputes in the meantime. You have my entire ob.log
for that other issue already we're discussing on slack.
Just got this again on another dispute. This time its a much bigger purchase amount. I am deactivating moderation on my node.
Running a custom build now to try and get better error details:
diff --git a/core/moderation.go b/core/moderation.go
index 43747350..0890cf4b 100644
--- a/core/moderation.go
+++ b/core/moderation.go
@@ -17,6 +17,7 @@ import (
"github.com/OpenBazaar/openbazaar-go/ipfs"
"github.com/OpenBazaar/openbazaar-go/pb"
+ "fmt"
)
// ModeratorPointerID moderator ipfs multihash
@@ -159,7 +160,7 @@ func (n *OpenBazaarNode) GetModeratorFee(transactionTotal uint64) (uint64, error
}
percentage := uint64(float64(transactionTotal) * (float64(profile.ModeratorInfo.Fee.Percentage) / 100))
if fixed+percentage >= transactionTotal {
- return 0, errors.New("Fixed moderator fee exceeds transaction amount")
+ return 0, errors.New(fmt.Sprintf("FIXED 3: Fixed moderator fee exceeds transaction amount. txtotal: %v fixed: %v percentage: %v", transactionTotal, fixed, profile.ModeratorInfo.Fee.Percentage))
}
return fixed + percentage, nil
default:
When I try to resolve this dispute again I see:
There was an error resolving the order. FIXED 3: Fixed moderator fee exceeds transaction amount. txtotal: 0 fixed: 15525 percentage: 5
Transaction Total == 0?!
Anything else you guys want me to try?
Tracking this problem back a step to CloseDispute()
:
diff --git a/core/disputes.go b/core/disputes.go
index 5f978cfb..7e568cd9 100644
--- a/core/disputes.go
+++ b/core/disputes.go
@@ -25,6 +25,7 @@ import (
"github.com/OpenBazaar/openbazaar-go/pb"
"github.com/OpenBazaar/openbazaar-go/repo"
"github.com/OpenBazaar/openbazaar-go/repo/db"
+ "fmt"
)
// ConfirmationsPerHour is temporary until the Wallet interface has Attributes() to provide this value
@@ -548,8 +549,11 @@ func (n *OpenBazaarNode) CloseDispute(orderID string, buyerPercentage, vendorPer
// Calculate total out value
var totalOut uint64
+ log.Debug(" -- here -- ")
+ log.Debug(outpoints)
for _, o := range outpoints {
totalOut += o.Value
+ log.Debug(fmt.Sprintf("outpoint: %v value: %v", o, o.Value))
}
// Create outputs using full value. We will subtract the fee off each output later.
log output:
17:34:40.896 [DEBUG] [core/CloseDispute] -- here --
17:34:40.896 [DEBUG] [core/CloseDispute] []
Something is causing this transaction to somehow not have any outputs...?
OK I achieved some success with this, using a dangerous and totally reckless work-around :-)
Using a SQLite browser on my local machine, I noticed that vendorOutpoints and buyerOutppints are missing on every dispute I've ever had since March 2018. Most of these disputes were awarded to the party that opened them, so I didn't encounter any issues. The problematic disputes occur when the party that opens the dispute loses. For some reason, the outpoints for the counterparty are not inserted in the database.
Using the SQL browser, I was able to copy all the buyerOutpoints to vendorOutpoints and vice versa, restart OB and successfully close all the problematic disputes!
Now my extra log outputs look correct:
18:59:58.832 [DEBUG] [core/CloseDispute] -- here --
18:59:58.832 [DEBUG] [core/CloseDispute] [hash:"19c3eab0955c323517ab0c95727e1341dde63e856c5dd9ef97b167f083bef223" index:1 value:883969 ]
18:59:58.832 [DEBUG] [core/CloseDispute] outpoint: hash:"19c3eab0955c323517ab0c95727e1341dde63e856c5dd9ef97b167f083bef223" index:1 value:883969 value: 883969
Thanks @pinheadmz for helping pin down the fix for this bug. Preparing a formal fix.
Fix is merged. Great work team! http://i.imgur.com/a9TX8.gif
Although it's definitely worth partying over -- that fix only solves one of the problems I was having, the other being more explicitly described in the screenshot above and, if I may quote @cpacia from a slack chat:
The ones where it says NULL is OK since the other party didn't send you their copy of the contract. The one's where it's just blank are not. Likely their node wasn't synced when they sent their copy of the contract. I can make it use the other copy of the outpoints if the field is empty. That should take care of most of it. But we should probably add functionality for the party to send updates to the moderator as it detects further payments.
Okay, let's track the other fix into master and verify resolution before closing. 😞 @cpacia opened https://github.com/OpenBazaar/openbazaar-go/issues/1117
@pinheadmz commented on Wed Aug 01 2018
OSX client 2.2.3, Raspbian server 0.12.0
Order total: $10.22 (₿0.00134698) My mod policy: $1.00 (+5%) Dispute resolution was 100% to vendor, so mod fee should be:
$1.00 + (5% of $10.22 = $0.51) = $1.51
leaving for the vendor,
$8.71
https://btc.fees.openbazaar.org/ responds
{"priority":7,"normal":1,"economic":1}
Here's the "Payment details"
@pinheadmz commented on Fri Aug 03 2018
@jjeffryes commented on Tue Aug 14 2018
@cpacia @placer14 This is the server returning a 500, could the message be incorrect about the reason the call is failing?