summaryrefslogtreecommitdiff
path: root/bip-0020.mediawiki
diff options
context:
space:
mode:
Diffstat (limited to 'bip-0020.mediawiki')
-rw-r--r--bip-0020.mediawiki30
1 files changed, 19 insertions, 11 deletions
diff --git a/bip-0020.mediawiki b/bip-0020.mediawiki
index 3bd2605..53823e8 100644
--- a/bip-0020.mediawiki
+++ b/bip-0020.mediawiki
@@ -1,5 +1,3 @@
-{{bip}}
-
<pre>
BIP: 20
Title: URI Scheme
@@ -57,7 +55,7 @@ Graphical bitcoin clients SHOULD register themselves as the handler for the "bit
==== Transfer amount/size ====
If an amount is provided, it may be specified either in decimal or, when prefixed with a single "x" character, hexadecimal.
-The number SHOULD be followed by "X" <digits> to signify an exponent to the base multiplier.
+The number SHOULD be followed by "X" &lt;digits&gt; to signify an exponent to the base multiplier.
Thus, "X8" multiplies your number by 100,000,000.
For decimal values, this means the standard BTC unit.
For hexadecimal values, this means ᵇTBC units (which are equivalent to 42.94967296 BTC).
@@ -94,9 +92,11 @@ Make it possible for later generations to improve our work, to mend our errors,
This section is non-normative and does not cover all possible syntax.
Please see the [[#BNF grammar|BNF grammar]] above for the normative syntax.
-[foo] means optional, <bar> are placeholders
+[foo] means optional, &lt;bar&gt; are placeholders
+<pre>
bitcoin:<address>[;version=1.0][?amount=<amount>][?label=<label>][?message=<message>][?send=<private key>]
+</pre>
=== Examples ===
@@ -129,15 +129,21 @@ Characters must be URI encoded properly.
===Sending money via private key===
To send a payment to someone else first construct a new keypair. You may want to use a [[mini private key format]], or you may also use a full private key for more security depending on the amount being sent and how long you expect to pass before a claim. Now create and publish a transaction with an output of the amount you wish to send. Use this script in that output:
+<pre>
<pubkey> OP_CHECKSIG
+</pre>
Construct an address from the public key. Encode the URI as below:
+<pre>
bitcoin:<address>?send=<base 58 encoded private key>
+</pre>
-You may optionally include amount or message fields as well. In a wallet to claim money sent this way search for an incoming transaction with the output script form above, where <address> matches the public key in the script. When you find the transaction create a claim transaction with an input script of this form:
+You may optionally include amount or message fields as well. In a wallet to claim money sent this way search for an incoming transaction with the output script form above, where &lt;address&gt; matches the public key in the script. When you find the transaction create a claim transaction with an input script of this form:
+<pre>
<sig>
+</pre>
This claims the money you were sent. Until your claim transaction has confirmed the sender may take their money back.
@@ -147,6 +153,7 @@ This claims the money you were sent. Until your claim transaction has confirmed
=== Parsing amount ===
==== ECMAScript ====
+<pre>
reAmount = /^(([\d.]+)(X(\d+))?|x([\da-f]*)(\.([\da-f]*))?(X([\da-f]+))?)$/i;
function parseAmount(txt) {
var m = txt.match(reAmount);
@@ -163,8 +170,10 @@ This claims the money you were sent. Until your claim transaction has confirmed
(m[4] ? Math.pow(10, m[4]) : 1e8)
);
}
+</pre>
==== Python ====
+<pre>
m = re.match(r'^(([\d.]+)(X(\d+))?|x([\da-f]*)(\.([\da-f]*))?(X([\da-f]+))?)$', amount, re.IGNORECASE)
if m.group(5):
amount = float(int(m.group(5), 16))
@@ -180,8 +189,10 @@ This claims the money you were sent. Until your claim transaction has confirmed
amount *= 10 ** int(m.group(4))
else:
amount *= 100000000
+</pre>
==== C# ====
+<pre>
Regex amountExpression = new Regex(@"^(([\d.]+)(X(\d+))?|x([\da-f]*)(\.([\da-f]*))?(X([\da-f]+))?)$", RegexOptions.IgnoreCase);
Match match = amountExpression.Match(value);
if (match.Success)
@@ -191,11 +202,11 @@ This claims the money you were sent. Until your claim transaction has confirmed
long hexDecimal = 0;
if (match.Groups[7].Success)
hexDecimal = Convert.ToInt64(match.Groups[7].Value, 16) * (long)Math.Pow(16, -match.Groups[7].Length);
-
+
long hexExponent = 0x10000;
if (match.Groups[9].Success)
hexExponent = (long)Math.Pow(16, Convert.ToInt32(match.Groups[9].Value, 16));
-
+
Amount = (Convert.ToInt64(match.Groups[5].Value, 16) + hexDecimal) * hexExponent;
}
else
@@ -206,7 +217,4 @@ This claims the money you were sent. Until your claim transaction has confirmed
Amount = (long)(decimal.Parse(match.Groups[2].Value) * decimalExponent);
}
}
-
-[[Category:Developer]]
-[[Category:Technical]]
-[[Category:BIP|D]]
+</pre>