Skip to content
Bitcoin dynamic content protocol
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md
package.json
planaria.js
planarium.js

README.md

D://

Bitcoin dynamic content protocol

Benefit

A D:// transaction refers to another transaction/file and thus forms a layer which state can be overwritten. This way, referencing content via D:// links (instead of b:// or c://) has the advantage of keeping the URL while the content can change.

Example B:// (can not be changed once set):
<img src="B://<TxID>"

Example D:// (content can be changed, because the state can be updated):
<img src="D://<OwnerBitcoinAddress>/<key>"

Overwrite D:// State

New transactions with the same key from a sender overwrite the previous state. The Planaria API always outputs only the most current state. The owner/key combination prevents an unauthorised person from changing the state.

Protocol

The sender of the transaction will always be an "owner" of the state = first input address will be able to change the state again.

D:// transactions comes in 2 variants.

External reference

A D:// transaction with external reference is formatted like:

OP_RETURN
  19iG3WTYSsbyos3uJ733yK4zEioi1FesNU
  [key]
  [value]
  [type]
  [sequence]
  • key must have one of the following values:

    • NULL
    • An utf-8 encoded string no longer than 1024 bytes not starting with / and not including the chars [\x00-\x1F\x7F?#]. It is suggested to simulate a folder like structure in a URI styled manner. Even if (almost) all utf8 chars are allowed it is not to be considered an IRI as key must be url-escaped to become a valid URI whenever presented to a user. Only using [a-zA-Z0-9_~/@!$&*+,.:;=-] is therefore advisable.
  • value must have one of the following values:

    • NULL
    • a string utf8 encoded string no longer than 2086 bytes.
  • type must have one of the following values:

    • NULL
    • the string c indicating that value contains the sha256 hash of the targeted content
    • the string b indicating that value contains the transaction ID of a b:// formatted transaction. For internal references type must be set to the string b indicating that target transaction is a b:// formatted transaction.
    • the string tx to indicate that value contains the transaction ID of a transaction
    • The string txt indicating that value contains the full content of the latest state.
  • sequence must have one of the following values:

    • An integer larger than 0 and smaller than 2^53-1. Everything that is not a number or a negative number is considered to be 1. Used to indicate the order of events if multiple updates are provided in the same block to the same key from the same owner.

Example:

OP_RETURN
  19iG3WTYSsbyos3uJ733yK4zEioi1FesNU
  "zebra.jpeg"
  0f9e7b6542eba739bd407323f58d75327dd1d68a53d2a535337a4dcf0ddb0edc
  tx
  1

Internal reference

A D:// transaction with internal reference is piped directly on to a B:// formatted structure (with mandatory fields for encoding and filename). type must always be b and value field will always be ignored.

OP_RETURN
  19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut
  [DATA]
  [MEDIA TYPE]
  [ENCODING] or NULL
  [FILENAME] or NULL
  |
  19iG3WTYSsbyos3uJ733yK4zEioi1FesNU
  [key]
  NULL
  b
  [sequence]

Explicit owner

Both transactions with internal and external references can add an explicit owner by piping the AIP protocol that signs all previous fields (API_ALL).

Example A:

OP_RETURN
  19iG3WTYSsbyos3uJ733yK4zEioi1FesNU
  [key]
  [value]
  [type]
  [sequence]
  |
  15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva
  [Signing Algorithm]
  [Signing Address]
  [Signature]

Example B:

OP_RETURN
  19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut
  [DATA]
  [MEDIA TYPE]
  [ENCODING] or NULL
  [FILENAME] or NULL
  |
  19iG3WTYSsbyos3uJ733yK4zEioi1FesNU
  [key]
  NULL
  b
  [sequence]
  |
  15PciHG22SNLQJXMoSUaWVi7WSqc7hCfva
  [Signing Algorithm]
  [Signing Address]
  [Signature]

If a transaction includes a valid AIP signature and the signature involves all previous fields (AIP_ALL) both the sender and AIP signing address will create an updated state for key. Effectively this means that you will be able to access the content with both D://<tx sender address>/<key> and D://<AIP signing address>/<key>.

Delete

A key is "removed" by updating the key with a type value set to NULL (0x00). The state of the planaria will provide the string deleted as "type" when a key is removed.

Example:

OP_RETURN
  19iG3WTYSsbyos3uJ733yK4zEioi1FesNU
  [key]
  NULL
  NULL
  1

Example Tx

This is an example Website with D:// link in it: https://bico.media/0363e9addc3f5de6587b250a07c4bab00f58f54cf780aa5f0f4655a8d3e4cfa5

The image is mapped like

<img src="D://19iG3WTYSsbyos3uJ733yK4zEioi1FesNU/der_wolf_und_die_sieben_geislein.jpeg">` 
  ==> C://c808b8aa7bf72a0732d1a366d530b6ad3cdea1f25cbe075ca075dc1f55006e5e 
    ==> B://efb301edd3a8b2270aea61cdc46bd923130a8c05245f763ff3c3c8fea1f0fc27

State machine D:// tx: https://whatsonchain.com/tx/329eacb2d1ab8770ac01d2daa13a852d72282379ea26caca1729817315fb12b0

State machine Query: https://d.onchain.ch/query/1G3BpTyEK6xF4LaQTHqdFBBaVxYHZzts4M/ewogICJ2IjogMywKICAicSI6IHsKICAgICJmaW5kIjogewogICAgICAic2VuZGVyIjoiMTlpRzNXVFlTc2J5b3MzdUo3MzN5SzR6RWlvaTFGZXNOVSIsCiAgICAgICJhbGlhcyI6ImRlcl93b2xmX3VuZF9kaWVfc2llYmVuX2dlaXNsZWluLmpwZWciCiAgICB9LAogICAgImxpbWl0IjogMTAwCiAgfSwKICAiciI6IHsKICAgICJmIjogIlsuW10gfCB7IHRyYW5zYWN0aW9uOiAudHhpZCwgYmxvY2s6IC5ibGsuaSwgc2VuZGVyOiAuc2VuZGVyICwgYWxpYXM6IC5hbGlhcywgcG9pbnRlcjogLnBvaW50ZXIsY250OiAuY250LCB0eXBlOiAudHlwZSAsIHNlcTogLnNlcSAsIFwiVVJJIG92ZXIgaHR0cHNcIjogKGlmIC50eXBlID09IFwiY1wiIHRoZW4gXCJodHRwczovL2RhdGEuYml0ZGIubmV0d29yay8xS3VVcjJwU0pEYW85N1hNOEpzcTh6d0xTNlcxV3RGZkxnL2MvXFwoLnBvaW50ZXIpXCIgZWxzZSBcImh0dHBzOi8vYi5iaXRkYi5uZXR3b3JrI1xcKC5wb2ludGVyKVwiIGVuZCl9XSIKICB9Cn0=

Referencing

A D:// transaction is referenced by D://<OwnerBitcoinAddress>/<key> or bit://19iG3WTYSsbyos3uJ733yK4zEioi1FesNU/<OwnerBitcoinAddress>/<key>

  • Key must always be presented as a URL encoded string

  • In case the key is NULL no key is to be provided

  • In case no key is provided the / is optional

  • In case no key is provided, the content will tentatively be derived from the first of the following keys with an existing and none-deleted d:// transaction:

    1. The key of NULL value (0x00)
    2. The key index.html
    3. The key index.htm

Links

Future ideas

  • An API that resolves D:// links to txids or an API that returns even the file data can be built.
  • Get a list of "files" in a directory (find all current tx with a key that starts with xyz/ for a specific owner)
  • Multiple signatures to share control
  • X out of N signatures to share control
  • Support D:// piped on any type of transaction

D:// was born as a brainchild of SH and @rangelWulff

You can’t perform that action at this time.