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

[refactoring] Move methods out of TransactionHistoryBuilder #11471

Conversation

kiminuo
Copy link
Collaborator

@kiminuo kiminuo commented Sep 12, 2023

This PR is meant to simplify #11458 and ease reviews. It should be easy to review the PR commit by commit.

Credits to @turbolay.

… `SmartTransactionExtensions`.

Co-authored-by: Turbolay <clement.ogame@gmail.com>
Co-authored-by: Turbolay <clement.ogame@gmail.com>
@kiminuo kiminuo force-pushed the feature/2023-09-12-Initial-refactoring-of-TransactionHistoryBuilder branch from 3c7c949 to f1fd6c9 Compare September 12, 2023 10:18
@kiminuo kiminuo marked this pull request as ready for review September 12, 2023 10:20

public static class SmartTransactionExtensions
{
public static IEnumerable<Output> GetOutputs(this SmartTransaction smartTransaction, Network network)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't like the method name here. Imho it should be more descriptive because SmartTransaction has already many output types.

return GetDestinationAddresses(inputs, outputs);
}

private static IEnumerable<BitcoinAddress> GetDestinationAddresses(ICollection<IInput> inputs, ICollection<Output> outputs)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't like the method name here. Imho it should start with the Compute prefix and imho there should be a short documentation what it does.

adamPetho
adamPetho previously approved these changes Sep 12, 2023
Copy link
Collaborator

@adamPetho adamPetho left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -36,4 +36,46 @@ public static IEnumerable<IInput> GetInputs(this SmartTransaction transaction)

return known.Concat(unknown);
}

public static IEnumerable<BitcoinAddress> GetDestinationAddresses(this SmartTransaction transaction, Network network, out List<IInput> inputs, out List<Output> outputs)
Copy link
Collaborator

@turbolay turbolay Sep 12, 2023

Choose a reason for hiding this comment

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

Why did you prefer to explicitely pass the network instead of using Services.WalletManager.Network?

Copy link
Collaborator Author

@kiminuo kiminuo Sep 12, 2023

Choose a reason for hiding this comment

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

I would say it's personal preference because it allows easy unit-testing. Also note that this is in the WalletWasabi project and not in the Fluent project.

It can change later if deemed necessary/useful.

Copy link
Collaborator

@turbolay turbolay left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@molnard molnard left a comment

Choose a reason for hiding this comment

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

LGTM, overall


txRecordList.Add(new TransactionSummary(spenderTransaction, Money.Zero - coin.Amount, GetInputs(spenderTransaction), outputs, destinationAddresses));
var destinationAddresses = spenderTransaction.GetDestinationAddresses(wallet.Network, out _, out List<Output> outputs);
txRecordList.Add(new TransactionSummary(spenderTransaction, Money.Zero - coin.Amount, spenderTransaction.GetInputs(), outputs, destinationAddresses));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Input is there above but discarded. You could use them. Are those the same?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, fixed.

Copy link
Collaborator

@lontivero lontivero left a comment

Choose a reason for hiding this comment

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

LGTM

@lontivero lontivero merged commit 7529e33 into WalletWasabi:master Sep 13, 2023
7 checks passed
@kiminuo kiminuo deleted the feature/2023-09-12-Initial-refactoring-of-TransactionHistoryBuilder branch September 13, 2023 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants