Skip to content

Commit a61b033

Browse files
committed
Update Readme
1 parent 59bfc69 commit a61b033

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

README.md

+11-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
## Usage
1212

13-
This crate exports a `script!` macro which can be used to build Bitcoin scripts. The macro returns the [`Script`](https://docs.rs/bitcoin/0.23.0/bitcoin/blockdata/script/struct.Script.html) type from the [`bitcoin`](https://github.com/rust-bitcoin/rust-bitcoin) crate.
13+
This crate exports a `script!` macro which can be used to build Bitcoin scripts. The macro returns the [`Script`](https://docs.rs/bitcoin/latest/bitcoin/struct.ScriptBuf.html) type from the [`bitcoin`](https://github.com/rust-bitcoin/rust-bitcoin) crate.
1414

1515
**Example:**
1616

@@ -30,11 +30,9 @@ let htlc_script = script! {
3030
};
3131
```
3232

33-
**NOTE:** As of rustc 1.41, the Rust compiler prevents using procedural macros as expressions. To use this macro you'll need to be on nightly and add `#![feature(proc_macro_hygiene)]` to the root of your crate. This will be stablized in the near future, the PR can be found here: https://github.com/rust-lang/rust/pull/68717
34-
3533
### Syntax
3634

37-
Scripts are based on the standard syntax made up of opcodes, base-10 integers, or hex string literals. Additionally, Rust expressions can be interpolated in order to support dynamically capturing Rust variables or computing values (delimited by `<angle brackets>`).
35+
Scripts are based on the standard syntax made up of opcodes, base-10 integers, or hex string literals. Additionally, Rust expressions can be interpolated in order to support dynamically capturing Rust variables or computing values (delimited by `<angle brackets>` or `{curly brackets}`). The `script!` macro can be nested.
3836

3937
Whitespace is ignored - scripts can be formatted in the author's preferred style.
4038

@@ -70,13 +68,15 @@ let script = script!(
7068

7169
#### Escape Sequences
7270

73-
Dynamic Rust expressions are supported inside the script, surrounded by angle brackets. In many cases, this will just be a variable identifier, but this can also be a function call or arithmetic.
71+
Dynamic Rust expressions are supported inside the script, surrounded by angle brackets or in a code block. In many cases, this will just be a variable identifier, but this can also be a function call or arithmetic.
7472

7573
Rust expressions of the following types are supported:
7674

7775
- `i64`
7876
- `Vec<u8>`
79-
- [`bitcoin::PublicKey`](https://docs.rs/bitcoin/0.23.0/bitcoin/util/key/struct.PublicKey.html)
77+
- [`bitcoin::PublicKey`](https://docs.rs/bitcoin/latest/bitcoin/struct.PublicKey.html)
78+
- [`bitcoin::XOnlyPublicKey`](https://docs.rs/bitcoin/latest/bitcoin/struct.XOnlyPublicKey.html)
79+
- [`bitcoin::ScriptBuf`](https://docs.rs/bitcoin/latest/bitcoin/struct.ScriptBuf.html)
8080

8181
```rust
8282
let bytes = vec![1, 2, 3];
@@ -85,5 +85,10 @@ let script = script! {
8585
<bytes> OP_CHECKSIGVERIFY
8686

8787
<2016 * 5> OP_CSV
88+
89+
<script! { OP_FALSE OP_TRUE }>
8890
};
8991
```
92+
93+
### Optimality
94+
Obsolete Opcodes are automatically removed when using the `optimal_opcodes` branch. E.g. a sequence of `OP_0 OP_ROLL` will be optimized away.

0 commit comments

Comments
 (0)