Bitcoin Forum
May 22, 2024, 04:05:42 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Spending multiple transactions  (Read 149 times)
kobik (OP)
Jr. Member
*
Offline Offline

Activity: 39
Merit: 3


View Profile
February 21, 2018, 10:37:38 AM
 #1

Suppose I have 3 unspent outputs:

tx: 3 BTC
tx: 2 BTC
tx: 1 BTC

Now I want to spend 2.5 BTC.
Which is preferred as input(s) and why?

A single:
3 BTC (Leaving my an output change of 0.5)?

Or:
1 BTC + 2BTC? (Leaving my an output change of 0.5)

I hope the question is clear.
talkbitcoin
Legendary
*
Offline Offline

Activity: 1372
Merit: 1032


All I know is that I know nothing.


View Profile
February 21, 2018, 10:43:06 AM
 #2

it is impossible to say which one is "preferred" because it depends on a lot of things. your question may be clear but the answer is hard.

for example if each of those txs belong to a different key, spending the 3BTC means only using 1 key. but spending 1+2 means using 2 keys. this may have privacy concerns as it links 2 of your addresses together.

another thing that comes to mind is that spending 1 tx (3BTC) will give you a smaller transaction so you have to pay a smaller fee. this is not much of a concern now but at times where fees are high it may be. (more inputs will give you a bigger transaction).

there is a case where you can pay it without creating a "change". for example if you have a transaction output of 3.00001000BTC and want to make a 3BTC payment. you simply spend this tx and pay 3BTC and the rest (1000 satoshi) goes to miners as fee. compared to using 5.00001000BTC output and paying 3BTC + 1000 satoshi fee + 2BTC change (leftover) the first one is preferable.

......
.L I V E C O I N . N E T.
.
..PROFITBOX..
██  █████████████████████████
  █████████▄      ▄██████████
█████████████▄  ▄████████████
    █████████████████████████
  ██████████▀    ▀█ ▀████████
████  █████▀  ▄▄  ▀█  ▀██████
  ████████▀  ▄██▄  ▀█   ▀████
    ██████   ▀██▀   ██   ████
  █████████▄      ▄██████████
██  █████████▄  ▄████████████
  ███████████████████████████
██  █████████████████████████
  █████████████████████▀ ███
█████████████████████▀   ███
    █████████████▀     ████
  █████████████▀   ██    ████
████  █████▀     ██    ████
  ███████▀   ██    ██    ████
    █████    ██    ██    ████
  ███████    ██    ██    ████
██  █████    ██    ██    ████
  ███████████████████████████
.....
MadGamer
Legendary
*
Offline Offline

Activity: 1568
Merit: 1031


View Profile
February 21, 2018, 10:45:03 AM
 #3

Better from what perspective exactly? It's a little bit unclear on what you're trying to achieve but Electrum have two options for coin selection, I believe it's what you're looking for:

Quote
Priority

Maximize transaction priority. Select the oldest unspent transaction outputs in your wallet, that are sufficient to cover the spent amount. Then, remove any unneeded inputs, starting with the smallest in value.

Privacy

Attempts to better preserve user privacy.  First, if any coin is spent from a user address, all coins are.  Compared to spending from other addresses to make up an amount, this reduces information leakage about sender holdings.  It also helps to reduce blockchain UTXO bloat, and reduce future privacy loss that would come from reusing that address' remaining UTXOs.  Second, it penalizes change that is quite different to the sent amount. Third, it penalizes change that is too big.
talkbitcoin
Legendary
*
Offline Offline

Activity: 1372
Merit: 1032


All I know is that I know nothing.


View Profile
February 21, 2018, 10:48:53 AM
 #4

Priority

Maximize transaction priority. Select the oldest unspent transaction outputs in your wallet, that are sufficient to cover the spent amount. Then, remove any unneeded inputs, starting with the smallest in value.

this was removed from bitcoin last year. some miners may still honor the priority thing if they choose to but it no longer matters how old your transactions are. they may have  1 confirmation or 500,000 and still be treated the same.

in fact this will be removed in next version of Electrum (v 3.1).

......
.L I V E C O I N . N E T.
.
..PROFITBOX..
██  █████████████████████████
  █████████▄      ▄██████████
█████████████▄  ▄████████████
    █████████████████████████
  ██████████▀    ▀█ ▀████████
████  █████▀  ▄▄  ▀█  ▀██████
  ████████▀  ▄██▄  ▀█   ▀████
    ██████   ▀██▀   ██   ████
  █████████▄      ▄██████████
██  █████████▄  ▄████████████
  ███████████████████████████
██  █████████████████████████
  █████████████████████▀ ███
█████████████████████▀   ███
    █████████████▀     ████
  █████████████▀   ██    ████
████  █████▀     ██    ████
  ███████▀   ██    ██    ████
    █████    ██    ██    ████
  ███████    ██    ██    ████
██  █████    ██    ██    ████
  ███████████████████████████
.....
jseverson
Hero Member
*****
Offline Offline

Activity: 1834
Merit: 759


View Profile
February 21, 2018, 10:51:08 AM
 #5

Suppose I have 3 unspent outputs:

tx: 3 BTC
tx: 2 BTC
tx: 1 BTC

Now I want to spend 2.5 BTC.
Which is preferred as input(s) and why?

A single:
3 BTC (Leaving my an output change of 0.5)?

Or:
1 BTC + 2BTC? (Leaving my an output change of 0.5)

I hope the question is clear.

You'll save a few bytes by spending the 3 BTC. I don't know if you would prefer that, as you may have other criteria, but that's what I would do. I'd also rather not let wallet explorers know that my 2 BTC and 1 BTC addresses are under the same wallet.

kobik (OP)
Jr. Member
*
Offline Offline

Activity: 39
Merit: 3


View Profile
February 21, 2018, 11:08:17 AM
 #6

Thanks guys! you gave me great tips, so I suppose the matter could be a bit more complex than I thought.
For now the privacy issue less concerns me (I know it's considered a "bad practice").
But I  noticed old and very small amounts txs (like 0.000001)  just hanging, so I thought I need to accumulate the small txs first.
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!