Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To add bip122.md #3

Merged
merged 9 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions bip122/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
namespace-identifier: bip122
title: BIP122 Namespace
author: Simon Warta (@webmaster128), ligi <ligi@ligi.de>, Pedro Gomes (@pedrouid)
status: Draft
type: Informational
created: 2019-12-05
updated: 2022-03-27
replaces: CAIP-4
---

# Namespace for BIP122 chains

This document describes the syntax and structure of the [BIP122][] namespace,
which formalized a URI scheme for references on Bitcoin-based networks that
conform to the convention, abstracting out specifics of block explorer
interfaces.

## Context

[BIP122][] is a draft specification from the Bitcoin improvement process from
2015 which has achieved wide adoption. It defines a `blockchain://` URI scheme,
although it has not, to date, been registered with IANA. Note: an IANA
registration has been
[proposed](https://www.iana.org/assignments/uri-schemes/prov/bitcoin) for
`bitcoin://` URIs, based on the older, and less chain-agnostic [BIP21][].

## References

- [BIP13][]: Bitcoin Improvement Proposal specifying "Script Hash" addresses
- [BIP21][]: Bitcoin Improvement Proposal specifying `bitcoin` URI scheme
- [BIP122][]: Bitcoin Improvement Proposal specifying `blockchain` URI scheme

[BIP13]: https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki
[BIP21]: https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki
[BIP122]: https://github.com/bitcoin/bips/blob/master/bip-0122.mediawiki
[CAIP-2]: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-2.md
[CAIP-10]: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-10.md
[CAIP-19]: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-19.md
[CAIP-21]: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-21.md
[CAIP-22]: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-22.md

## Rights

Copyright and related rights waived via CC0.
65 changes: 65 additions & 0 deletions bip122/caip10.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
namespace-identifier: bip122-caip10
title: BIP122 Namespace - Addresses
author: Simon Warta (@webmaster128), ligi <ligi@ligi.de>, Pedro Gomes (@pedrouid)
discussions-to: https://github.com/ChainAgnostic/namespaces/pulls/3
status: Draft
type: Standard
created: 2019-12-05
updated: 2022-03-27
requires: CAIP-2, CAIP-10
replaces: CAIP-4
---

# CAIP-10

*For context, see the [CAIP-10][] specification.*

## Rationale

While Ethereum "accounts" were the unstated norm in the definition of
[CAIP-10][], the "script hashes" addressing schemed defined by [BIP13][] map
well enough to "account"-model blockchains that these can be described by a
CAIP-10 reference.

## Syntax

See [Specification section of BIP13](https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki#Specification).

### Backwards Compatibility

Previously, the legacy CAIP-10 schema was defined by appending as suffix the
CAIP-2 chainId delimited by the at sign (@)

#### Legacy example

`128Lkh3S7CkDTBZ8W7BbpsN3YYizJMp8p6@bip122:000000000019d6689c085ae165831e93`

## Test Cases

```
# Bitcoin mainnet
bip122:000000000019d6689c085ae165831e93:128Lkh3S7CkDTBZ8W7BbpsN3YYizJMp8p6

# Litecoin
bip122:12a765e31ffd4059bada1e25190f6e98:128Lkh3S7CkDTBZ8W7BbpsN3YYizJMp8p6
```

## References

- [BIP13][]: Bitcoin Improvement Proposal specifying "Script Hash" addresses
- [BIP21][]: Bitcoin Improvement Proposal specifying `bitcoin` URI scheme
- [BIP122][]: Bitcoin Improvement Proposal specifying `blockchain` URI scheme

[BIP13]: https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki
[BIP21]: https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki
[BIP122]: https://github.com/bitcoin/bips/blob/master/bip-0122.mediawiki
[CAIP-2]: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-2.md
[CAIP-10]: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-10.md
[CAIP-19]: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-19.md
[CAIP-21]: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-21.md
[CAIP-22]: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-22.md

## Rights

Copyright and related rights waived via CC0.
87 changes: 87 additions & 0 deletions bip122/caip2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
namespace-identifier: bip122-caip2
title: BIP122 Namespace - Chains
author: Simon Warta (@webmaster128), ligi <ligi@ligi.de>, Pedro Gomes (@pedrouid)
discussions-to: https://github.com/ChainAgnostic/namespaces/pulls/3
status: Draft
type: Standard
created: 2019-12-05
updated: 2022-03-27
requires: CAIP-2
replaces: CAIP-4
---

# CAIP-2

*For context, see the [CAIP-2][] specification.*

## Rationale

The chain ID identifiers for BIP122 are specified in [BIP122's chain ID
definition](https://github.com/bitcoin/bips/blob/master/bip-0122.mediawiki#definition-of-chain-id).

## Syntax

The syntax for BIP122 chain ID can be summarized as a 32-character prefix from
the hash of the genesis block of a given chain, in lowercase hex
representation.

### Resolution Method

To query for a Chain ID to represent or checksum a BIP122 reference, make a
JSON-RPC request to the blockchain node with method `getblockhash`, for example:

```jsonc
// Request
{
"id": 1,
"jsonrpc": "2.0",
"method": "getblockhash",
"params": [0]
}

// Response
{
"id": 1,
"jsonrpc": "2.0",
"result": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
}
```

The response will return as a result value the hash for the block with height 0
that should be sliced to its first 16 bytes (32 characters for base 16) to be
compatible with the reference syntax defined above.

## Test Cases

This is a list of manually composed examples:

```
# Bitcoin mainnet (see [chain ID section of BIP122](https://github.com/bitcoin/bips/blob/master/bip-0122.mediawiki#definition-of-chain-id))
bip122:000000000019d6689c085ae165831e93

# Litecoin
bip122:12a765e31ffd4059bada1e25190f6e98

# Feathercoin (Litecoin fork)
bip122:fdbe99b90c90bae7505796461471d89a
```

## References

- [BIP13][]: Bitcoin Improvement Proposal specifying "Script Hash" addresses
- [BIP21][]: Bitcoin Improvement Proposal specifying `bitcoin` URI scheme
- [BIP122][]: Bitcoin Improvement Proposal specifying `blockchain` URI scheme

[BIP13]: https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki
[BIP21]: https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki
[BIP122]: https://github.com/bitcoin/bips/blob/master/bip-0122.mediawiki
[CAIP-2]: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-2.md
[CAIP-10]: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-10.md
[CAIP-19]: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-19.md
[CAIP-21]: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-21.md
[CAIP-22]: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-22.md

## Rights

Copyright and related rights waived via CC0.