<p>You can validate transactions in an offline instance of bitcoind that has absolutely none of the block chain!</p>

<p>Launch it like this:</p>

<pre><code>$ bitcoind -datadir=some-datadir -server -connect=localhost:9999
</code></pre>

<p>The "connect" parameter gives it the remote connect to. If you point it at a non-listening port, it will never gather any blocks. This is fine for validating transactions.</p>

<p>It will tell you that you need to create a bitcoin.conf, and where, and what to put into it (rpcuser=bitcoinrpc and rpcpassword=some_long_string).</p>

<p>Then your bitcoind RPC url will be</p>

<pre><code>http://bitcoinrpc:password@localhost:8332/
</code></pre>

<p>You use the JSON API signrawtransaction documented in section 7.2 of <a href="https://en.bitcoin.it/wiki/Raw_Transactions" rel="nofollow">https://en.bitcoin.it/wiki/Raw_Transactions</a>. You will need to pass in the inputs, since they will not be known to the bitcoin daemon.</p>

<p>I'm the author of the Python library pycoin <a href="https://github.com/richardkiss/pycoin/" rel="nofollow">https://github.com/richardkiss/pycoin/</a> and I use bitcoind to verify that transactions created by pycoin are valid (or in some cases, invalid). See bitcoind_agrees_on_transaction_validity in <a href="https://github.com/richardkiss/pycoin/blob/offline_tx/pycoin/services/bitcoind.py" rel="nofollow">https://github.com/richardkiss/pycoin/blob/offline_tx/pycoin/services/bitcoind.py</a> for an example usage.</p>

<p>(You could also use pycoin to validate transactions. It works, but it's not quite there yet documentation-wise. It also hasn't been extensively tested on non-standard transactions, so its VM implementation is hardly authoritative.)</p>

CC BY-SA 3.0
2014-04-05T15:50:43.680Z
Got the server running on Windows 7 (thanks) and I can successfully issue commands using bitcoind (e.g. getinfo, decoderawtransaction, etc) but all my attempts to put any sort of JSON data into a command fails...for example...bitcoind signrawtransaction <transactioninhex> [{"txid":"bc2964822afc7ed5cf0f6f412cc61a086ff765584d6cb910a2bbe8d4f045eedf","vout":0,"scriptPubKey":"76a91406f1b6703d3f56427bfcfd372f952d50d04b64bd88ac"}]
error: Error parsing JSON:[{txid:bc2964822afc7ed5cf0f6f412cc61a086ff765584d6cb910a2bbe8d4f045eedf,vout:0,scriptPubKey:76a91406f1b6703d3f56427bfcfd372f952d50d04b64bd88ac}]
Phil Dann Ward
CC BY-SA 3.0
2014-04-05T18:35:37.870Z
@PhilDannWard Try enclosing everything in _triple_-quotes. And if you're on Windows--it seems like when I was messing around with Namecoin--I believe CMD needs `\n`ewlines to play nice with JSON (Though I'm probably very wrong.)
KJ O
CC BY-SA 3.0
2014-04-06T21:34:07.263Z
@KJO Your suggestion led me to http://bitcoin.stackexchange.com/questions/5424/passing-a-json-argument-to-bitcoind-in-windows-command-prompt and https://bitcointalk.org/index.php?topic=104512.0 Using either method avoids the JSON parsing error ( :-) ) but trying it out on a worked example https://people.xiph.org/~greg/signdemo.txt gives me complete=false where I'd expect to recreate the example to get complete=true ( :-( ). I shall keep banging my head against the wall trying to work out why I seem to be unable to properly process raw transactions but thanks for getting me a few steps closer.
Phil Dann Ward
CC BY-SA 3.0
2014-04-05T03:55:52.883Z
2014-04-05T03:55:52.883Z
Richard Kiss
<p>I've been wanting to join in the fun on <a href="https://bitcointalk.org/index.php?topic=538423.0" rel="nofollow">this Bitcoin transaction contest</a> but while I'm comfortable enough working out the scripts themselves and playing with the web-based tools suggested, as a relative newbie to Bitcoin I haven't got a clue how to use bitcoind/qt to do the raw transaction validation.</p>

<p>I've downloaded bitcoind/qt/cli but I don't know what to put in my bitcoin.conf nor do I know how to run the tools nor what data I should feed them in order to validate my raw transactions.</p>

<p>I'd prefer to run my raw transaction validations offline but I don't even know if that's a possibility with these tools?</p>

<p>Despite searching wikis, forums, etc, I haven't found a 'dummy's guide' for these tools; everything seems to start from a level of knowledge which is somewhere above where I am at the moment.</p>

<p>I'd be very grateful if somebody could point me in the direction of some suitable information or else provide it here?</p>

