<p>I am not sure as have not used their api system but it could be down to the format of your bitcoin address you are passing in.</p>

<p><code>66f4dec6ab29cd056ce1814c6fdfee05e1524b36</code> is read as a valid bitcoin address using <a href="https://thomas.vanhoutte.be/tools/validate-bitcoin-address.php?address=66f4dec6ab29cd056ce1814c6fdfee05e1524b36&amp;submit=" rel="nofollow noreferrer">this service</a></p>

<p>However when I <a href="https://www.blockchain.com/btc/address/1APPGSyMsPaBUAHtjEm6tPqV9U54JRzmd6" rel="nofollow noreferrer">search that address under a block explorer</a> I get the following address which starts with the more common 1 <code>1APPGSyMsPaBUAHtjEm6tPqV9U54JRzmd6</code></p>

<p>66f is not a start of a bitcoin address i recognise, though there are many out but <a href="https://en.bitcoin.it/wiki/List_of_address_prefixes" rel="nofollow noreferrer">no mention on the wiki</a></p>

<p>Thus I would suggest trying your code with the more common bitcoin address format</p>

<pre><code>$FEES = $wallet-&gt;coinSelection(\Blocktrail\SDK\Wallet::normalizeOutputsStruct(['1APPGSyMsPaBUAHtjEm6tPqV9U54JRzmd6' =&gt;'100000']),false,false,\Blocktrail\SDK\Wallet::FEE_STRATEGY_LOW_PRIORITY['fee'];
echo "$FEES";
</code></pre>

<p>And see if that works</p>

CC BY-SA 4.0
2018-07-29T12:51:28.450Z
Thanks for reply, but it still don't work, same error
user10148040
CC BY-SA 4.0
2018-07-29T12:56:52.720Z
hmm One thing I would want to verify next would be that the `coinSelection` part of your code is definitely choosing bitcoin?
Fuzzybear
CC BY-SA 4.0
2018-07-29T12:59:53.663Z
Yes, it is bitcoin, the only thing is that I'm using the bitcoin testnet, that I have initialized before, $client = new BlocktrailSDK("api", "api", "BTC", true);
user10148040
CC BY-SA 4.0
2018-07-29T13:04:22.543Z
66f4dec6ab29cd056ce1814c6fdfee05e1524b36  is a bitcoin test net address
user10148040
CC BY-SA 4.0
2018-07-29T14:13:27.490Z
might be you need to specify the testnet on the fee transaction as well... what are the `false,false` parts submitted after the address? though i would have expected that to have worked with the bitcoin address starting with the 1. So not sure, have you tried speaking directly to their support?
Fuzzybear
CC BY-SA 4.0
2018-07-29T12:38:39.373Z
2018-07-29T12:38:39.373Z
Fuzzybear
<p><code>66f4dec6ab29cd056ce1814c6fdfee05e1524b36</code> is not a valid Bitcoin address.</p>
<p>Valid Bitcoin addresses on mainnet start with a <code>1</code> (P2PKH), <code>3</code> (P2SH), or <code>bc1</code> (segwit).</p>
<p>On testnet, the addresses start with <code>m</code> or <code>n</code> (P2PKH), <code>2</code> (P2SH), or <code>tb1</code> (segwit).</p>

CC BY-SA 4.0
2021-12-28T10:12:59.527Z
2021-12-28T10:12:59.527Z
meshcollider
<p>after init wallet</p>
<pre><code>$wallet = $client-&gt;initWallet(&quot;WALLET&quot;, &quot;PASS&quot;);
</code></pre>
<p>You can force a fee. I don't know if that will serve you.</p>
<pre><code>$fee = 0.0001;

$wallet-&gt;pay(array(&quot;address&quot; =&gt; BlocktrailSDK::toSatoshi(0.00200000)), null, false, false, Wallet::FEE_STRATEGY_FORCE_FEE, BlocktrailSDK::toSatoshi($fee));
</code></pre>

CC BY-SA 4.0
2021-11-28T09:58:30.370Z
2021-11-28T09:58:30.370Z
Jean Kássio
<p>I want to calculate the fees of a blocktrail transaction with blocktrail SDK, before making the transaction, in order to let the recipient pay fees.</p>
<p>Here is what I tried:</p>
<pre><code>$FEES = $wallet-&gt;coinSelection(\Blocktrail\SDK\Wallet::normalizeOutputsStruct(['66f4dec6ab29cd056ce1814c6fdfee05e1524b36' =&gt;'100000']),false,false,\Blocktrail\SDK\Wallet::FEE_STRATEGY_LOW_PRIORITY;
echo &quot;$FEES&quot;;
$fee = $FEES['fee'];
echo &quot;$fee&quot;;
</code></pre>
<p>But this don't work, it says this: <code>Fatal error: Uncaught Blocktrail\SDK\Exceptions\BlocktrailSDKException: Address not recognized</code></p>
<p>How can I fix this error?</p>

<api><php><blocktrail>
Calculate fees with Blocktrail/btc.com SDK
user10148040
# Calculate fees with Blocktrail/btc.com SDK

(Asked by: username_0 on 2018-07-29)

I want to calculate the fees of a blocktrail transaction with blocktrail SDK, before making the transaction, in order to let the recipient pay fees.

Here is what I tried:

```
$FEES = $wallet->coinSelection(\Blocktrail\SDK\Wallet::normalizeOutputsStruct(['66f4dec6ab29cd056ce1814c6fdfee05e1524b36' =>'100000']),false,false,\Blocktrail\SDK\Wallet::FEE_STRATEGY_LOW_PRIORITY;
echo "$FEES";
$fee = $FEES['fee'];
echo "$fee";

```

But this don't work, it says this: `Fatal error: Uncaught Blocktrail\SDK\Exceptions\BlocktrailSDKException: Address not recognized`

How can I fix this error?

**Tags:** api, php, blocktrail


---

## 3 answers

### Answer by username_1 on 2018-07-29. Score: 1

I am not sure as have not used their api system but it could be down to the format of your bitcoin address you are passing in.

`66f4dec6ab29cd056ce1814c6fdfee05e1524b36` is read as a valid bitcoin address using [this service](https://thomas.vanhoutte.be/tools/validate-bitcoin-address.php?address=66f4dec6ab29cd056ce1814c6fdfee05e1524b36&submit=)

However when I [search that address under a block explorer](https://www.blockchain.com/btc/address/1APPGSyMsPaBUAHtjEm6tPqV9U54JRzmd6) I get the following address which starts with the more common 1 `1APPGSyMsPaBUAHtjEm6tPqV9U54JRzmd6`

66f is not a start of a bitcoin address i recognise, though there are many out but [no mention on the wiki](https://en.bitcoin.it/wiki/List_of_address_prefixes)

Thus I would suggest trying your code with the more common bitcoin address format

```
$FEES = $wallet->coinSelection(\Blocktrail\SDK\Wallet::normalizeOutputsStruct(['1APPGSyMsPaBUAHtjEm6tPqV9U54JRzmd6' =>'100000']),false,false,\Blocktrail\SDK\Wallet::FEE_STRATEGY_LOW_PRIORITY['fee'];
echo "$FEES";

```

And see if that works

> **Comments:**
> **username_0**: Thanks for reply, but it still don't work, same error  
> **username_1**: hmm One thing I would want to verify next would be that the `coinSelection` part of your code is definitely choosing bitcoin?  
> **username_0**: Yes, it is bitcoin, the only thing is that I'm using the bitcoin testnet, that I have initialized before, $client = new BlocktrailSDK("api", "api", "BTC", true);  
> **username_0**: 66f4dec6ab29cd056ce1814c6fdfee05e1524b36  is a bitcoin test net address  
> **username_1**: might be you need to specify the testnet on the fee transaction as well... what are the `false,false` parts submitted after the address? though i would have expected that to have worked with the bitcoin address starting with the 1. So not sure, have you tried speaking directly to their support?  

---

### Answer by username_2 on 2021-12-28. Score: 1

`66f4dec6ab29cd056ce1814c6fdfee05e1524b36` is not a valid Bitcoin address.

Valid Bitcoin addresses on mainnet start with a `1` (P2PKH), `3` (P2SH), or `bc1` (segwit).

On testnet, the addresses start with `m` or `n` (P2PKH), `2` (P2SH), or `tb1` (segwit).


---

### Answer by username_3 on 2021-11-28. Score: 0

after init wallet

```
$wallet = $client->initWallet("WALLET", "PASS");

```

You can force a fee. I don't know if that will serve you.

```
$fee = 0.0001;

$wallet->pay(array("address" => BlocktrailSDK::toSatoshi(0.00200000)), null, false, false, Wallet::FEE_STRATEGY_FORCE_FEE, BlocktrailSDK::toSatoshi($fee));

```


---

