Author

Topic: size of transaction bitcoin ? (Read 293 times)

legendary
Activity: 3430
Merit: 3080
April 21, 2019, 02:26:46 PM
#10
ugh, you're right (shouldn't go on Dev & Tech board when drunk or tired Cheesy)

corrected
legendary
Activity: 3472
Merit: 10611
April 20, 2019, 10:08:51 PM
#9
Public keys are SHA256 hashes,
SHA256 hashes are this long (32 bytes)    : 03664c1df2953630fbec0293c9fe78c891e40b9a92427bec71782a74e13bc1dac6

public key is not a hash! public key is a coordinate (as in x,y) in bitcoin because the curve is a 256 bit curve these points have 256 bit x and y. there is no hashes involved.
so 03-664c1df2... (which is 33 bytes long) is the x coordinate of the public key + the initial first byte indicating oddity of y coordinate.
legendary
Activity: 3430
Merit: 3080
April 20, 2019, 05:07:16 PM
#8
"if" this is my address address/1LUUzeASL4Ed51eRsHBZxCpPhS5GT5YBAf

if you have any address in a bitcoin core wallet file, you can do this:

Code:
bitcoin-cli getaddressinfo 1LUUzeASL4Ed51eRsHBZxCpPhS5GT5YBAf 

the public key for a given address isn't written to the blockchain until after the address (i.e. the publick key hash) has been spent from


my pubkey is d59cfd295c3ac1160058148c0df2033a5ba2f955 ?
refference from Hash 160

that looks like 160 bits length, not 256 bits length. Public keys are SHA256 hashes 256 bits long, which makes them visually distinct in length compared to ripemd160 hashes.

ripemd160 hashes are this long (20 bytes): d59cfd295c3ac1160058148c0df2033a5ba2f955
SHA256 hashes are this long (32 bytes)    : 03664c1df2953630fbec0293c9fe78c891e40b9a92427bec71782a74e13bc1dac6

...and they're always that long, because they're always the same number of bits/bytes

hero member
Activity: 1232
Merit: 738
Mixing reinvented for your privacy | chipmixer.com
April 20, 2019, 03:31:06 PM
#7
"if" this is my address address/1LUUzeASL4Ed51eRsHBZxCpPhS5GT5YBAf and i check the detail address here
https://www.blockchain.com/en/btc/address/1LUUzeASL4Ed51eRsHBZxCpPhS5GT5YBAf

my pubkey is d59cfd295c3ac1160058148c0df2033a5ba2f955 ?
refference from Hash 160
https://www.blockchain.com/en/btc/address/d59cfd295c3ac1160058148c0df2033a5ba2f955
No, that's not a public key for 1LUU...
to see its public key you can find it in a tx that spends any of its utxos

Input Scripts
ScriptSig: PUSHDATA(71)[3044022078aa0125cc9f60406af5218c7fbbe68b8add17b5ca9fd4e1186c23552befe6800220633d9131a78b6250a41c53a7126fa4ca28516dfa9072ccca710dc4bdf1f1b1ec01] PUSHDATA(33)[03664c1df2953630fbec0293c9fe78c891e40b9a92427bec71782a74e13bc1dac6]
that is the input script part of the tx, the bolded part is the public key of 1LUU...
it's a 66 characters long, so 1LUU... is a compressed bitcoin address
if it were an uncompressed one, its public key would be 130 characters long
legendary
Activity: 1316
Merit: 1145
April 20, 2019, 08:59:49 AM
#6
thanks for reply poya and hcp
so the address like this 1F1tAaz5x1HUXrCNLbtMDqcw6o5GNn4xqX is compros  "uncompressed" P2PKH
You can't actually tell just from an address if it was created from a "compressed" or "uncompressed" public key. This is because the address is an encoding of the hash of the public key. The hashing function used is one way, so there is no way to get from address -> public key...

So, you need to start with the public key... And then check what address is generated from the compressed form and the uncompressed form and compare with the address you have.

Or, if you didn't already have the public key, you could look at a transaction involving spending from that address and you could see if the input script used the compressed or uncompressed public key.

"if" this is my address address/1LUUzeASL4Ed51eRsHBZxCpPhS5GT5YBAf and i check the detail address here
https://www.blockchain.com/en/btc/address/1LUUzeASL4Ed51eRsHBZxCpPhS5GT5YBAf

my pubkey is d59cfd295c3ac1160058148c0df2033a5ba2f955 ?
refference from Hash 160
https://www.blockchain.com/en/btc/address/d59cfd295c3ac1160058148c0df2033a5ba2f955
HCP
legendary
Activity: 2086
Merit: 4361
April 20, 2019, 04:27:12 AM
#5
thanks for reply poya and hcp
so the address like this 1F1tAaz5x1HUXrCNLbtMDqcw6o5GNn4xqX is compros  "uncompressed" P2PKH
You can't actually tell just from an address if it was created from a "compressed" or "uncompressed" public key. This is because the address is an encoding of the hash of the public key. The hashing function used is one way, so there is no way to get from address -> public key...

