Author

Topic: DNS Bitcoin Address (Read 700 times)

newbie
Activity: 7
Merit: 0
July 24, 2011, 06:51:14 PM
#4
example source for rpc.h to allow sendtoaddress to accept dnsnames in the form of user@domain

The @ is replaced with a dot (.) and _btc. is prepended to the question, which is resolved or an error thrown
Code:

Value sendtoaddress(const Array& params, bool fHelp)
{
...

/**
; <<>> DiG 9.7.3 <<>> _btc.rick.wesson.us txt
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43754
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;_btc.rick.wesson.us.           IN      TXT

;; ANSWER SECTION:
_btc.rick.wesson.us.    300     IN      TXT     "BTC=1; 1GCVXLfF1TcpnnDLJRHk845NZhuJWQTnUD"

;; Query time: 143 msec           
**/


    string strAddress = params[0].get_str();
    string dname="_btc.";
    if(strAddress.find("@")){
       unsigned char answer[255];
       int len=0;
       dname.append(strAddress);
       dname.replace(dname.find("@"), 1, ".");

       if((len = res_query(dname.c_str(), C_IN, T_TXT, answer, PACKETSZ)) < 0) {
         string dnsAnswer=(char*)answer;
         int i=dnsAnswer.find("BTC=1;");
         if( i < 0) throw runtime_error( dname + " is not associated with a bitcoin address");
         i += 6;
         i = dnsAnswer.find("1", 6) ; // address start with a one (1)
         dnsAnswer.erase(0,i);
         strAddress=dnsAnswer;
       }

    }
    // Amount
    int64 nAmount = AmountFromValue(params[1]);
...
newbie
Activity: 7
Merit: 0
July 24, 2011, 05:13:52 PM
#3
Its the logic that would be required to handle all the NAPTR options, then there is the difficulty of getting everyone to use them in a standard way, that would behave consistently. TXT records are easiest from a parsing standpoint.

The internet-draft for a wallet address is just a point to begin a discussion in the IETF if that is the correct route. The WA record I'm proposing could offer a generic wat to represent many virtual currencies.

My first patch to rpc.cpp is to add TXT record lookup and parsing.
hero member
Activity: 566
Merit: 500
Unselfish actions pay back better
July 24, 2011, 04:33:28 PM
#2

The second option is to use  NAPTR records but it offers less capability over TXT.

What's the reason you feel that NAPTR ‘offers less capability’?  NAPTRs are far more flexible than TXT, IMHO, although less simple to parse.

Cheers,
newbie
Activity: 7
Merit: 0
July 24, 2011, 04:19:03 PM
#1
I hosted and event at our farm and had about 20 folks come out to discuss legal and techie issues around bitcoin. We found it really difficult to exchange bitcoins and constructed an idea on a better way to get a bitcoin wallet identifier to one of our friends.

The first solution would be to use DNS TXT records to put a bitcoin address into, much as SPF records did for adding anti-spam capabilities. The second option is to use  NAPTR records but it offers less capability over TXT. My third option is to develop an internet-draft for a WA (wallet-address) record and offer it to the DNS community.

The TXT records could be something like BTC=1;
The first label defines the curency and its version, the second is the address. For the label I'm considering _btc. where name would need to be either ASCII-7 or a internationalized punycode label for UTF-8 names.

I'd really like to associate the address with a label under a domain so that sendtoaddress could leverage syntax much like sendto [email protected] which would cause the client rpc code to lookup the TXT record from _btc.rick.wesson.us and insert the resuting address into the pwalletMain->SendMoneyToBitcoinAddress (line 511 in rpc.h)

My three work items are:
  o simple internet-draft describing the WA (wallet address) record
  o patches for bitcoind and bitcoinJ
 

I believe that by leveraging wallet addresses in the DNS will allow more folks to feel comfortable by sending money to [email protected] rather than 1GCVXLfF1TcpnnDLJRHk845NZhuJWQTnUD

Looking for advise, mostly regarding how to get a patch accepted into the mainline.

-rick


Jump to: