Skip to content

Double spend test#7

Merged
martti007 merged 8 commits into
mainfrom
double-spend-test
Sep 10, 2025
Merged

Double spend test#7
martti007 merged 8 commits into
mainfrom
double-spend-test

Conversation

@martti007

Copy link
Copy Markdown
Contributor

No description provided.

@martti007 martti007 linked an issue Sep 10, 2025 that may be closed by this pull request
@MastaP
MastaP requested a review from Copilot September 10, 2025 19:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR simplifies predicate and token state handling by transitioning from specialized nametag token classes to generic token state implementations. The changes remove complexity around masked predicates and nametag-specific state while adding double spend prevention tests.

  • Removes NameTagTokenState class and its specialized constructor parameters
  • Replaces masked predicates with unmasked predicates throughout the codebase
  • Adds comprehensive double spend test to verify transaction validation

Reviewed Changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
TokenUtils.java Simplified nametag token minting by removing specialized parameters
FunctionalUnsignedPredicateDoubleSpendTest.java New test file verifying double spend prevention
CommonTestFlow.java Updated to use unmasked predicates and simplified token state creation
NametagMintTransactionData.java Removed token data and coin data parameters from constructor
Token.java Updated predicate verification to use transaction lists instead of single transactions
NameTagTokenState.java Removed entire specialized token state class
Multiple predicate files Updated verification methods to accept transaction lists

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

public UnmaskedPredicate deserialize(JsonParser p, DeserializationContext ctx)
throws IOException {
PredicateType type = null;
PredicateType type;

Copilot AI Sep 10, 2025

Copy link

Choose a reason for hiding this comment

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

The variable type is now uninitialized. This will cause a compilation error when used before assignment. Initialize to null or ensure it's assigned before use.

Suggested change
PredicateType type;
PredicateType type = null;

Copilot uses AI. Check for mistakes.
public MaskedPredicate deserialize(JsonParser p, DeserializationContext ctx)
throws IOException {
PredicateType type = null;
PredicateType type;

Copilot AI Sep 10, 2025

Copy link

Choose a reason for hiding this comment

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

The variable type is now uninitialized. This will cause a compilation error when used before assignment. Initialize to null or ensure it's assigned before use.

Suggested change
PredicateType type;

Copilot uses AI. Check for mistakes.
Comment on lines +44 to +54
return super.verify(transactions, token) && SigningService.verifyWithPublicKey(
new DataHasher(HashAlgorithm.SHA256)
.update(
transactions.size() > 1
? transactions.get(transactions.size() - 2).getData().getSalt()
: token.getGenesis().getData().getSalt()
)
.digest(),
this.getNonce(),
this.getPublicKey()
);

Copilot AI Sep 10, 2025

Copy link

Choose a reason for hiding this comment

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

When transactions.size() == 1, this accesses transactions.get(-1) which will throw an IndexOutOfBoundsException. The logic should check transactions.size() > 1 for the previous transaction access.

Copilot uses AI. Check for mistakes.
@martti007
martti007 merged commit a2ad60b into main Sep 10, 2025
2 checks passed
@martti007
martti007 deleted the double-spend-test branch September 10, 2025 20:05
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.

Move Nametag target address from transaction data field to genesis data field Add check for signed salt in UnmaskedPredicate

3 participants