summaryrefslogtreecommitdiff
path: root/bip-0015.mediawiki
diff options
context:
space:
mode:
authorPeter Todd <pete@petertodd.org>2013-10-21 02:18:47 -0400
committerPeter Todd <pete@petertodd.org>2013-10-21 02:18:47 -0400
commitd9e890a8f27e46806238e298a346397871fd7e87 (patch)
tree522a1bc5c5e064df296ac2142cf9ed573b57c706 /bip-0015.mediawiki
parent3b0e74507e865d6a847aed71790bf1fb72cbc5f1 (diff)
Fix formatting
Diffstat (limited to 'bip-0015.mediawiki')
-rw-r--r--bip-0015.mediawiki60
1 files changed, 29 insertions, 31 deletions
diff --git a/bip-0015.mediawiki b/bip-0015.mediawiki
index 9750c8b..1ec6f12 100644
--- a/bip-0015.mediawiki
+++ b/bip-0015.mediawiki
@@ -1,15 +1,13 @@
-{{bip}}
-
<pre>
BIP: 15
Title: BIP Aliases
Author: Amir Taaki <genjix@riseup.net>
- Status: Deferred
+ Status: Deferred
Type: Standards Track
Created: 10-12-2011
</pre>
-[[BIP 0070]] (payment protocol) may be seen as the alternative to Aliases.
+[[bip-0070.mediawiki|BIP 0070]] (payment protocol) may be seen as the alternative to Aliases.
Using vanilla bitcoin, to send funds to a destination, an address in the form 1Hd44nkJfNAcPJeZyrGC5sKJS1TzgmCTjjZ is needed. The problem with using addresses is they are not easy to remember. An analogy can be thought if one were required to enter the IP address of their favourite websites if domain names did not exist.
@@ -97,7 +95,7 @@ It also scales reasonably- anybody wishing to run a naming service can attach a
A naive implementation is provided below as an example.
-<source lang="cpp">
+<pre>
// resolv.h
#ifndef NOMRESOLV_H__
#define NOMRESOLV_H__
@@ -151,7 +149,7 @@ private:
bool Perform();
// CURL error message
- char pErrorBuffer[CURL_ERROR_SIZE];
+ char pErrorBuffer[CURL_ERROR_SIZE];
// CURL response
string strBuffer;
// CURL handle
@@ -159,9 +157,9 @@ private:
};
#endif
-</source>
+</pre>
-<source lang="cpp">
+<pre>
// resolv.cpp
#include "resolv.h"
@@ -170,16 +168,16 @@ private:
#include "access.h"
// callback used to write response from the server
-static int writer(char *pData, size_t nSize, size_t nNmemb, std::string *pBuffer)
-{
- int nResult = 0;
- if (pBuffer != NULL)
- {
- pBuffer->append(pData, nSize * nNmemb);
- // How much did we write?
- nResult = nSize * nNmemb;
- }
- return nResult;
+static int writer(char *pData, size_t nSize, size_t nNmemb, std::string *pBuffer)
+{
+ int nResult = 0;
+ if (pBuffer != NULL)
+ {
+ pBuffer->append(pData, nSize * nNmemb);
+ // How much did we write?
+ nResult = nSize * nNmemb;
+ }
+ return nResult;
}
NameResolutionService::NameResolutionService()
@@ -187,17 +185,17 @@ NameResolutionService::NameResolutionService()
// Initialise CURL with our various options.
curl = curl_easy_init();
// This goes first in case of any problems below. We get an error message.
- curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, pErrorBuffer);
+ curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, pErrorBuffer);
// fail when server sends >= 404
- curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
- curl_easy_setopt(curl, CURLOPT_HEADER, 0);
- curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
+ curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
+ curl_easy_setopt(curl, CURLOPT_HEADER, 0);
+ curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(curl, CURLOPT_POSTREDIR, CURL_REDIR_POST_302);
- curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writer);
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writer);
curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_TRY);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1);
// server response goes in strBuffer
- curl_easy_setopt(curl, CURLOPT_WRITEDATA, &strBuffer);
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, &strBuffer);
pErrorBuffer[0] = '\0';
}
NameResolutionService::~NameResolutionService()
@@ -215,7 +213,7 @@ void NameResolutionService::ExplodeHandle(const string& strHandle, string& strNi
bool NameResolutionService::Perform()
{
// Called after everything has been setup. This actually does the request.
- CURLcode result = curl_easy_perform(curl);
+ CURLcode result = curl_easy_perform(curl);
return (result == CURLE_OK);
}
@@ -235,7 +233,7 @@ string NameResolutionService::FetchAddress(const string& strHandle, string& strA
// construct url for GET request
string strRequestUrl = strDomain + "/bitcoin-alias/?handle=" + pszEncodedNick;
// Pass URL to CURL
- curl_easy_setopt(curl, CURLOPT_URL, strRequestUrl.c_str());
+ curl_easy_setopt(curl, CURLOPT_URL, strRequestUrl.c_str());
if (!Perform())
return pErrorBuffer;
// Server should respond with a JSON that has the address in.
@@ -279,7 +277,7 @@ const Object CheckMaybeThrow(const string& strJsonIn)
// Now check for a key called "error"
const Value& error = find_value(request, "error");
// It's an error JSON! so propagate the error.
- if (error.type() != null_type)
+ if (error.type() != null_type)
throw JSONRPCError(-4, error.get_str());
// Return JSON object
return request;
@@ -290,7 +288,7 @@ const string CollectAddress(const string& strIn)
// If the handle does not have an @ in it, then it's a normal base58 bitcoin address
if (strIn.find('@') == (size_t)-1)
return strIn;
-
+
// Open the lookup service
NameResolutionService ns;
// We established that the input string is not a BTC address, so we use it as a handle now.
@@ -314,7 +312,7 @@ Value rpc_send(const Array& params, bool fHelp)
throw runtime_error(
"send <name@domain or address> <amount>\n"
"<amount> is a real and is rounded to the nearest 0.01");
-
+
// Intelligent function which looks up address given handle, or returns address
string strAddy = CollectAddress(params[0].get_str());
int64 nAmount = AmountFromValue(params[1]);
@@ -327,7 +325,7 @@ Value rpc_send(const Array& params, bool fHelp)
}
...
-</source>
+</pre>
=== IP Transactions ===
@@ -369,7 +367,7 @@ Two examples are presented below. The first shows a simpler format, while the se
'''More possibilities :'''
-* Allow to securely use '''unsecured channels'''
+* Allow to securely use '''unsecured channels'''
You can put an url and a bitcoin address that will be used to sign the result. It means that a query to this url will return a bitcoin address and a signature. Bitcoin can then check (with the verify_message function) that the returned address has not been replaced by another one.
$ namecoind name_show id/khal
{