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

feat(coinjoin): fix private send and regular send #228

Merged
merged 12 commits into from
Aug 28, 2023

Conversation

HashEngineering
Copy link
Collaborator

@HashEngineering HashEngineering commented Aug 22, 2023

Issue being fixed or feature implemented

  • Fix CoinJoin Send - previously based on keys and denominated outputs
  • Fix regular send
  • Add some key, output info to the coinjoin wallet ext output

What was done?

How Has This Been Tested?

Breaking Changes

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

@HashEngineering HashEngineering self-assigned this Aug 22, 2023
@@ -58,10 +51,8 @@ public CoinSelection select(Coin target, List<TransactionOutput> candidates) {
protected boolean shouldSelect(Transaction tx) {
if (tx != null) {
for (TransactionOutput output : tx.getOutputs()) {
if (!output.isDenominated()) {
if (!output.isFullyMixed(wallet)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unmixed coins are not fully mixed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about partially mixed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This question will be answered later.

Comment on lines +329 to +330
if(!transactionBag.isFullyMixed(this))
return false;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CoinJoin coins are fully mixed.

Comment on lines +213 to +231
outputs.forEach(output -> {
TransactionOutPoint outPoint = new TransactionOutPoint(output.getParams(), output.getIndex(), output.getParentTransactionHash());
builder.append(" addr:")
.append(Address.fromPubKeyHash(output.getParams(), ScriptPattern.extractHashFromP2PKH(output.getScriptPubKey())))
.append(" outpoint:")
.append(outPoint.toStringShort())
.append(" ");
int rounds = ((WalletEx) wallet).getRealOutpointCoinJoinRounds(outPoint);
builder.append(CoinJoin.getRoundsString(rounds));
if (rounds >= 0) {
builder.append(" ").append(rounds).append(" rounds");
if (((WalletEx) wallet).isFullyMixed(outPoint)) {
builder.append(" (fully mixed)");
}
} else {
builder.append(" ").append(output.getValue().toFriendlyString());
}
builder.append("\n");
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change will update this section in a wallet dump to include each "output" and the rounds mixed

Outputs:
N/A outputs:11 total:0.00518944 DASH
  addr:ydEvmG7LMN8mne4LcGqraHV4v7KsDu5jZ7 outpoint:d7d6f127b9fb262baa49c397fa4f0e3afeba3534ce7e34c72d931bab7a039b58-0 collateral 0.0003 DASH
  addr:yQume8R9UgEn1ADfRqUmoqHeTRiDBXWyK4 outpoint:7fcea451f4b633197a0d5c69f651df23628b0c246c8b0dc6b51ab77ba857d6be-0 collateral 0.0004 DASH
  addr:yYXBfwGAFAj4R1Gpa7DUgrdHSd7vhpgyY4 outpoint:9745ffa61f8f8c8a8936bb5d59b8d29c4d8630e0d84ab01eb0cfbfc421ab953e-0 collateral 0.0004 DASH
  addr:yVCP88cjxHj8qko2fK1dFBdJQQ84Hkr4xV outpoint:713b579b0491feae451eae2a865dbbd7d3ffeef5155c1f579df5bb896498da26-0 collateral 0.0003 DASH
  addr:yUBvXJC9jXu8ac5Bm7xW4RSNQJi7sS9Z5Y outpoint:b7e3951e6567013a3b4b9342b766a028ab750de92935423d701cb14d25f26596-1 non-denominated 0.00079648 DASH
  addr:yUiFfkDWsAgunwcEYwnrwmmgr8rcP77hNY outpoint:65ffe13000550caa6bbe3e51589cb74611e132e20b72462dd50f2e51cfc4f185-1 non-denominated 0.00079648 DASH
  addr:yYrifCGm91rw1BtekrpH62kKck7j9ziCbA outpoint:d38def14895dc7c44f34692fca1f963e675f79f4842b75b68370c0f632a299c9-0 collateral 0.0003 DASH
  addr:yP6hq8bFkNozGZAffhhaHUCz2KXmpCPQeb outpoint:7fcea451f4b633197a0d5c69f651df23628b0c246c8b0dc6b51ab77ba857d6be-1 non-denominated 0.00079648 DASH
  addr:yMB1KM1XciP7RZ1tfsc2bEt6J8Sv65N5eo outpoint:1c9ede53abf7f28164f6cb567d9432295669e7e89c114af64eec8fd50f317894-1 collateral 0.0004 DASH
  addr:yNhrC82fPxV6zecXjtTR13aGPtiTSxKccE outpoint:65ffe13000550caa6bbe3e51589cb74611e132e20b72462dd50f2e51cfc4f185-0 collateral 0.0004 DASH
  addr:ybe6i8sg6oNX478mUxVk82VtuHcHspkdCE outpoint:cfcd443d79513b43faa0163d8698a4da2261241921009586a099d4b6e24429f2-0 collateral 0.0003 DASH
10.0001 outputs:0 total:0.00 DASH
1.00001 outputs:0 total:0.00 DASH
0.100001 outputs:0 total:0.00 DASH
0.0100001 outputs:2 total:0.0200002 DASH
  addr:ybMRc9tCRkCdxFk3Lcz3fGKkfEAUMEuALD outpoint:77b902728d9dc7d6ab9d75ea2a4fe0673f0f69ec478f948a6214136224a11a37-1 coinjoin 4 rounds
  addr:ydKqnTtLkq2xJijip997WS7WkBB22EDKse outpoint:07ee8cbce22bfeefaa92589ce082c28443310bd08596624a12e922f193e956d2-1 coinjoin 2 rounds
0.00100001 outputs:0 total:0.00 DASH

@HashEngineering HashEngineering marked this pull request as ready for review August 24, 2023 14:14
@codecov
Copy link

codecov bot commented Aug 24, 2023

Codecov Report

Patch coverage: 31.03% and project coverage change: -0.02% ⚠️

Comparison is base (c16ca38) 48.06% compared to head (98fe7cb) 48.04%.
Report is 1 commits behind head on feature-coinjoin.

❗ Current head 98fe7cb differs from pull request most recent head f037beb. Consider uploading reports for the commit f037beb to get more accurate results

Additional details and impacted files
@@                  Coverage Diff                   @@
##             feature-coinjoin     #228      +/-   ##
======================================================
- Coverage               48.06%   48.04%   -0.02%     
- Complexity               7195     7197       +2     
======================================================
  Files                     450      451       +1     
  Lines                   49611    49698      +87     
  Branches                 7068     7075       +7     
======================================================
+ Hits                    23844    23876      +32     
- Misses                  23036    23082      +46     
- Partials                 2731     2740       +9     
Files Changed Coverage Δ
.../main/java/org/bitcoinj/coinjoin/Denomination.java 0.00% <0.00%> (ø)
...bitcoinj/coinjoin/UnmixedZeroConfCoinSelector.java 0.00% <0.00%> (ø)
...coinj/coinjoin/progress/MixingProgressTracker.java 0.00% <0.00%> (ø)
.../org/bitcoinj/coinjoin/utils/CoinJoinReporter.java 0.00% <0.00%> (ø)
...in/java/org/bitcoinj/wallet/CoinJoinExtension.java 29.41% <0.00%> (-5.89%) ⬇️
core/src/main/java/org/bitcoinj/wallet/Wallet.java 71.96% <0.00%> (+0.13%) ⬆️
...re/src/main/java/org/bitcoinj/wallet/WalletEx.java 61.92% <ø> (+0.68%) ⬆️
...a/org/bitcoinj/coinjoin/CoinJoinClientOptions.java 88.88% <33.33%> (-11.12%) ⬇️
.../src/main/java/org/bitcoinj/coinjoin/CoinJoin.java 47.72% <47.05%> (-2.58%) ⬇️
...a/org/bitcoinj/coinjoin/CoinJoinClientSession.java 45.56% <64.70%> (+0.12%) ⬆️
... and 3 more

... and 17 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@Syn-McJ Syn-McJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@HashEngineering HashEngineering merged commit 24ac28c into feature-coinjoin Aug 28, 2023
4 checks passed
@HashEngineering HashEngineering deleted the feature-coinjoin-fix-send branch October 30, 2023 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants