<pre><code>&gt;     print bitcoin.unspent('16jn6k2FJqwrNLDpbZmmmpf4TCW7uM6LED')
</code></pre>

<p>Sovled the issue.</p>

CC BY-SA 3.0
2015-05-19T14:04:03.813Z
2015-05-19T14:04:03.813Z
Bitswim
<p>I am a beginner looking to write a simple program that takes an input (address) and prints the unspent amount in it.</p>

<p>I copied some code from chapter 4 of Mastering Bitcoin to generate a random keypair, and the last lines Andreas had in the code I copied were:</p>

<pre><code>&gt;     # Generate bitcoin address from public key
&gt;       print "Bitcoin Address (b58check) is:", bitcoin.pubkey_to_address(public_key)
&gt;     
&gt;     # Generate compressed bitcoin address from compressed public key
&gt;       print "Compressed Bitcoin Address (b58check) is:", \
&gt;           bitcoin.pubkey_to_address(hex_compressed_public_key)
</code></pre>

<p>I added the following bit at the end that prints the UTXO. It is currently printing "[ ]" because there are no UTXOs because I'm generating a new address, but it at least works when I do this and prints something.</p>

<pre><code>&gt;     #Print the UTXO for the given address     
&gt;     print bitcoin.unspent(bitcoin.pubkey_to_address(public_key))
</code></pre>

<p>However, when I type an address instead of the "(bitcoin.pubkey_to_address(public_key))", like so:</p>

<pre><code>&gt;     print bitcoin.unspent(16jn6k2FJqwrNLDpbZmmmpf4TCW7uM6LED)
</code></pre>

<p>It gives me an error ("SyntaxError: invalid syntax) and points to the "D" at the end of the address. I really want to use this specific bit of code to enable me to enter an address and have the UTXOs returned. (Please note, I just found that address on blockchain.info by clicking addresses until one with unspent coins came up! Also I am a complete novice so please go easy on me!)</p>

<p>Thanks in advance</p>

CC BY-SA 3.0
2015-05-19T14:04:14.110Z
Are you using Python 2.7? It appears you're using Python 3.4
Wizard Of Ozzie
<development><script><ubuntu><python>
How do I print unspent transaction outputs of an address using pybitcointools
Bitswim
# How do I print unspent transaction outputs of an address using pybitcointools

(Asked by: username_0 on 2015-05-19)

I am a beginner looking to write a simple program that takes an input (address) and prints the unspent amount in it.

I copied some code from chapter 4 of Mastering Bitcoin to generate a random keypair, and the last lines Andreas had in the code I copied were:

```
>     # Generate bitcoin address from public key
>       print "Bitcoin Address (b58check) is:", bitcoin.pubkey_to_address(public_key)
>     
>     # Generate compressed bitcoin address from compressed public key
>       print "Compressed Bitcoin Address (b58check) is:", \
>           bitcoin.pubkey_to_address(hex_compressed_public_key)

```

I added the following bit at the end that prints the UTXO. It is currently printing "[ ]" because there are no UTXOs because I'm generating a new address, but it at least works when I do this and prints something.

```
>     #Print the UTXO for the given address     
>     print bitcoin.unspent(bitcoin.pubkey_to_address(public_key))

```

However, when I type an address instead of the "(bitcoin.pubkey\_to\_address(public\_key))", like so:

```
>     print bitcoin.unspent(16jn6k2FJqwrNLDpbZmmmpf4TCW7uM6LED)

```

It gives me an error ("SyntaxError: invalid syntax) and points to the "D" at the end of the address. I really want to use this specific bit of code to enable me to enter an address and have the UTXOs returned. (Please note, I just found that address on blockchain.info by clicking addresses until one with unspent coins came up! Also I am a complete novice so please go easy on me!)

Thanks in advance

**Tags:** development, script, ubuntu, python

> **Comments:**
> **username_1**: Are you using Python 2.7? It appears you're using Python 3.4  

---

## 1 answers

### Answer by username_0 on 2015-05-19. Score: 1

```
>     print bitcoin.unspent('16jn6k2FJqwrNLDpbZmmmpf4TCW7uM6LED')

```

Sovled the issue.


---

