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

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

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

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

<p>Your backend can lookup the <code>pubkeyhash/address</code> 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)).</p>

CC BY-SA 4.0
2019-01-07T17:59:44.237Z
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!
Patoshi パトシ
CC BY-SA 4.0
2019-01-07T18:05:51.033Z
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 https://github.com/libbitcoin/libbitcoin-server/wiki/Query-Service
James C.
CC BY-SA 4.0
2019-01-07T17:53:06.240Z
2019-01-07T17:53:06.240Z
James C.
<p>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? </p>

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

<p>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.</p>

<raw-transaction><php><javascript><signrawtransaction><signature-operations>
Creating a raw bitcoin transaction and signing it with the private key using php and javascript
Patoshi パトシ
# Creating a raw bitcoin transaction and signing it with the private key using php and javascript

(Asked by: username_0 on 2019-01-07)

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.

**Tags:** raw-transaction, php, javascript, signrawtransaction, signature-operations


---

## 1 answers

### Answer by username_1 on 2019-01-07. Score: 1

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)).

> **Comments:**
> **username_0**: 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!  
> **username_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 https://github.com/libbitcoin/libbitcoin-server/wiki/Query-Service  

---

