I have experimented with creating the shortest possible raw transaction, which has been successfully broadcast and mined.
A very quick Google search (my due diligence is admittedly so-so) reveals that someone boasts about
sending a 129-byte transaction.
I have sent an 85-byte transaction! Txid: fbff3bdec5b34bff4e3bd9066fd53262b014abe0227898ce9bcc8552f31f7394Is it possible to beat this, i.e. do even shorter than 85 bytes?My strategy:
-- Spend from an any-one-can-spend address with a 4-byte sigscript (I have failed to go shorter than this, can you?)
-- Send to a native segwit address, the shortest of the predefined standard formats
Here is my transaction...
01000000012f107ec7a860784725acc93d2362a0dc9b2560eafe5ff3f0b1faef5e0831517b0100000003510161ffffffff0186959800000000001600141ee44a2f2c8d366945ff02676bd608f70a559ea700000000
... and let's break it down (and look for any potential room for improvement):
01000000 - version number (always 4 bytes)
01 - number of inputs (always 1 byte)
2f107ec7a860784725acc93d2362a0dc9b2560eafe5ff3f0b1faef5e0831517b - txid in little endian format (always 32 bytes)
01000000 - vout little endian (always 4 bytes)
03510161 - sigscript including length byte padding (1+3=4 bytes)
ffffffff (sequence number - always 4 bytes)
01 - number of outputs (1 byte)
8695980000000000 - amount (little endian, always 8 bytes)
1600141ee44a2f2c8d366945ff02676bd608f70a559ea7 -- (a native segwit address, 1+22=23 bytes [shortest possible standard address])
00000000 - locktime (block 0, always 4 bytes)
4 + 1 + 32 + 4 + 4 + 4 + 1 + 8 + 23 + 4 = 85 bytes
Seems to check out.
OK, can we go shorter? My reasoning - I'd love your comments:
-- Most of the values have hardcoded lengths, you can for example never reference a txid that isn't exactly 32 bytes
-- I want the transaction to be accepted on the mainnet, which excludes sending to pure scripts (P2S), as these are no longer accepted by Bitcoin Core nodes, due to IsStandard() and IsStandardtx() checks, so we are limited to the predefined address formats of which native segwit is the shortest, byte-wise (and there is no witness data here since we use a stupid any-one-can-spend address)
-- All my attempts to assemble shorter sigscritps have failed. A sigscript must contain an unlocking script that is "push only", so OP_1 (51) it is for the unlocking script, and it must be followed by the locking script, which cannot be empty (I think?!), and the whole shebang must be prefixed with a length byte; I haven't been able to get anything below 4 bytes in total to work
-- You could cheat and spend to OP_RETURN 01
only, which is considered a standard address (whether you like it or not); such transactions, however, always lead to provably unspendable outputs, so add that to my list of requirements: the transaction should not trap coins in unspendable outputs
Is my 85-bytes transaction some sort of record? If so, cool, I guess.
Can we go shorter than 85 bytes? Shoot! Thanks.