pybitcash / bitcash

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

send() no longer pulls in unspents #106

Closed ghost closed 2 years ago

ghost commented 2 years ago

It looks like send() no longer gets unspents. I can get_unspents() and I'll get them, and if I don't pass the unspents to send(), it'll say there are none. If I pass the unspents as an argument to send(), it works fine.

Is this intentional? Seems like different behavior than I remember.

Thank you!

merc1er commented 2 years ago

Yes, this is intentional. Send was never pulling the UTXOs. You need to do:

key.get_balance()  # or get_unspents()
key.send(...)
ghost commented 2 years ago

I was calling key.get_unspents() first, but I wasn't passing it as an argument to send().

merc1er commented 2 years ago

You don't need to pass it as an argument.

merc1er commented 2 years ago

I just tested it and can confirm you do not need to pass the unspents as an argument. Here is the code:

from bitcash import Key

print(key.to_wif())  # in case you close the Python shell
print(key.address)  # add some funds here

key.get_balance()
key.send([], leftover="bitcoincash:xxxxx")  # replace with your BCH address
ghost commented 2 years ago

Ah, I think you're right. I was doing something stupid and not reusing the same key object.

Thank you!