<p>The correct netcode must be given in the bitcoin_address function if it differs from the default bitcoin network.</p>

<pre><code>tx_out.bitcoin_address(netcode='XTN')
</code></pre>

CC BY-SA 3.0
2015-05-16T18:00:29.213Z
2015-05-16T18:00:29.213Z
Fabian Barkhau
<p>The library is assuming you are using main network Bitcoin, so it prints addresses that start with 1. You need to tell the library you are using that you're in testnet mode. </p>

<p>This seems to be the relevant file: <a href="https://github.com/richardkiss/pycoin/blob/master/pycoin/networks.py" rel="nofollow">https://github.com/richardkiss/pycoin/blob/master/pycoin/networks.py</a></p>

CC BY-SA 3.0
2015-05-15T17:03:55.300Z
2015-05-15T17:03:55.300Z
morsecoder
<p>I am using pycoin version 0.52 from pypi and it is getting the wrong output address from a transaction.</p>

<p>Code</p>

<pre><code># testnet txid and corresponding rawtx
# see https://test-insight.bitpay.com/tx/e20af2349c48774eddda161b74659e3e64ad0f62794df9a2271e6baa313796f2
txid = "e20af2349c48774eddda161b74659e3e64ad0f62794df9a2271e6baa313796f2"
rawtx = "010000000120addc4fc706417fad4158b4b9e30f9289e7dac4918277dc189e03f9a0155064000000006b483045022100b49bae1352d24d9673396bb01a23da583e01c5226347be6cf0f75477cce7f628022062eeb7a5a9b87a97f834660ce417278d4889d525e7e0f947020efdda045d54530121028895b78ad435814caecbeeb43453e4881a96d32c23d61b909dee06ad44c07ad5ffffffff0273a139c3000000001976a914a6d608497ad283ca93c1bdc3abb0a610b8edb18988ac80a81201000000001976a914f4131906b10615a61af347c56f1223ddc214f95c88ac00000000"

from pycoin.tx.Tx import Tx

tx = Tx.tx_from_hex(rawtx)
out = tx.txs_out[1]

print "expected", "n3mW3o8XNMyH6xHWBkN98rm7zxxxswzpGM"
print "actually", out.bitcoin_address()
</code></pre>

<p>Output</p>

<pre><code>$ python test.py
expected n3mW3o8XNMyH6xHWBkN98rm7zxxxswzpGM
actually 1PFYkk3YZLY2KqotUBPmJwYo8yNFz3Nxyy
</code></pre>

<transactions><address><output>
Why is pycoin getting the incorrect output address?
Fabian Barkhau
# Why is pycoin getting the incorrect output address?

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

I am using pycoin version 0.52 from pypi and it is getting the wrong output address from a transaction.
Code
# testnet txid and corresponding rawtx
# see https://test-insight.bitpay.com/tx/e20af2349c48774eddda161b74659e3e64ad0f62794df9a2271e6baa313796f2
txid = "e20af2349c48774eddda161b74659e3e64ad0f62794df9a2271e6baa313796f2"
rawtx = "010000000120addc4fc706417fad4158b4b9e30f9289e7dac4918277dc189e03f9a0155064000000006b483045022100b49bae1352d24d9673396bb01a23da583e01c5226347be6cf0f75477cce7f628022062eeb7a5a9b87a97f834660ce417278d4889d525e7e0f947020efdda045d54530121028895b78ad435814caecbeeb43453e4881a96d32c23d61b909dee06ad44c07ad5ffffffff0273a139c3000000001976a914a6d608497ad283ca93c1bdc3abb0a610b8edb18988ac80a81201000000001976a914f4131906b10615a61af347c56f1223ddc214f95c88ac00000000"

from pycoin.tx.Tx import Tx

tx = Tx.tx_from_hex(rawtx)
out = tx.txs_out[1]

print "expected", "n3mW3o8XNMyH6xHWBkN98rm7zxxxswzpGM"
print "actually", out.bitcoin_address()

Output
$ python test.py
expected n3mW3o8XNMyH6xHWBkN98rm7zxxxswzpGM
actually 1PFYkk3YZLY2KqotUBPmJwYo8yNFz3Nxyy

**Tags:** transactions, address, output


---

## 2 answers

### Answer by username_0 on 2015-05-16. Score: 0 | Accepted answer

The correct netcode must be given in the bitcoin_address function if it differs from the default bitcoin network.
tx_out.bitcoin_address(netcode='XTN')


---

### Answer by username_1 on 2015-05-15. Score: 2

The library is assuming you are using main network Bitcoin, so it prints addresses that start with 1. You need to tell the library you are using that you're in testnet mode.

This seems to be the relevant file: <https://github.com/richardkiss/pycoin/blob/master/pycoin/networks.py>


---

