How to handle return address Output field using bitcoin bip 70?

3

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

derrend

Posted 2014-06-20T06:50:29.457

Reputation: 606

Answers

1

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

derrend

Posted 2014-06-20T06:50:29.457

Reputation: 606