Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: lukew on January 21, 2017, 03:58:48 PM



Title: Ideas needed for preventing dust
Post by: lukew on January 21, 2017, 03:58:48 PM
I'm working on a project and part of it is is a database based wallet. I'm trying to get a quick and dirty transaction building routine working so I can start making transactions, and filling the database with actual keys and transaction data for testing. This is all on TestNet.

One thing I want to quickly hack together is a fee calculator. I was considering just building the transaction with no fee, grabbing the size and then re-building it with the appropriate fee. It will work for initial testing and filling the database. Is this the best way to get it done quickly, or is there a better way?

I'm also trying to prevent filling change addresses with dust. I will be sorting un-spent outputs by size (after pulling from database where value is greater than payment amount). I would guess that the easiest way is just to use the highest value un-spent output there is, but that would mean a small transaction would potentially leave a larger one later on needing to use several inputs and potentially increase fees.

I am using NBitcoin and programming in C#.

Thanks for any advice :)


Title: Re: Ideas needed for preventing dust
Post by: Coding Enthusiast on January 21, 2017, 04:38:47 PM
What wallets do for their coin selection (selecting which UTXO to spend) is that they either go for privacy or priority (I think the the priority approach is no longer applicable ref (https://en.bitcoin.it/wiki/Transaction_fees#Historic_rules_for_free_transactions)).
And for privacy they choose outputs in a way to protect the privacy, so if you have multiple address only spend outputs that are connected to addresses in one transaction.
* There may be other things wallets do for that, which I don't know or am forgetting now.

I am not sure what they do for dust but I believe if after making the transaction if there is any leftover (what you usually send to change address) and that leftover is smaller than dust amount, it is considered as fee (they don't send it to a change address).


Title: Re: Ideas needed for preventing dust
Post by: lukew on January 22, 2017, 01:38:40 AM
I guess I was focussed on preventing dust transactions and never thought of just letting it go as part of the fee. I'll probably just do that :)

I actually had this mostly working yesterday, and after some unknown fuckup with Windows, every open file in Visual Studio was replaced with a lot of 0x00. Firefox had a shit too and lost all recent history. No recent backup and lost a few days work :(