Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: remotemass on December 20, 2020, 01:05:51 PM



Title: What file format you recommend to save a signed transaction to broadcast later?
Post by: remotemass on December 20, 2020, 01:05:51 PM
What file format do you recommend to save a signed transaction to broadcast much later?

I suppose I should save it in a text file (.txt) or in a pdf file using just plain text with JSON or XML.

Actually, I don't have a clear idea of how does a signed transaction ready to be broadcasted and validated by the bitcoin network (and eventually entering the blockchain) does look like in plain text.

Even less, how does it look like if it uses smart contracts with "Bitcoin Script".

But I want to learn about it. For instance, it would be very useful to be able to lock some coins and would be sent to someone else's address in the distant future if I did not change my mind in the meantime. This way I would know that if I die someone from my family would receive my coins in the distant future as I would not be able to change my mind after dying. Hope it makes sense.








 












Title: Re: What file format you recommend to save a signed transaction to broadcast later?
Post by: LoyceV on December 20, 2020, 01:28:14 PM
What file format do you recommend to save a signed transaction to broadcast much later?
Any text-format will do. There's no need to make it more complicated.
Unless you want to make a QR-code out of it, in that case I'd go for PDF. Or just save it as GIF.

I suppose I should save it in a text file (.txt) or in a pdf file using just plain text with JSON or XML.

Quote
Actually, I don't have a clear idea of how does a signed transaction ready to be broadcasted and validated by the bitcoin network (and eventually entering the blockchain) does look like in plain text.
Like this:
Signed Recovery Transaction
Code:
010000000126063a71fecd0c76fa7d31a561cbe95bf2c7e5da01ae04fed6a6e9dfbc80953e010000006a47304402201a16d89264518baca8f4959b446372c6ce91e8d1fbc0b7b48618aeb76113df33022040eb804bf7cd6519d01709066658251cef1822ff49fd07707e058a07b27b42f9012103f78766b4346bcec0f2ae92d7e132e6b321c47627f14356a704b3ce57169dcb4e000000000116260000000000001976a914cfdd1b997472bd0b668e7472d9708305f116994d88acc0270900
https://loyce.club/other/transaction.png

