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

Revise guide after mainnet walkthrough #968

Merged
merged 9 commits into from
Dec 14, 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
81 changes: 66 additions & 15 deletions docs/src/guides/inscriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ individual satoshis using ordinal theory.
Bitcoin Core provides both a Bitcoin full node and wallet. However, the Bitcoin
Core wallet cannot make ordinal-aware transactions. Making ordinal-aware
transactions requires [`ord`](https://github.com/casey/ord), the ordinal theory
utility. `ord wallet` subcommands interact with an existing Bitcoin Core
wallet.
utility. `ord` doesn't implement its own wallet, so `ord wallet` subcommands
interact with an existing Bitcoin Core wallet.

This guide covers:

Expand Down Expand Up @@ -73,10 +73,22 @@ Syncing the Bitcoin Blockchain
Once Bitcoin Core has been configured to use signet, you'll need to sync the
blockchain. Signet is a low-volume test network, so this shouldn't take long.

To sync the chain, run `bitcoind -signet -txindex` and leave it running until
`bitcoin-cli -signet getblockcount` agrees with the block count on a block
explorer like [the mempool.space signet block
explorer](https://mempool.space/signet).
To sync the chain, run:

```
bitcoind -signet -txindex
```

…and leave it running until `getblockchount`:

```
bitcoin-cli -signet getblockcount
```

agrees with the block count on a block explorer like [the mempool.space signet
block explorer](https://mempool.space/signet). `ord` interacts with `bitcoind`,
so you should leave `bitcoind` running in the background when you're using
`ord`.

Creating a Bitcoin Core Wallet
------------------------------
Expand All @@ -90,7 +102,7 @@ unintentionally using the `ord` utility with non-ordinal Bitcoin wallets.
To create a Bitcoin Core wallet named `ord` for use with `ord`, run:

```
ord --chain signet wallet create
ord --signet wallet create
```

This is equivalent to running:
Expand All @@ -110,6 +122,32 @@ wallet if you just created it. Otherwise, run:
bitcoin-cli -signet loadwallet ord
```

Once your wallet is loaded, you should be able to run:

```
ord --signet wallet receive
```

…and get a fresh receive address.

If you get an error message like:

```
error: JSON-RPC error: RPC error response: RpcError { code: -19, message: "Wallet file not specified (must request wallet RPC through /wallet/<filename> uri-path).", data: None }
```

This means that `bitcoind` has more than one wallet loaded. List loaded wallets with:

```
bitcoin-cli -signet listwallets
```

And unload all wallets other than `ord`:

```
bitcoin-cli -signet unloadwallet foo
```

Installing `ord`
----------------

Expand All @@ -123,23 +161,36 @@ You can install the latest pre-built binary from the command line with:
curl --proto '=https' --tlsv1.2 -fsLS https://ordinals.com/install.sh | bash -s
```

Once `ord` is installed, you should be able to run `ord --version` on the
command line.
Once `ord` is installed, you should be able to run:

```
ord --version
```

Which prints out `ord`'s version number.

Receiving Satoshis
------------------

Inscriptions are made on individual satoshis, using normal Bitcoin transactions
that pay fees in satoshis, so your wallet will need some sats.

Get a new address from your `ord` wallet by running `ord --signet wallet
receive`
Get a new address from your `ord` wallet by running:

```
ord --signet wallet receive
```

Use a signet faucet to send satoshis to the address you generated. Two faucets
you might try are [signet.bc-2.jp](https://signet.bc-2.jp/) and
[alt.signetfaucet.com](https://alt.signetfaucet.com/).

You can see pending transactions with `ord --chain signet walet transactions`.
You can see pending transactions with:

```
ord --signet wallet transactions
```

Once the faucet transaction confirms, you should be able to see the
transactions outputs with `ord --signet wallet utxos`.

Expand All @@ -153,7 +204,7 @@ explorer are currently limited to `.png` and `.txt` files.

Additionally, inscriptions made on signet must be 1024 bytes or less, to avoid
congesting signet for other users. Inscriptions are stored in Taproot input
witnesses, so mainnet inscriptions will only be limited by the depths of your
witnesses, so mainnet inscriptions will be limited only by the depths of your
pockets and the 4,000,000 byte witness size limit.

Creating Inscriptions
Expand Down Expand Up @@ -205,7 +256,7 @@ ord --signet wallet send INSCRIPTION_ID ADDRESS

See the pending transaction with:
```
ord --chain signet wallet transactions
ord --signet wallet transactions
```

Once the send transaction confirms, the recipient can confirm receipt by
Expand All @@ -232,7 +283,7 @@ ord --signet wallet send INSCRIPTION_ID ADDRESS

See the pending transaction with:
```
ord --chain signet wallet transactions
ord --signet wallet transactions
```

Once the send transaction confirms, you can can confirm receipt by running:
Expand Down
12 changes: 7 additions & 5 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,20 +635,22 @@ impl Server {
async fn inscription(
Extension(chain): Extension<Chain>,
Extension(index): Extension<Arc<Index>>,
Path(txid): Path<Txid>,
Path(inscription_id): Path<InscriptionId>,
) -> ServerResult<PageHtml> {
let (inscription, satpoint) = index
.get_inscription_by_inscription_id(txid)
.get_inscription_by_inscription_id(inscription_id)
.map_err(|err| {
ServerError::Internal(anyhow!(
"failed to retrieve inscription from txid {txid} from index: {err}"
"failed to retrieve inscription with inscription id {inscription_id} from index: {err}"
))
})?
.ok_or_else(|| ServerError::NotFound(format!("transaction {txid} has no inscription")))?;
.ok_or_else(|| {
ServerError::NotFound(format!("transaction {inscription_id} has no inscription"))
})?;

Ok(
InscriptionHtml {
txid,
inscription_id,
inscription,
satpoint,
}
Expand Down
20 changes: 11 additions & 9 deletions src/subcommand/server/templates/inscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ use super::*;

#[derive(Boilerplate)]
pub(crate) struct InscriptionHtml {
pub(crate) txid: Txid,
pub(crate) inscription_id: InscriptionId,
pub(crate) inscription: Inscription,
pub(crate) satpoint: SatPoint,
}

impl PageContent for InscriptionHtml {
fn title(&self) -> String {
format!("Inscription {}", self.txid)
format!("Inscription {}", self.inscription_id)
}
}

Expand All @@ -21,16 +21,18 @@ mod tests {
fn txt_inscription() {
pretty_assert_eq!(
InscriptionHtml {
txid: Txid::from_str("ec90757eb3b164aa43fc548faa2fa0c52025494f2c15d5ddf11260b4034ac6dc")
.unwrap(),
inscription_id: InscriptionId::from_str(
"ec90757eb3b164aa43fc548faa2fa0c52025494f2c15d5ddf11260b4034ac6dc"
)
.unwrap(),
inscription: inscription("text/plain;charset=utf-8", "HELLOWORLD"),
satpoint: satpoint(1, 0),
}
.to_string(),
"
<h1>Inscription</h1>
<h1>Inscription ec90757eb3b164aa43fc548faa2fa0c52025494f2c15d5ddf11260b4034ac6dc</h1>
<dl>
<dt>satpoint</dt>
<dt>location</dt>
<dd>1111111111111111111111111111111111111111111111111111111111111111:1:0</dd>
</dl>
HELLOWORLD
Expand All @@ -43,15 +45,15 @@ mod tests {
fn png_inscription() {
pretty_assert_eq!(
InscriptionHtml {
txid: Txid::from_str("ec90757eb3b164aa43fc548faa2fa0c52025494f2c15d5ddf11260b4034ac6dc").unwrap(),
inscription_id: InscriptionId::from_str("ec90757eb3b164aa43fc548faa2fa0c52025494f2c15d5ddf11260b4034ac6dc").unwrap(),
inscription: inscription("image/png", [1; 100]),
satpoint: satpoint(1, 0),
}
.to_string(),
"
<h1>Inscription</h1>
<h1>Inscription ec90757eb3b164aa43fc548faa2fa0c52025494f2c15d5ddf11260b4034ac6dc</h1>
<dl>
<dt>satpoint</dt>
<dt>location</dt>
<dd>1111111111111111111111111111111111111111111111111111111111111111:1:0</dd>
</dl>
<img src='data:image/png;base64,AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ=='>
Expand Down
4 changes: 2 additions & 2 deletions templates/inscription.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1>Inscription</h1>
<h1>Inscription {{ self.inscription_id }}</h1>
<dl>
<dt>satpoint</dt>
<dt>location</dt>
<dd>{{ self.satpoint }}</dd>
</dl>
{{ self.inscription.content_html() }}
2 changes: 2 additions & 0 deletions templates/transaction.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<h1>Transaction <span class=monospace>{{self.txid}}</span></h1>
%% if let Some(inscription) = &self.inscription {
<h2>Inscription</h2>
<a href=/inscription/{{self.txid}}>
{{ inscription.content_html() }}
</a>
%% }
<h2>{{"Output".tally(self.transaction.output.len())}}</h2>
<ul class=monospace>
Expand Down
26 changes: 15 additions & 11 deletions tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ fn inscription_page() {
rpc_server.mine_blocks(1);

TestServer::spawn_with_args(&rpc_server, &[]).assert_response_regex(
&format!("/inscription/{}", reveal_tx),
&format!("/inscription/{reveal_tx}"),
&format!(
".*<h1>Inscription</h1>
".*<h1>Inscription {reveal_tx}</h1>
<dl>
<dt>satpoint</dt>
<dt>location</dt>
<dd>{reveal_tx}:0:0</dd>
</dl>
HELLOWORLD.*",
Expand All @@ -83,9 +83,13 @@ fn inscription_appears_on_reveal_transaction_page() {

TestServer::spawn_with_args(&rpc_server, &[]).assert_response_regex(
&format!("/tx/{}", reveal_tx),
".*<h1>Transaction .*</h1>.*
&format!(
".*<h1>Transaction .*</h1>.*
<h2>Inscription</h2>
HELLOWORLD.*",
<a href=/inscription/{reveal_tx}>
HELLOWORLD
</a>.*",
),
);
}

Expand All @@ -108,11 +112,11 @@ fn inscription_page_after_send() {

let ord_server = TestServer::spawn_with_args(&rpc_server, &[]);
ord_server.assert_response_regex(
&format!("/inscription/{}", reveal_txid),
&format!("/inscription/{reveal_txid}"),
&format!(
".*<h1>Inscription</h1>
".*<h1>Inscription {reveal_txid}</h1>
<dl>
<dt>satpoint</dt>
<dt>location</dt>
<dd>{reveal_txid}:0:0</dd>
</dl>
HELLOWORLD.*",
Expand All @@ -131,11 +135,11 @@ HELLOWORLD.*",

let ord_server = TestServer::spawn_with_args(&rpc_server, &[]);
ord_server.assert_response_regex(
&format!("/inscription/{}", reveal_txid),
&format!("/inscription/{reveal_txid}"),
&format!(
".*<h1>Inscription</h1>
".*<h1>Inscription {reveal_txid}</h1>
<dl>
<dt>satpoint</dt>
<dt>location</dt>
<dd>{}:0:0</dd>
</dl>
HELLOWORLD.*",
Expand Down
12 changes: 6 additions & 6 deletions tests/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ fn send_works_on_signet() {

let ord_server = TestServer::spawn_with_args(&rpc_server, &[]);
ord_server.assert_response_regex(
&format!("/inscription/{}", reveal_txid),
&format!("/inscription/{reveal_txid}"),
&format!(
".*<h1>Inscription</h1>
".*<h1>Inscription {reveal_txid}</h1>
<dl>
<dt>satpoint</dt>
<dt>location</dt>
<dd>{send_txid}:0:0</dd>
</dl>
.*",
Expand Down Expand Up @@ -144,11 +144,11 @@ fn send_inscribed_sat() {

let ord_server = TestServer::spawn_with_args(&rpc_server, &[]);
ord_server.assert_response_regex(
&format!("/inscription/{}", reveal_txid),
&format!("/inscription/{reveal_txid}"),
&format!(
".*<h1>Inscription</h1>
".*<h1>Inscription {reveal_txid}</h1>
<dl>
<dt>satpoint</dt>
<dt>location</dt>
<dd>{send_txid}:0:0</dd>
</dl>
.*",
Expand Down