<p>You may be trying to validate a mainnet address on a testnet/regtest client.</p>

<p>For the benefit of others:</p>

<pre><code>&lt;?php

require '/tmp/vendor/autoload.php';

$command = new \Nbobtc\Command\Command('getinfo');
$client  = new \Nbobtc\Http\Client('http://username:password@localhost:18332');

# legacy testnet address
#$address = "mvM368BXwRNx4HcYdL8XbU8hAX274gMKcq";
# bech32 address
#$address = "2Mzm5MPhGWTxNcZPGfpW7URR4mASKzsCZ3k";
# mainnet address
$address = "1KJFgSXpPvUthy3a7NxyM66szTkqHabpYB";

$command = new \Nbobtc\Command\Command('validateaddress', [$address]);
$response = $client-&gt;sendCommand($command);
$contents = $response-&gt;getBody()-&gt;getContents();

echo $contents;
?&gt;
</code></pre>

<p>I observe that bitcoin 0.18.1 will return as OP describes when attempting to validate a mainnet address on a testnet/regtest client, and return correct details otherwise.</p>

<p>If not, could you edit in to your question the actual address and the bitcoin.conf you're using.</p>

<p>Edit: I notice there IS a difference. I'm getting 
<code>{"result":{"isvalid":false},"error":null,"id":null}</code>
vs OP getting
<code>Array ( [result] =&gt; Array ( [isvalid] =&gt; ) [error] =&gt; [id] =&gt; )</code>
Perhaps there is some post-processing you're doing to $contents that is losing the value?</p>

CC BY-SA 4.0
2019-09-19T17:38:56.943Z
2019-09-19T17:54:25.303Z
2019-09-19T17:54:25.303Z
Alistair Mann
<p>I am attempting to use Bitcoin RPC in regtest mode, however, when I try to validate a bitcoin address with the following function</p>

<pre><code>public function validateAddress($address)
{
    $command = new \Nbobtc\Command\Command('validateaddress', [$address]);
    $response = $this-&gt;client-&gt;sendCommand($command);
    $contents = $response-&gt;getBody()-&gt;getContents();

    return $contents;
}
</code></pre>

<p>it returns...</p>

<pre><code>Array ( [result] =&gt; Array ( [isvalid] =&gt; ) [error] =&gt; [id] =&gt; )
</code></pre>

<p>Any ideas why the isvalid value is missing?</p>

<p>I could have sworn this was working a day or two ago...</p>

CC BY-SA 4.0
2019-09-19T14:32:46.457Z
can you add more details?
vincenzopalazzo
CC BY-SA 4.0
2019-09-19T14:35:06.307Z
Thank you for taking a look, Did you have a specific questions about my question? =]
Jeffrey L. Roberts
CC BY-SA 4.0
2019-09-19T15:35:27.367Z
you use the same address for the testing in the mainet and regtest?
vincenzopalazzo
CC BY-SA 4.0
2019-09-19T16:27:54.877Z
yes sir i do, i copy and pasted it
Jeffrey L. Roberts
<bitcoind><json-rpc><validation>
Bitcoin RPC RegTest not validating addresses
Jeffrey L. Roberts
# Bitcoin RPC RegTest not validating addresses

(Asked by: username_0 on 2019-09-19)

I am attempting to use Bitcoin RPC in regtest mode, however, when I try to validate a bitcoin address with the following function

```
public function validateAddress($address)
{
    $command = new \Nbobtc\Command\Command('validateaddress', [$address]);
    $response = $this->client->sendCommand($command);
    $contents = $response->getBody()->getContents();

    return $contents;
}

```

it returns...

```
Array ( [result] => Array ( [isvalid] => ) [error] => [id] => )

```

Any ideas why the isvalid value is missing?

I could have sworn this was working a day or two ago...

**Tags:** bitcoind, json-rpc, validation

> **Comments:**
> **username_1**: can you add more details?  
> **username_0**: Thank you for taking a look, Did you have a specific questions about my question? =]  
> **username_1**: you use the same address for the testing in the mainet and regtest?  
> **username_0**: yes sir i do, i copy and pasted it  

---

## 1 answers

### Answer by username_2 on 2019-09-19. Score: 1

You may be trying to validate a mainnet address on a testnet/regtest client.

For the benefit of others:

```
<?php

require '/tmp/vendor/autoload.php';

$command = new \Nbobtc\Command\Command('getinfo');
$client  = new \Nbobtc\Http\Client('http://username:password@localhost:18332');

# legacy testnet address
#$address = "mvM368BXwRNx4HcYdL8XbU8hAX274gMKcq";
# bech32 address
#$address = "2Mzm5MPhGWTxNcZPGfpW7URR4mASKzsCZ3k";
# mainnet address
$address = "1KJFgSXpPvUthy3a7NxyM66szTkqHabpYB";

$command = new \Nbobtc\Command\Command('validateaddress', [$address]);
$response = $client->sendCommand($command);
$contents = $response->getBody()->getContents();

echo $contents;
?>

```

I observe that bitcoin 0.18.1 will return as OP describes when attempting to validate a mainnet address on a testnet/regtest client, and return correct details otherwise.

If not, could you edit in to your question the actual address and the bitcoin.conf you're using.

Edit: I notice there IS a difference. I'm getting
`{"result":{"isvalid":false},"error":null,"id":null}`
vs OP getting
`Array ( [result] => Array ( [isvalid] => ) [error] => [id] => )`
Perhaps there is some post-processing you're doing to $contents that is losing the value?


---