But I want to learn about it. For instance, it would be very useful to be able to lock some coins and would be sent to someone else's address in the distant future if I did not change my mind in the meantime. This way I would know that if I die someone from my family would receive my coins in the distant future as I would not be able to change my mind after dying. Hope it makes sense.
See Using Locktime for inheritance planning, backups or gifts (https://bitcointalk.org/index.php?topic=5180850.0) :)
Or play around with Coinb.in (https://coinb.in/) (don't enter any private keys on a LIVE website!).


Title: Re: What file format you recommend to save a signed transaction to broadcast later?
Post by: NotATether on December 20, 2020, 02:22:47 PM
What file format do you recommend to save a signed transaction to broadcast much later?
Any text-format will do. There's no need to make it more complicated.
Unless you want to make a QR-code out of it, in that case I'd go for PDF. Or just save it as GIF.

PDF is a great format for presenting documents for consumption... but it's notoriously difficult to copy text data from a PDF file. Blank spaces and newlines are inserted at the wrong places in the clipboard, and some characters are changed into similar Unicode characters from PDF to clipboard, and creating a PDF is a very complicated process that involves using things like TeX and *latex (and there are several kinds of latex programs such that it's confusing to beginners).

There's literally no reason not to use a plain text file for the signed transaction because it takes the smallest amount of space, is easy to copy from and paste to some transaction broadcaster, and there are no broadcasters that accept a QR code representation of a transaction as input.


Title: Re: What file format you recommend to save a signed transaction to broadcast later?
Post by: LoyceV on December 20, 2020, 03:16:38 PM
there are no broadcasters that accept a QR code representation of a transaction as input.
Good point. The QR-code is only useful if you print it and don't want to manually type the transaction to broadcast.


Title: Re: What file format you recommend to save a signed transaction to broadcast later?
Post by: HCP on December 20, 2020, 08:13:23 PM
What file format do you recommend to save a signed transaction to broadcast much later?
I suppose I should save it in a text file (.txt) or in a pdf file using just plain text with JSON or XML.
Yes, just use a text file. There is no reason to save it as a PDF, aside from being a hassle to create in the first place, you will likely run into issues when trying to extract the data back out of the PDF (They're designed and made for reading, not for transferring data).

Quote
Actually, I don't have a clear idea of how does a signed transaction ready to be broadcasted and validated by the bitcoin network (and eventually entering the blockchain) does look like in plain text.

As shown, a signed transaction is just a long sequence of "hex" characters:
Code:
010000000126063a71fecd0c76fa7d31a561cbe95bf2c7e5da01ae04fed6a6e9dfbc80953e010000006a47304402201a16d89264518baca8f4959b446372c6ce91e8d1fbc0b7b48618aeb76113df33022040eb804bf7cd6519d01709066658251cef1822ff49fd07707e058a07b27b42f9012103f78766b4346bcec0f2ae92d7e132e6b321c47627f14356a704b3ce57169dcb4e000000000116260000000000001976a914cfdd1b997472bd0b668e7472d9708305f116994d88acc0270900

You can use a transaction decoder (like this (https://btc.com/tools/tx/decode) or this (https://live.blockcypher.com/btc/decodetx/) or decoderawtransaction in Bitcoin Core) to get the details of the transaction in a JSON format like so:
Code:
{
  "txid": "dc6383e28e4b6c652ab326592652b0322331caf07231cabec562ab116a46ff9c",
  "hash": "dc6383e28e4b6c652ab326592652b0322331caf07231cabec562ab116a46ff9c",
  "version": 1,
  "size": 191,
  "vsize": 191,
  "weight": 764,
  "locktime": 600000,
  "vin": [
    {
      "txid": "3e9580bcdfe9a6d6fe04ae01dae5c7f25be9cb61a5317dfa760ccdfe713a0626",
      "vout": 1,
      "scriptSig": {
        "asm": "304402201a16d89264518baca8f4959b446372c6ce91e8d1fbc0b7b48618aeb76113df33022040eb804bf7cd6519d01709066658251cef1822ff49fd07707e058a07b27b42f9[ALL] 03f78766b4346bcec0f2ae92d7e132e6b321c47627f14356a704b3ce57169dcb4e",
        "hex": "47304402201a16d89264518baca8f4959b446372c6ce91e8d1fbc0b7b48618aeb76113df33022040eb804bf7cd6519d01709066658251cef1822ff49fd07707e058a07b27b42f9012103f78766b4346bcec0f2ae92d7e132e6b321c47627f14356a704b3ce57169dcb4e"
      },
      "sequence": 0
    }
  ],
  "vout": [
    {
      "value": 0.00009750,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 cfdd1b997472bd0b668e7472d9708305f116994d OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914cfdd1b997472bd0b668e7472d9708305f116994d88ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "1Kx5kYqStfhPQntRv185pTuyafLoaYLrV7"
        ]
      }
    }
  ]
}

Storing as "hex" is the best option as it takes up the least amount of space and can be immediately sent using any Transaction Broadcast tool (website "push tx" tool like this (https://btc.com/tools/tx/publish) or this (https://live.blockcypher.com/btc/pushtx/) or Bitcoin Core sendrawtransaction etc)


Title: Re: What file format you recommend to save a signed transaction to broadcast later?
Post by: pooya87 on December 21, 2020, 05:30:19 AM
It depends on how you are going to consume the file later.
  • A .txt file containing the transaction in hexadecimal format can be opened almost everywhere and copied to be pasted in almost any wallet and any online (web) tool to be broadcast.
  • A JSON file that contains the deserialized transaction is not useful since you have to serialize it again to be able to use it anywhere; unless you have a code already that saves and reads this file itself. Although there is no point in saving it like that.
  • Any special format like the one Electrum uses (.txn file) is going to be specific to that wallet/tool and may not be usable in any other tool. (Electrum .txn files are the raw hex inside a JSON).
  • Saving it as data (.dat) and writing the bytes to disk will produce the smallest file (half the size of the hex) but can only be read using a program (they aren't human readable).
  • QR code is only good for visual representation and is useful when you have an airgap cold storage that you don't want to connect anything (like a USB disk) to.