pybitcash / bitcash

BitCash: Python Bitcoin Cash Library (fork of ofek's Bit)
https://bitcash.dev
MIT License
97 stars 39 forks source link

Bitcash not creating valid transactions despite returning a TxID #134

Closed revoxhere closed 8 months ago

revoxhere commented 8 months ago

Hello there. I'm having a problem with BitCash not sending funds properly, minimal example:

Python 3.9.17 (main, Nov 28 2023, 21:19:59)
[GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from bitcash import Key
>>> wallet = Key('XXX')
>>> wallet.get_balance()
'4018567'
>>> wallet.send([("xxx", 0.001, 'bch')])
'b08e56674d712249763ab38f4c6f02786eba6df85817e024de42a6ea536ac7de'
>>> wallet.get_balance()
'4018567'

The generated TxID, when explored in a blockchain explorer is not valid and the balance does not change, yet the transaction does not fail.

This is happening both on version 1.0.0 and 1.0.1 (used in the example). It happens with any amount and receiving wallet.

I really like this library and been using it for the past two years or so, but it seems to not work for the past few days or weeks. Maybe someone can help me troubleshoot this?

Thanks in advance.

yashasvi-ranawat commented 8 months ago

I'm unable to reproduce the bug. I tried to send a tx, and it was sent (and seen in the blockexplorer). Perhaps you can give further details here or in https://t.me/pybitcash

merc1er commented 8 months ago

I am also able to send transactions without issues on my end: Screenshot 2023-12-28 at 12 53 27

The transaction is found on Blockchair: https://blockchair.com/bitcoin-cash/transaction/3cb93f1ee2424d9cf409363cfa0732861d83eac44c57765f4a64a648324ce12b

Do you use a custom Node endpoint @revoxhere?

revoxhere commented 8 months ago

No, I don't think I'm using any custom endpoints. Haven't changed anything in the source. I'm not sure why, but changing to a different private key fixed this issue and valid transactions can be created with exactly the same prompt.

Is there any way I can prevent this from happening again? I thought I could somehow check if the generated TXID is valid... But since the problem is solved I'll close this issue.

Thanks for your input and this awesome library!

merc1er commented 8 months ago

Hmm that's strange.

Are you able to share a private key that results in this failure?

Make sure there is no money in it and that you will never use it again.

If you are unable to share that, maybe you can share how it was generated so I can try to reproduce?

I understand all this can be sensitive information so please only share if it does not compromise your security.