I have a full bitcoin core node setup and would like to use it to just "broadcast" my signed transactions. But what is required to make a raw transaction using PHP and Javascript? The variables I have are just the private key, amount i want to send, and a send to address. What other missing data do I need?

Is there a good easy tutorial to follow for doing this in PHP and Javascript?

I want to make a static html/js page where I can paste my private key and other data into and it would output a "signed" transaction.


You also need to acquire the UTXO's which are spendable by your private key.

The private key in WIF private key format provides the information required to derive the pubkeyhash found in P2PKH(pubkeyhash) and P2WPKH(pubkeyhash) output scripts spendable by the private key. Deriving the pubkeyhash, or even address, can be done with BitcoinJS on the front-end.

Once you have derived the pubkeyhash or address key, you need to have an index to look-up all unspent spendable output points (utxo's) belonging to this key.

You can either build your own pubkeyhash/address index, or use an Bitcoin server implementation which does this (e.g. Libbitcoin-Server).

Your backend can lookup the pubkeyhash/address key and fetch all spendable UTXO's which are then signed on the front-end by your private key (depending on the amount and coin-selection strategy, you will select specific UTXO's to build the transaction which spends to your destination address(es)).

  • I was hoping that I was able to make a raw transaction without the need to access any other data. But from what your saying I still need to query the blockchain to get my unspent UTXO's derived from my public key right? Is there a way I can code my html/js static page to just query a public database with this data instead of install any other software? I want to make it as streamlined as possible. thanks! Jan 7 '19 at 17:59
  • 1
    You can try querying the Libbitcoin mainnet servers (e.g. mainnet1.libbitcoin.net) for testing purposes. These are in V3, and index all transactions by address, which is what you need. The caveat is that the server-api is a ZeroMQ interface, which you can query with both PHP/JS. See the fetch_history query command at github.com/libbitcoin/libbitcoin-server/wiki/Query-Service
    – James C.
    Jan 7 '19 at 18:05

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.