So, you need to start with the public key... And then check what address is generated from the compressed form and the uncompressed form and compare with the address you have.

Or, if you didn't already have the public key, you could look at a transaction involving spending from that address and you could see if the input script used the compressed or uncompressed public key.
legendary
Activity: 1316
Merit: 1145
April 20, 2019, 01:21:43 AM
#4

public key is the second item that is pushed on the stack inside the scriptsig. from the signature simply read the script, the first is the signature and the sighashtype and the second is the public key.
from private key, you have to derive the public key by multiplying private key by curve's generator.

ps. look at this site: https://coinb.in/#fees
how usefull calculate, thanks pooya
now i can see how easy calculate size of transaction , i jusp put how much input and output.

As Pooya has mentioned... No "pub address"... You mean "Pay to Pub key hash" aka "P2PKH".. This version of the formula (inputs*180...) is when you are spending UTXOs belonging to "1-type" aka Legacy addresses that have been created using uncompressed public keys.


thanks for reply poya and hcp
so the address like this 1F1tAaz5x1HUXrCNLbtMDqcw6o5GNn4xqX is compros  "uncompressed" P2PKH
and like this 0250863ad64a87ae8a2fe83c1af1a8403cb53f53e486d8511dad8a04887e5b2352 is pubkey? refference : https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses

sorry im still learning more deep abut blockchain.

i think i must learn more deep again.
HCP
legendary
Activity: 2086
Merit: 4361
April 19, 2019, 11:29:38 PM
#3
if isend to pub address "uncompressed" P2PKH i use this calculate
in*180 + out*34 + 10 plus or minus 'in'
As Pooya has mentioned... No "pub address"... You mean "Pay to Pub key hash" aka "P2PKH".. This version of the formula (inputs*180...) is when you are spending UTXOs belonging to "1-type" aka Legacy addresses that have been created using uncompressed public keys.


Quote
and for pubkey "compressed" P2PKH i use this
in*148 + out*34 + 10 plus or minus 'in'
That formula (input*148) is for "P2PKH" addresses using compressed public keys as they are 32bytes smaller than the original uncompressed public key.


Again, as Pooya has mentioned, the advent of P2SH-P2WPKH and P2WPKH SegWit transactions means these basic formulas for calculating Bitcoin are no longer valid for all transactions...

It is only valid when spending outputs from legacy "1-type" addresses. The correct method for estimating the effective "size" of a SegWit transaction is stated here: https://bitcoincore.org/en/segwit_wallet_dev/#transaction-fee-estimation

Transaction Fee Estimation
  • Instead of transaction size, a new metric is defined, called “virtual size” (vsize)
  • vsize of a transaction equals to 3 times of the size with original serialization, plus the size with new serialization, divide the result by 4 and round up to the next integer. For example, if a transaction is 200 bytes with new serialization, and becomes 99 bytes with marker, flag, and witness removed, the vsize is (99 * 3 + 200) / 4 = 125 with round up.
  • vsize of a non-segwit transaction is simply its size
  • Transaction fee should be estimated by comparing the vsize with other transactions, not the size.
  • Developers should be careful not to make an off-by-4-times mistake in fee estimation.
legendary
Activity: 3472
Merit: 10611
April 19, 2019, 10:41:06 PM
#2
that answer is quite old and things have changed a lot since then. basically now you first have to determine the type of transaction you are making and then start calculating its size. in short that calculation is currently quite complicated because there is a lot of "if"s now. for example if it is a SegWit transaction you should calculate "weight" instead of size and also your transaction will contain extra fields (eg. the extra 2 byte flag) and depending on the script type (P2WPKH or P2WSH) you may have empty scriptsig or extra data in it.

if isend to pub address i use this calculate
there is no such thing as "pub address"!
and where you send coins to (the type of output you create) isn't going to change the size that much for 90% of the cases.
the size difference is mostly based on what you are spending (the type of output you are spending).
the formula you posted is for when you spend a P2PKH output with a compressed public key

Quote
i want to asking about pubkey, how to extract the pubkey of bitcoin? i have bitcoin private key (running bitcoin daemon), can i use pubkey from signature message ?
public key is the second item that is pushed on the stack inside the scriptsig. from the signature simply read the script, the first is the signature and the sighashtype and the second is the public key.
from private key, you have to derive the public key by multiplying private key by curve's generator.

ps. look at this site: https://coinb.in/#fees
legendary
Activity: 1316
Merit: 1145
April 19, 2019, 06:46:51 PM
#1
if isend to pub address i use this calculate
in*180 + out*34 + 10 plus or minus 'in'

and for pubkey i use this
in*148 + out*34 + 10 plus or minus 'in'


refference : https://bitcoin.stackexchange.com/questions/1195/how-to-calculate-transaction-size-before-sending-legacy-non-segwit-p2pkh-p2sh

i want to asking about pubkey, how to extract the pubkey of bitcoin? i have bitcoin private key (running bitcoin daemon), can i use pubkey from signature message ?
Jump to: