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).
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:
010000000126063a71fecd0c76fa7d31a561cbe95bf2c7e5da01ae04fed6a6e9dfbc80953e010000006a47304402201a16d89264518baca8f4959b446372c6ce91e8d1fbc0b7b48618aeb76113df33022040eb804bf7cd6519d01709066658251cef1822ff49fd07707e058a07b27b42f9012103f78766b4346bcec0f2ae92d7e132e6b321c47627f14356a704b3ce57169dcb4e000000000116260000000000001976a914cfdd1b997472bd0b668e7472d9708305f116994d88acc0270900
You can use a transaction decoder (like
this or
this or
decoderawtransaction in Bitcoin Core) to get the details of the transaction in a JSON format like so:
{
"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 or
this or Bitcoin Core
sendrawtransaction etc)