0

I mean generating the transaction itself offline, assuming I know in advance how much bitcoin a UTXO has. In other words, without querying the network for the UTXO balance.

Then I also need to sign that tx, also offline.

And finally I can pass the signed tx to someone via bluetooth, and then he can drive to an Internet connection, and broadcast the tx.

I'm pretty sure there isn't a wallet that does this, so this needs to be some special script or a sequence of cli commands

1

assuming I know in advance how much bitcoin a UTXO has

createrawtransaction in Bitcoin Core requires tx id and vout, if you know it and the address which will be used for output then transaction can be created offline.

Then I also need to sign that tx, also offline

Signing will require private key or a wallet with private key depending on which of these RPC commands you prefer to use: signrawtransactionwithwallet or signrawtransactionwithkey

And finally I can pass the signed tx to someone via bluetooth, and then he can drive to an Internet connection, and broadcast the tx.

Sure. This is possible. I had even worked on a side project which can be used to send bitcoin with text messages (Internet not working but SMS works). You can even encode signed transaction hex in to words.

Related Q&A: Issues decoding the words to transaction hex

I'm pretty sure there isn't a wallet that does this, so this needs to be some special script or a sequence of cli commands

Cold storage (keeping private keys offline) is used by many people in which transaction signing is done offline. Transaction can be created on any device or wallet (online/offline) as long as you have information required to create transaction. For example: tx id and vout of UTXOs you are trying to spend.

RPC to create PSBT also requires same information. I am not sure about compatibility of different wallets so creating a transaction in one wallet and signing in other may have issues. However, I have tried creating a transaction and signing it in Electrum in this Q&A: Create unsigned tx (PSBT) in a watch-only wallet using bitcoin core, sign it in electrum and broadcast using bitcoin core

You can try one experiment:

  1. Open Electrum Wallet. Copy one transaction id. Open it in explorer.

  2. Disconnect Internet.

  3. Open Bitcoin Core.

  4. Create transaction with createrawtransaction

  5. Convert to PSBT with converttopsbt

  6. Copy the results and load transaction in Electrum Wallet. Sign it and copy the transaction hex.

  7. Close all wallets. Open https://blockstream.info/tx/push in browser of any online machine.

  8. Broadcast this transaction

0
1

In this approach, Bitcoin Core is used to create the transaction offline without the hassle of manually creating the transaction:

How to move/sweep your Bitcoin Core bitcoins safely and air-gapped to your new fancy cold storage?

0

Partialy Signed Bitcoin Transactions (PSBTs) cover most of your requirements. PSBTs however require for the Signer to have the full UTXO, not just the Transaction ID, Output index and Amount.

There are many libraries that support PSBTs or simple Transaction creation & signing. You do not need to connect to a full Bitcoin node to use them.

The one that I have used most is Bitcoin JS. It has a clean API, good documentation and unit tests that you can use as examples. You can export the transaction in Hex format, ready for broadcast.

It also has a Web UI for PSBT and Transaction creation and signing. If you want to build your Transactions offline you can just clone the GitHub repo and open the index.html file.

Disclaimer: I am a contributor for the Web UI

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.