Bitcoin Forum
May 25, 2024, 10:09:34 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Ideas needed for preventing dust  (Read 523 times)
lukew (OP)
Jr. Member
*
Offline Offline

Activity: 81
Merit: 4


View Profile
January 21, 2017, 03:58:48 PM
 #1

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 Smiley

Spark payment and crypto systems.
Current status - Pre-alpha
Coding Enthusiast
Legendary
*
Offline Offline

Activity: 1039
Merit: 2783


Bitcoin and C♯ Enthusiast


View Profile WWW
January 21, 2017, 04:38:47 PM
 #2

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).
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).

Projects List+Suggestion box
Donate: 1Q9s or bc1q
|
|
|
FinderOuter(0.19.1)Ann-git
Denovo(0.7.0)Ann-git
Bitcoin.Net(0.26.0)Ann-git
|
|
|
BitcoinTransactionTool(0.11.0)Ann-git
WatchOnlyBitcoinWallet(3.2.1)Ann-git
SharpPusher(0.12.0)Ann-git
lukew (OP)
Jr. Member
*
Offline Offline

Activity: 81
Merit: 4


View Profile
January 22, 2017, 01:38:40 AM
 #3

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 Smiley

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 Sad

Spark payment and crypto systems.
Current status - Pre-alpha
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!