bitcoin URI is not transferred correctly over NFC

Bug #1249084 reported by Alex Kot
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
nfcpy
Fix Released
High
Unassigned

Bug Description

Hi Stephen

I'm working on some Bitcoin-related hardware device implementation that includes NFC, and what I need to do with NFC is to send bitcoin URI over it.
I've tested it with beam.py test script and found that http:// URIs work fine, but bitcoin: URI is failing. I've tried debugging it and managed to fix this, although I'm not fully understanding what was the problem, so I doubt that my code is good enough for pull request.
So what I did is this:

in beam.py:

    def run_send_link_action(args, llc):
        # sp = nfc.ndef.SmartPosterRecord(args.uri)
        # if args.title:
        # sp.title = args.title
        sp = nfc.ndef.UriRecord(args.uri)
        send_message(args, llc, nfc.ndef.Message(sp))

in uri_record.py:

    @property
    def data(self):
        # for i, p in enumerate(protocol_strings):
        # if i > 0 and self.uri.startswith(p):
        # return chr(i) + self.uri[len(p):]
        # else:
        # return "\x00"
        return "\x00"+self.uri

(commented parts are what was there before)

with this fix bitcoin URI processes fine via NFC and calls relevant application on the phone side to handle it.
You can get more data on bitcoin URI at https://en.bitcoin.it/wiki/URI_Scheme

Regards,
Alex

Revision history for this message
Stephen Tiedemann (stephen-tiedemann) wrote :

Thank you for the bug report. The actual error is where in uri_record.py the uri string is not appended to the abbreviation code 0x00 (which is for uri's with a non recognized prefix).

The modifications you did in run_send_link_action may not be necessary, a smartposter is essentially just a wrapper around the uri which allows to give it a friendly title and maybe icon to display to the user when the uri is not understood. But if a handler for the uri scheme is registered it'll usually be called straight, as seems to be the case for 'bitcoin' (guess that's when a bc wallet app is installed).

Changed in nfcpy:
status: New → Confirmed
importance: Undecided → High
assignee: nobody → Stephen Tiedemann (stephen-tiedemann)
Revision history for this message
Stephen Tiedemann (stephen-tiedemann) wrote :

fixed in trunk revision #196

Changed in nfcpy:
assignee: Stephen Tiedemann (stephen-tiedemann) → nobody
status: Confirmed → Fix Released
Revision history for this message
Alex Kot (alexykot) wrote :

yes, it works now, thanks.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.