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

Nick ODell
  • 29,184
  • 11
  • 69
  • 129
derrend
  • 696
  • 5
  • 16

1 Answers1

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
  • 696
  • 5
  • 16