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

1 Answer 1

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

Your Answer

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

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