ofek / bit

Bitcoin made easy.
https://ofek.dev/bit/
MIT License
1.24k stars 212 forks source link

Building blocks for Replace By Fee #22

Open ghost opened 6 years ago

ghost commented 6 years ago

I have a transaction stuck in pergatory that'll never confirm, yet never seems to get out of mempool.

I'd like to sweep that wallet, but (most) of the APIs don't return those unspents. I've been thinking about how to do a Replace By Fee transaction. I figure you just take the inputs of the transaction you want, then adjust the outputs/fee accordingly and broadcast that transaction.

So to do this I think we need:

get_transaction() to get the hex of a transaction broadcast. We then need get_transaction_as_unspent() which would take the hex of a transaction and return it as an unspent. I guess a second argument would be the key, unless we just provide that in the key class that this is off of anyways.

Then finally, get_unspents_from_transaction() which would iterate through the inputs of a transaction, and build an unspent list that could then be used by send().

Does that seem about right? Not sure I want to add this in any time soon but I am curious if this seems about like the right approach.

So it'd look kind of like:

key.send(unspents=key.get_unspents_from_transaction('rbftransactionid')...)

Thanks!

ofek commented 6 years ago

Thank you!

This is in https://ofek.github.io/bit/community/contributing.html#todo

It requires implementing new network API calls for each backend.