<p>If not a coinbase transaction, you <em>have</em> to spend from an existing output. Thus the input <em>must</em> reference an existing transaction.</p>

<blockquote>
  <p>cannot retrieve the previous tx_hash</p>
</blockquote>

<p>Maybe the library you are using is the following common semantic:</p>

<ul>
<li><code>txid</code> for the transaction id (hash <em>without</em> the witness data)</li>
<li><code>tx_hash</code> for the transaction hash (hash <em>with</em> the witness data)</li>
</ul>

<p>You want the <code>txid</code> to reference a previous transaction in an input.</p>

CC BY-SA 4.0
2020-03-12T15:31:38.027Z
2020-03-12T15:31:38.027Z
Antoine Poinsot
<p>Iam using the bitcoinjs-lib library and trying to do a transaction. Iam doing the tx.addInput method before building but running into a build issue. I assume an error is thrown if blockchainScripthash_listunspent cannot retrieve the previous tx_hash.</p>

<bitcoin-core><client><bitcoinjs>
How to do tx.addInput without tx_hash if sending from address for the first time?
jwjop1
# How to do tx.addInput without tx_hash if sending from address for the first time?

(Asked by: username_0 on 2020-03-12)

Iam using the bitcoinjs-lib library and trying to do a transaction. Iam doing the tx.addInput method before building but running into a build issue. I assume an error is thrown if blockchainScripthash\_listunspent cannot retrieve the previous tx\_hash.

**Tags:** bitcoin-core, client, bitcoinjs


---

## 1 answers

### Answer by username_1 on 2020-03-12. Score: 1

If not a coinbase transaction, you *have* to spend from an existing output. Thus the input *must* reference an existing transaction.

> cannot retrieve the previous tx\_hash

Maybe the library you are using is the following common semantic:

* `txid` for the transaction id (hash *without* the witness data)
* `tx_hash` for the transaction hash (hash *with* the witness data)

You want the `txid` to reference a previous transaction in an input.


---

