<p>I managed it with Petrer Todds <a href="https://github.com/petertodd/python-bitcoinlib/" rel="nofollow" title="library">python-bitcoinlib</a>.</p>

<p>Link to <code>payments_pb2</code> proto file <a href="https://github.com/bitcoin/bips/blob/master/bip-0070/paymentrequest.proto" rel="nofollow" title="proto file">here</a>.</p>

<pre><code>import bitcoin

## Uncomment for testnet
#bitcoin.SelectParams('testnet')

import payments_pb2

from bitcoin.wallet import CBitcoinAddress
from bitcoin.core.script import CScript

def protoresponse(httprequest):

    ## Object
    o = payments_pb2

    ## PaymentACK object
    pao = o.PaymentACK()
    pao.payment.ParseFromString(httprequest.body)

    refund_address = CBitcoinAddress.from_scriptPubKey(CScript(pao.payment.refund_to[0].script))

    return httpresponse
</code></pre>

CC BY-SA 3.0
2014-06-26T03:16:44.590Z
2014-12-30T03:47:53.803Z
2014-12-30T03:47:53.803Z
derrend
<p>More specifically, how do I derive the return address from the Output field in a protocol buffer Payment object?</p>

<p>I can convert the serialized byte string from the 'script' field of the Output into a 25 character scriptPubKey but I'm stuck as to where to go from here?</p>

<p>Any help greatly appreciated :)</p>

<bitcoind><bip70-payment-protocol>
How to handle return address Output field using bitcoin bip 70?
derrend
# How to handle return address Output field using bitcoin bip 70?

(Asked by: username_0 on 2014-06-20)

More specifically, how do I derive the return address from the Output field in a protocol buffer Payment object?

I can convert the serialized byte string from the 'script' field of the Output into a 25 character scriptPubKey but I'm stuck as to where to go from here?

Any help greatly appreciated :)

**Tags:** bitcoind, bip70-payment-protocol


---

## 1 answers

### Answer by username_0 on 2014-06-26. Score: 1 | Accepted answer

I managed it with Petrer Todds python-bitcoinlib.
Link to payments_pb2 proto file here.
import bitcoin

## Uncomment for testnet
#bitcoin.SelectParams('testnet')

import payments_pb2

from bitcoin.wallet import CBitcoinAddress
from bitcoin.core.script import CScript

def protoresponse(httprequest):

    ## Object
    o = payments_pb2

    ## PaymentACK object
    pao = o.PaymentACK()
    pao.payment.ParseFromString(httprequest.body)

    refund_address = CBitcoinAddress.from_scriptPubKey(CScript(pao.payment.refund_to[0].script))

    return httpresponse


---

