Bitcoin Forum
April 24, 2024, 07:22:41 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Transaction inputs and outputs with multiple addresses  (Read 212 times)
balambala (OP)
Newbie
*
Offline Offline

Activity: 35
Merit: 0


View Profile
April 02, 2019, 08:56:25 PM
 #1

I understand that bitcoin transaction has 1 or more inputs and 1 or more outputs.

I was assuming, that each input and output is related to a single address, however, when reading the blockcypher api docs I read:
Quote
addresses array[string]

An array of public addresses associated with the output of the previous transaction.


How is it possible that multiple addresses are involved with a single input or output? I was thinking of multi-signature transactions, however, afaik this would be accomplished by writing a script, which would then be hashed (or double-hashed, since btc folks like to double-hash all the things Smiley) which would represent the P2SH address, right?



Disclaimer:

I searched the internet with no success, all I was able to find were questions à la "Why does a BTC tx have multiple inputs/outputs". Also, I'm not a native English speaker, so forgive me any probably existing mistakes I made.
Make sure you back up your wallet regularly! Unlike a bank account, nobody can help you if you lose access to your BTC.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713943361
Hero Member
*
Offline Offline

Posts: 1713943361

View Profile Personal Message (Offline)

Ignore
1713943361
Reply with quote  #2

1713943361
Report to moderator
HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4316

<insert witty quote here>


View Profile
April 02, 2019, 11:30:30 PM
 #2

A partial answer is probably in the same API docs for the TXoutput:

Quote
addresses   array[string]

Addresses that correspond to this output; typically this will only have a single address, and you can think of this output as having “sent” value to the address contained herein

I'm not aware of any current use cases that have multiple addresses for a single output... perhaps it was going to be a planned feature that was simply never implemented... but the API was left as is. Huh

Also, you should note that this is the Blockcypher API, which is not necessarily identical to the Bitcoin spec...

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
pooya87
Legendary
*
Offline Offline

Activity: 3430
Merit: 10497



View Profile
April 03, 2019, 02:56:43 AM
 #3

