Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Blockchain: a payment that was already mined can be submitted again, and it is accepted and mined a second time

Open
#16 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@tanujb03 is already working on this.

Since Oct 10, 2026.

  • #18 by @tanujb03 — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
java

Research direction

Start with the reproduction program in the issue, which uses Blockchain.addTransaction, minePending, balanceOf and isValid, plus Transaction.create in package minichain. Find where pending and mined transactions are stored and check whether the transaction id is ever compared against them. Done when the resubmitted transaction is refused, the balances stay at ravi=20 and asha=80, and isValid still returns true.

Written by the indexing model from the issue text.

Description

bug good first issue

What I did

  1. Fresh checkout of main, JDK 17, Maven.
  2. mvn compile
  3. Save this as Replay.java in the project folder:
package minichain;

import java.security.KeyPair;
import java.security.KeyPairGenerator;

public class Replay {
    public static void main(String[] args) throws Exception {
        KeyPairGenerator g = KeyPairGenerator.getInstance("RSA");
        g.initialize(1024);
        KeyPair asha = g.generateKeyPair();

        Blockchain chain = new Blockchain(2);
        chain.minePending("asha");
        chain.minePending("asha");   // asha has 100 coins

        // asha makes ONE payment of 20 coins to ravi and it is mined
        Transaction pay = Transaction.create("asha", "ravi", 20, asha.getPrivate(), asha.getPublic());
        chain.addTransaction(pay);
        chain.minePending("m");
        System.out.println("after the one payment: ravi=" + chain.balanceOf("ravi") + ", asha=" + chain.balanceOf("asha"));

        // anyone can copy that transaction out of the chain and submit it again, unchanged
        Transaction copy = chain.getChain().get(3).getTransactions().get(0);
        chain.addTransaction(copy);
        chain.addTransaction(copy);
        chain.minePending("m");
        System.out.println("after resubmitting it twice: ravi=" + chain.balanceOf("ravi") + ", asha=" + chain.balanceOf("asha") + ", chain valid=" + chain.isValid());
    }
}
  1. Compile and run it (use : instead of ; on Linux/macOS):
mkdir out && javac -cp target/classes -d out Replay.java && java -cp "target/classes;out" minichain.Replay

What I expected
Asha authorised one 20-coin payment and was charged 60.

The README says: "The system uses digital signatures to prevent forging transactions." (README.md, Note on Security)

A payment asha made once should only be able to move her coins once. Submitting the same, unchanged transaction again should be refused.

What happened instead

after the one payment: ravi=20, asha=80
after resubmitting it twice: ravi=60, asha=40, chain valid=true

The same transaction id is accepted again (even twice in a row while it is still waiting to be mined), mined, and the chain stays valid. Asha authorised 20 coins and ends up paying 60. Nobody needs her private key: every mined transaction, with its id, public key and signature, is stored in the chain and in chain.dat.

Environment
main @ 0e92205, JDK 17, Maven 3.9.16, Windows 11.

I'd like to work on the fix for this.

Dominant language
Java
Stars
0
Forks
3
Avg merge
16h 38m
Merged PRs (30d)
7

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from techcsispit/mini-chain

All issues in techcsispit/mini-chain

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.