<p>And although the organiser of the Bitcoin contest proposed using bitcoind for validating raw transactions I'm happy to consider any other tools/services that would do the equivalent job so if anybody can point me at (simpler?) alternatives that would be fine too.</p>

<p>Thanks in advance.</p>

<bitcoind><raw-transaction><transaction-verification>
How to validate raw transactions using bitcoind and/or bitcoin-cli (preferably offline)?
Phil Dann Ward
# How to validate raw transactions using bitcoind and/or bitcoin-cli (preferably offline)?

(Asked by: username_0 on 2014-04-04)

I've been wanting to join in the fun on [this Bitcoin transaction contest](https://bitcointalk.org/index.php?topic=538423.0) but while I'm comfortable enough working out the scripts themselves and playing with the web-based tools suggested, as a relative newbie to Bitcoin I haven't got a clue how to use bitcoind/qt to do the raw transaction validation.

I've downloaded bitcoind/qt/cli but I don't know what to put in my bitcoin.conf nor do I know how to run the tools nor what data I should feed them in order to validate my raw transactions.

I'd prefer to run my raw transaction validations offline but I don't even know if that's a possibility with these tools?

Despite searching wikis, forums, etc, I haven't found a 'dummy's guide' for these tools; everything seems to start from a level of knowledge which is somewhere above where I am at the moment.

I'd be very grateful if somebody could point me in the direction of some suitable information or else provide it here?

And although the organiser of the Bitcoin contest proposed using bitcoind for validating raw transactions I'm happy to consider any other tools/services that would do the equivalent job so if anybody can point me at (simpler?) alternatives that would be fine too.

Thanks in advance.

**Tags:** bitcoind, raw-transaction, transaction-verification


---

## 1 answers

### Answer by username_1 on 2014-04-05. Score: 2 | Accepted answer

You can validate transactions in an offline instance of bitcoind that has absolutely none of the block chain!

Launch it like this:

```
$ bitcoind -datadir=some-datadir -server -connect=localhost:9999

```

The "connect" parameter gives it the remote connect to. If you point it at a non-listening port, it will never gather any blocks. This is fine for validating transactions.

It will tell you that you need to create a bitcoin.conf, and where, and what to put into it (rpcuser=bitcoinrpc and rpcpassword=some\_long\_string).

Then your bitcoind RPC url will be

```
http://bitcoinrpc:password@localhost:8332/

```

You use the JSON API signrawtransaction documented in section 7.2 of <https://en.bitcoin.it/wiki/Raw_Transactions>. You will need to pass in the inputs, since they will not be known to the bitcoin daemon.

I'm the author of the Python library pycoin <https://github.com/username_1/pycoin/> and I use bitcoind to verify that transactions created by pycoin are valid (or in some cases, invalid). See bitcoind\_agrees\_on\_transaction\_validity in <https://github.com/username_1/pycoin/blob/offline_tx/pycoin/services/bitcoind.py> for an example usage.

(You could also use pycoin to validate transactions. It works, but it's not quite there yet documentation-wise. It also hasn't been extensively tested on non-standard transactions, so its VM implementation is hardly authoritative.)

> **Comments:**
> **username_0**: Got the server running on Windows 7 (thanks) and I can successfully issue commands using bitcoind (e.g. getinfo, decoderawtransaction, etc) but all my attempts to put any sort of JSON data into a command fails...for example...bitcoind signrawtransaction <transactioninhex> [{"txid":"bc2964822afc7ed5cf0f6f412cc61a086ff765584d6cb910a2bbe8d4f045eedf","vout":0,"scriptPubKey":"76a91406f1b6703d3f56427bfcfd372f952d50d04b64bd88ac"}] error: Error parsing JSON:[{txid:bc2964822afc7ed5cf0f6f412cc61a086ff765584d6cb910a2bbe8d4f045eedf,vout:0,scriptPubKey:76a91406f1b6703d3f56427bfcfd372f952d50d04b64bd88ac}]  
> **username_2**: @username_0 Try enclosing everything in _triple_-quotes. And if you're on Windows--it seems like when I was messing around with Namecoin--I believe CMD needs `\n`ewlines to play nice with JSON (Though I'm probably very wrong.)  
> **username_0**: @KJO Your suggestion led me to http://bitcoin.stackexchange.com/questions/5424/passing-a-json-argument-to-bitcoind-in-windows-command-prompt and https://bitcointalk.org/index.php?topic=104512.0 Using either method avoids the JSON parsing error ( :-) ) but trying it out on a worked example https://people.xiph.org/~greg/signdemo.txt gives me complete=false where I'd expect to recreate the example to get complete=true ( :-( ). I shall keep banging my head against the wall trying to work out why I seem to be unable to properly process raw transactions but thanks for getting me a few steps closer.  

---

