bit icon indicating copy to clipboard operation
bit copied to clipboard

Clearing a wallet

Open mc-17 opened this issue 5 years ago • 3 comments

Thanks for the library!

One thing I'm currently trying to work out is how to effectively clear a wallet - currently I use PrivateKey.send(outputs), but this can produce a situation where fee + output is more than the balance.

Is there a method I've missed that says "send all the balance of this PK"?

mc-17 avatar Jul 06 '20 14:07 mc-17

What you're talking about is often known as sweeping. We should probably add that keyword in the documentation.

https://ofek.dev/bit/guide/transactions.html#transfer-funds

I think that should work for you.

ghost avatar Jul 07 '20 15:07 ghost

What you're talking about is often known as sweeping. We should probably add that keyword in the documentation.

https://ofek.dev/bit/guide/transactions.html#transfer-funds

I think that should work for you.

Thanks! That does work for me.

From running this code it appears we get a raw string of the transaction - is there any way of confirming how much is actually going to be sent prior to sending the tx, or do we just have to send it and inspect the tx afterwards?

mc-17 avatar Jul 08 '20 18:07 mc-17

What you're talking about is often known as sweeping. We should probably add that keyword in the documentation. https://ofek.dev/bit/guide/transactions.html#transfer-funds I think that should work for you.

Thanks! That does work for me.

From running this code it appears we get a raw string of the transaction - is there any way of confirming how much is actually going to be sent prior to sending the tx, or do we just have to send it and inspect the tx afterwards?

You can try to estimate the size of the transaction and query the fee.

Th0rgal avatar Aug 07 '20 08:08 Th0rgal