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