Bitcoin Forum
May 26, 2024, 01:38:03 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoinj Anyone know how to do coin control?  (Read 1455 times)
gweedo (OP)
Legendary
*
Offline Offline

Activity: 1498
Merit: 1000


View Profile
June 24, 2013, 02:23:29 AM
 #1

It should be a viable input using transaction object. Is their anyway I can do this?
jim618
Legendary
*
Offline Offline

Activity: 1708
Merit: 1066



View Profile WWW
June 24, 2013, 08:03:11 AM
 #2

Hi Gweedo,

You can have a custom CoinSelector in the Wallet to only select the transaction outputs you want.
The default one selects unspent confirmed outputs and unspent pending outputs that come from you.

For change you specify a change address - I think from memory there is a getChangeAddress in Wallet (or maybe it is on the SendRequest).

MultiBit HD   Lightweight desktop client.                    Bitcoin Solutions Ltd   Bespoke software. Consultancy.
jim618
Legendary
*
Offline Offline

Activity: 1708
Merit: 1066



View Profile WWW
June 24, 2013, 03:49:54 PM
 #3

In your wallet you should have all the Transactions with your spendable outputs.
You can use a CoinSelector to examine any of these to see if their unspent outputs are 'good' for the Transaction you are building. (With good meaning your algorithm)

If you use all of them you'll be able to spend the whole balance, less the fee, but if you start filtering them obviously you'll have a lower total. For instance if you want to 'freeze' an address like in Electrum those outputs would be unavailable for you.

I don't think many people have written custom CoinSelectors yet so you might have some experimentation to get things working..

MultiBit HD   Lightweight desktop client.                    Bitcoin Solutions Ltd   Bespoke software. Consultancy.
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!