Skip to content

Reject zero/negative buy amount before sending transaction #2

Description

@smypmsa

Problem

pumpfun buy <mint> 0 sends a 0-lamport transaction to the network, wasting fees. Negative amounts are parsed as CLI flags (-1 → "No such option"), which is safe but confusing.

Fix

Add validation in src/pumpfun_cli/commands/trade.py buy(), after _validate_mint():

if sol_amount <= 0:
    error("Buy amount must be greater than zero.")

Files to change

  • src/pumpfun_cli/commands/trade.py — add guard in buy()
  • tests/test_commands/test_trade_cmd.py — add test for zero amount

How to test

uv run pytest tests/test_commands/test_trade_cmd.py -v

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions