1
0
mirror of https://github.com/bitcoin/bips.git synced 2024-11-19 09:50:06 +01:00
bitcoin-bips/bip-0122.mediawiki

125 lines
4.4 KiB
Plaintext
Raw Normal View History

<pre>
2016-01-08 18:45:00 +01:00
BIP: 122
Title: URI scheme for Blockchain references / exploration
Author: Marco Pontello <marcopon@gmail.com>
Status: Draft
Type: Standards Track
2016-02-03 08:02:36 +01:00
Created: 2015-08-29
2016-01-02 13:59:32 +01:00
Post-History: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2015-August/010712.html
</pre>
==Abstract==
This BIP proposes a URI scheme for looking up blocks, transactions and addresses on a Blockchain explorer, or in general to make proper Blockchain references.
==Motivation==
The purpose of this URI scheme is to enable users to handle all the requests for details about blocks, transactions, etc. with their preferred tool (being that a web service or a local application).
Currently a Bitcoin client usually points to an arbitrary blockchain explorer when the user looks for the details of a transaction or allows the user to choose from a set of alternatives.
Resorting to copy + paste into a browser is often required.
The same happens with posts and messages that reference some particular txs or blocks, if they provide links at all.
==Specification==
2016-01-05 02:58:30 +01:00
The URI follow this form:
2016-01-12 16:46:52 +01:00
<nowiki>blockchain:[//<chain>]/<tx|block|address>/<hash></nowiki>
Where:
2016-01-05 02:58:30 +01:00
{| class="wikitable"
! style="text-align: center;" | Element
! colspan="2" style="text-align: center;" | Description
! Required?
2016-01-05 02:58:30 +01:00
|-
| chain
| colspan="2" | '''chain ID''' (see below) of the desired chain, leading 0s included. If omitted (which would be the usual case), Bitcoin main net is assumed.
| optional
|-
| rowspan="3" | type
| tx
| for transactions.
| rowspan="3" | required
2016-01-05 02:58:30 +01:00
|-
| block
| for blocks (supports both hash or height).
|-
| address
| for addresses.
|-
| hash
| colspan="2" | the relevant hash to refer to (leading zeros included), or block height.
| required
2016-01-05 02:58:30 +01:00
|}
2016-01-12 16:46:52 +01:00
====ABNF grammar====
<pre>
blockchainuri = "blockchain:" ["//" chain] "/" object
2016-01-12 19:09:57 +01:00
object = ("tx" "/" hash) / ("block" "/" (hash / blockheight)) /
("address" "/" address)
2016-01-12 16:46:52 +01:00
chain = hash
hash = 64HEXDIG
blockheight = 1*15DIGIT ; 15 is somehow arbitrary, i.e. a "small" int.
address = base58 ; https://en.wikipedia.org/wiki/Base58
</pre>
2016-01-05 02:58:30 +01:00
----
===Definition of chain ID===
The '''chain ID''' of a chain is the block hash of the corresponding genesis block. For forked chains, it's the block hash of the first block after fork.
So, for example:
<pre>
Bitcoin main : 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
Bitcoin test : 000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943
Bitcoin regtest: 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206
</pre>
2015-11-16 00:44:34 +01:00
2016-01-05 02:58:30 +01:00
An example of forked chain (Feathercoin, that forked Litecoin):
2015-11-16 00:44:34 +01:00
2016-01-08 18:45:00 +01:00
<img src=bip-0122/chainid.png></img>
2016-01-05 02:58:30 +01:00
<pre>
Litecoin : 12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2
Feathercoin: fdbe99b90c90bae7505796461471d89ae8388ab953997aa06a355bbda8d915cb
</pre>
==Examples==
2016-01-05 02:58:30 +01:00
A transaction on Bitcoin main net:
blockchain:/tx/b462ae6eb8bdae2e060239a2a3ea5d9c3e0f9ef34d9717beb2dcf0ed42cee7da
2016-01-05 02:58:30 +01:00
A block on Bitcoin main net:
blockchain:/block/00000000000000000119af5bcae2926df54ae262e9071a94a99c913cc217cc72
or
blockchain:/block/372338
2016-01-05 02:58:30 +01:00
An address on Bitcoin main net:
blockchain:/address/16EW6Rv9P9AxFDBrZV816dD4sj1EAYUX3f
2016-01-05 02:58:30 +01:00
A transaction on Bitcoin test net:
blockchain://000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943/tx/3b95a766d7a99b87188d6875c8484cb2b310b78459b7816d4dfc3f0f7e04281a
==Rationale==
From the point of view of a wallet (or other Blockchain related tool) developers which need to reference Blockchain data, using this scheme mean that he can simply make it a `blockchain:` link without having to worry about any specific Blockchain explorer or provide a means for the user to select one.
Blockchain explorers in turn will simply offer to handle the `blockchain:` URI schema, the first time the user visit their website, or launch/install the application, or even set themselves if there isn't already one.
Users can link directly to their preferred block explorer (avoiding copy + paste which can be awkward on mobile devices).
2016-01-07 23:11:32 +01:00
== Sample implementation ==
[https://github.com/MarcoPon/blockchain-exploration Demo Blockchain: URI handler on GitHub]
2015-11-16 00:44:34 +01:00
==Acknowledgements==
Thanks to Btc Drak for suggesting support for different networks and Jorge Timon for the suggestion that we could identify each network by its genesis block hash.
Thanks to Richard Moore, Matt Whitlock, Andreas Schildbach for help with the structure and hierarchy of the URI scheme.
2015-11-16 00:44:34 +01:00
==Copyright==
2016-01-12 19:09:57 +01:00
This document is placed in the public domain.