How to receive and manipulate a bip 70 payment object in django python?

3

1

I'm trying to check to see if the variables are being set correctly by the client and being received correctly by me. I'm new to proto buffs and django and my code below doesn't seem to be working. I'm using bitcoin 0.9 I'm trying to capture a refund address.

In views:

from project import payments_pb2
def protoresponse(request):
    xpo = payments_pb2.Payment.ParseFromString(request)
    returnaddress = xpo.refund_to
    transactions = xpo.transactions
    memo = xpo.memo

    xpa = payments_pb2.PaymentACK
    xpa.payment = xpo.SerializeToString()
    xpa.memo = 'success'
    return HttpResponse(xpa.SerializeToString(), content_type="application/octet-stream")

Any pointers would be greatly appreciated :)

derrend

Posted 2014-06-10T04:13:36.740

Reputation: 606

Any information how it doesn't work is necessary for answering the question.Mikko Ohtamaa 2014-06-10T14:04:47.337

Thank you for the response :) I receive a 'forbidden access' error once I attempt to send the payment after initially opening the URI, (where to send the payment object is different to the initial URI address). Do I need to do something special to the object like def protoresponse(request, content_type="application/octet-stream")? Are there any obvious mistakes with the above code?derrend 2014-06-10T22:26:07.690

Forbidden access is not related to the code above, but is most likely related to your web server. Please study how to setup a basic single web page through Django first, see it works and then try see that your protoresponse view gets called properly.Mikko Ohtamaa 2014-06-11T07:52:18.607

It is unlikely the error is any way related to the code or the question above, unless shown otherwise.Mikko Ohtamaa 2014-06-11T07:52:45.533

will the protobuffer object come through as a request that I must deserialize - edit - and reserialize before sending back? Please can you give me an example, I cannot find any documentation or forum posts specifically on this subject which is why I am posting here. Thanks :)derrend 2014-06-11T09:46:25.143

Answers

0

I asked this same question in a simpler way without mentioning bip 70 and got the answer here.

The initial problem was that Django doesn't like people posting to your server who arent authorised so I used from django.views.decorators.csrf import csrf_exempt and the corresponding decorator @csrf_exempt as a short term work around for further debugging.

More detailed info can be found by following the link to the simplified question.

derrend

Posted 2014-06-10T04:13:36.740

Reputation: 606