these arrays have nothing to do with input/output, these arrays are simply telling you the addresses that were involved in the transaction.
for example if you look at the Tx example (https://api.blockcypher.com/v1/btc/main/txs/f854aebae95150b379cc1187d848d58225f3c4157fe992bcd166f58bd5063449) you can see there is an array of addresses like this:
"addresses": [
    "13XXaBufpMvqRqLkyDty1AXqueZHVe6iyy",
    "19YtzZdcfs1V2ZCgyRWo8i2wLT8ND1Tu4L",
    "1BNiazBzCxJacAKo2yL83Wq1VJ18AYzNHy",
    "1GbMfYui17L5m6sAy3L3WXAtf1P32bxJXq",
    "1N2f642sbgCMbNtXFajz9XDACDFnFzdXzV"
],
the first 4 addresses are the ones that are spending their own outputs (4 tx_in from 4 addresses) and the last one is the one they are paying to (1 tx_out to one address).
this is just a quick way of figuring out what addresses were involved in this particular transaction (f854aeb....)
to keep the code consistent, everywhere else that lists addresses like this (like txinput) will also use a string array as its type.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
balambala (OP)
Newbie
*
Offline Offline

Activity: 35
Merit: 0


View Profile
April 03, 2019, 03:51:49 AM
 #4

A partial answer is probably in the same API docs for the TXoutput:

Quote
addresses   array[string]

Addresses that correspond to this output; typically this will only have a single address, and you can think of this output as having “sent” value to the address contained herein

I'm not aware of any current use cases that have multiple addresses for a single output... perhaps it was going to be a planned feature that was simply never implemented... but the API was left as is. Huh

Also, you should note that this is the Blockcypher API, which is not necessarily identical to the Bitcoin spec...

I am using this tool https://github.com/libbitcoin/libbitcoin-system/blob/79442071497efe14801d103dd5d400dc3157bbf6/include/bitcoin/system/chain/output.hpp and I face the same issue, I wanted to confirm if there is / can be a case where I will face an output with more than one address.

pooya87
Legendary
*
Offline Offline

Activity: 3430
Merit: 10497



View Profile
April 03, 2019, 04:12:02 AM
Merited by bones261 (2), ABCbits (1)
 #5

~ I wanted to confirm if there is / can be a case where I will face an output with more than one address.

outputs are not addresses, they are scripts. some of them (which would shape up majority of transactions) can be converted to addresses.
knowing that, you have to "read" the script and in that it is possible to see anything including more than one address. here is an example transaction:
055f9c6dc094cf21fa224e1eb4a54ee3cc44ae9daa8aa47f98df5c73c48997f9
if you decode it, the pubkey script of it is this:
5121030e001332b43924be343986cca3df669f57b0dedd120990e727787f8dea50fdbc211000000 0000000000000000000000000000000000000000000000000000000000052ae
<OP_1><public key><another public key><OP_2><OP_CheckMultiSig>
so there is technically two addresses here:
030e001332b43924be343986cca3df669f57b0dedd120990e727787f8dea50fdbc
and
100000000000000000000000000000000000000000000000000000000000000000 (although this is an invalid pubkey in this particular case but it didn't need to be)

a better example would have been using OP_IF and things like that but i couldn't find any actual one.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4316

<insert witty quote here>


View Profile
April 03, 2019, 04:17:35 AM
 #6

these arrays have nothing to do with input/output, these arrays are simply telling you the addresses that were involved in the transaction.
...snip...
to keep the code consistent, everywhere else that lists addresses like this (like txinput) will also use a string array as its type.
Yes, but you're looking at the TX level... OP was talking specifically about the TXOutput level.

As you have said, at the TXInput and TXOutput level they are still arrays... and indeed, if you look further down in your example tx decode,  you'll see the "addresses" arrays listed under each "inputs" and "outputs". Even though they only contain a single address, they're still in array notation with the square brackets ie. [ "..." ]

Theoretically, they could show multiple addresses as they are arrays and while that would be valid from a purely syntactical point of view, in practice, I don't think that this would actually decode to a "valid" transaction unless it was some weird custom script.

I concur that it was likely just a design decision made in the early days and has never been corrected for one reason or another.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
pooya87
Legendary
*
Offline Offline

Activity: 3430
Merit: 10497



View Profile
April 03, 2019, 04:46:51 AM
 #7

unless it was some weird custom script.

^^ this
and it probably is due to lazy developers copying code because it doesn't work where it should. i found a better example: https://api.blockcypher.com/v1/btc/test3/txs/8d897ca91774a7fafa086a3275e679248d6bffee015d3b2efefd5dab00df152d?limit=50&includeHex=true
as you can see at the bottom of the page it says ""addresses": null," for the following output:
Code:
76a9145f1426c2ce4a8e1abaa9dbe819b6303eb8a25a2688ad6376a9146c7ceafe76c56843c9d2868f616fdc9370355eb988ac67aa20644d79d87e0907833e888e272e5d7b925deb261a8499a65cbc0bf26797a15e8e8768
which is
Code:
76 a9 14 5f1426c2ce4a8e1abaa9dbe819b6303eb8a25a26 88 ad 
<DUP><HASH160><push><EqualVerify><CheckSigVerify>

63
<IF>
76 a9 14 6c7ceafe76c56843c9d2868f616fdc9370355eb9 88 ac
<DUP><HASH160><push><EqualVerify><CheckSig>

67
<ELSE>

aa 20 644d79d87e0907833e888e272e5d7b925deb261a8499a65cbc0bf26797a15e8e 87
<HASH256><push><EQUAL>

68
<ENDIF>

so it has 2 addresses with P2PKH scripts (so 2 base58 encoding here which will result in addresses starting with 1 or in case of testnet with m) and a third double SHA256 result which i can't tell what it is, it can be result of hash of a public key or anything else!

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
odolvlobo
Legendary
*
Offline Offline

Activity: 4298
Merit: 3200



View Profile
April 03, 2019, 06:20:48 AM
 #8

As @pooya87 explained, an output doesn't have an address. It has a script. There are scripts with no addresses (for example, a pay-to-any transaction), and there can be scripts with multiple addresses. It is all up to the script contained in the output.

The most common type of Bitcoin transaction is called pay-to-pubkey-hash (P2PKH), which is a transaction that sends bitcoins to an address. The script contains an address (in the form of a "pubkey hash") and a block explorer extracts it from the script and displays it as the destination address.


Join an anti-signature campaign: Click ignore on the members of signature campaigns.
PGP Fingerprint: 6B6BC26599EC24EF7E29A405EAF050539D0B2925 Signing address: 13GAVJo8YaAuenj6keiEykwxWUZ7jMoSLt
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!