Unable to transfer coins - decimal.InvalidOperation

Hi,
I have been unable to transfer coins from the official wallet to the exchange’s wallet. An error is returned during transfer:
decimal.InvalidOperation: [<class ‘decimal.ConversionSyntax’>]
I would be grateful for help in solving this problem.
Stan

Operating System: Ubuntu 22.04.3 LTS
Chia CLI: 2.1.1
Chia Wallet:
-Total Balance: 0.510124413426 xch (510124413426 mojo)
-Pending Total Balance: 0.010124413426 xch (10124413426 mojo)
-Spendable: 0.009963494012 xch (9963494012 mojo)
-Type: STANDARD_WALLET
-Wallet ID: 1

chia wallet send -i 1 -t xxxxxxxxxxxxxxxxxxxxxxxxxxxx -m 0 -a 0.5XCH

Traceback (most recent call last):
  File .../chia-blockchain/venv/bin/chia, line 8, in <module>
    sys.exit(main())
  File .../chia-blockchain/chia/cmds/chia.py, line 135, in main
    cli()  # pylint: disable=no-value-for-parameter
  File .../chia-blockchain/venv/lib/python3.10/site-packages/click/core.py, line 1130, in __call__
    return self.main(*args, **kwargs)
  File .../chia-blockchain/venv/lib/python3.10/site-packages/click/core.py, line 1055, in main
    rv = self.invoke(ctx)
  File .../chia-blockchain/venv/lib/python3.10/site-packages/click/core.py, line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File .../chia-blockchain/venv/lib/python3.10/site-packages/click/core.py, line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File .../chia-blockchain/venv/lib/python3.10/site-packages/click/core.py, line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File .../chia-blockchain/venv/lib/python3.10/site-packages/click/core.py, line 760, in invoke
    return __callback(*args, **kwargs)
  File .../chia-blockchain/chia/cmds/wallet.py, line 216, in send_cmd
    amount=Decimal(amount),
decimal.InvalidOperation: [<class 'decimal.ConversionSyntax'>]

decimal separator test:

 python -c 'print(1.1/2)'
0.55

Clearing my wallet of unconfirmed transactions helped.
Problem solved.

When you use CLI, do you need that extra “XCH” there? If you check CLI reference (Wallet CLI | Chia Documentation) and the very first example there, there is no XCH in the amount field (agreed that the “-m” field description is not clear about it there):

chia wallet send --fingerprint 3792481086 --address xch1jp5thqu3dhwkvvh5p77lvlackddrd9q2zpt58zs6yqr2c4yvregs69ayqr --memo "This is a test memo" --fee 0.000000000001 --amount 0.000000001`

Chia code is a bit sensitive (thus that trackball you have there). The last line you got was about a decimal conversion. Potentially, the code path that was executed expected just naked a number (no XCH at the end) and barfed seeing that XCH.

EDIT
Actually, take a look at the file where the crash happened - chia-blockchain/chia/cmds/wallet.py at main · Chia-Network/chia-blockchain · GitHub. The offending line is 216 (fee=Decimal(amount)). They are using “decimal” library there. However, “Decimal(string_value)” will barf when the string_value contains alpha chars (so you cannot have that XCH there, same goes for the fee).

So, that is just a bad code that doesn’t sanitize the input and just barfs producing that trackball.

You’re right - my mistake. CLI does not need redundant XCH parameters. However, without XCH, other errors occurred. Deleting unconfirmed transactions helped.
Many thanks for your knowledge - I will use it :slightly_smiling_face:
Happy New Year to everyone.

2 Likes