1

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

2 Answers 2

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

0

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')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.