The @ is replaced with a dot (.) and _btc. is prepended to the question, which is resolved or an error thrown
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]);
...