Skip to content

Commit

Permalink
[framework] result and taproot_builder are graduate from nursery (#2423)
Browse files Browse the repository at this point in the history
  • Loading branch information
jolestar committed Aug 13, 2024
1 parent a03f867 commit 7808213
Show file tree
Hide file tree
Showing 18 changed files with 411 additions and 411 deletions.
1 change: 1 addition & 0 deletions frameworks/bitcoin-move/doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This is the reference documentation of the Bitcoin Move Framework.
- [`0x4::ord`](ord.md#0x4_ord)
- [`0x4::pending_block`](pending_block.md#0x4_pending_block)
- [`0x4::script_buf`](script_buf.md#0x4_script_buf)
- [`0x4::taproot_builder`](taproot_builder.md#0x4_taproot_builder)
- [`0x4::types`](types.md#0x4_types)
- [`0x4::utxo`](utxo.md#0x4_utxo)

Expand Down
159 changes: 159 additions & 0 deletions frameworks/bitcoin-move/doc/taproot_builder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@

<a name="0x4_taproot_builder"></a>

# Module `0x4::taproot_builder`

Taproot is a module that provides Bitcoin Taproot related functions.


- [Struct `TaprootBuilder`](#0x4_taproot_builder_TaprootBuilder)
- [Struct `NodeInfo`](#0x4_taproot_builder_NodeInfo)
- [Constants](#@Constants_0)
- [Function `new`](#0x4_taproot_builder_new)
- [Function `add_leaf`](#0x4_taproot_builder_add_leaf)
- [Function `finalize`](#0x4_taproot_builder_finalize)


<pre><code><b>use</b> <a href="">0x1::option</a>;
<b>use</b> <a href="">0x1::vector</a>;
<b>use</b> <a href="">0x2::bcs</a>;
<b>use</b> <a href="">0x2::compare</a>;
<b>use</b> <a href="">0x2::hash</a>;
<b>use</b> <a href="">0x2::result</a>;
<b>use</b> <a href="script_buf.md#0x4_script_buf">0x4::script_buf</a>;
</code></pre>



<a name="0x4_taproot_builder_TaprootBuilder"></a>

## Struct `TaprootBuilder`



<pre><code><b>struct</b> <a href="taproot_builder.md#0x4_taproot_builder_TaprootBuilder">TaprootBuilder</a> <b>has</b> drop, store
</code></pre>



<a name="0x4_taproot_builder_NodeInfo"></a>

## Struct `NodeInfo`



<pre><code><b>struct</b> <a href="taproot_builder.md#0x4_taproot_builder_NodeInfo">NodeInfo</a> <b>has</b> drop, store
</code></pre>



<a name="@Constants_0"></a>

## Constants


<a name="0x4_taproot_builder_ErrorInvalidMerkleTreeDepth"></a>



<pre><code><b>const</b> <a href="taproot_builder.md#0x4_taproot_builder_ErrorInvalidMerkleTreeDepth">ErrorInvalidMerkleTreeDepth</a>: u64 = 1;
</code></pre>



<a name="0x4_taproot_builder_ErrorNodeNotInDfsOrder"></a>



<pre><code><b>const</b> <a href="taproot_builder.md#0x4_taproot_builder_ErrorNodeNotInDfsOrder">ErrorNodeNotInDfsOrder</a>: u64 = 2;
</code></pre>



<a name="0x4_taproot_builder_ErrorOverCompleteTree"></a>



<pre><code><b>const</b> <a href="taproot_builder.md#0x4_taproot_builder_ErrorOverCompleteTree">ErrorOverCompleteTree</a>: u64 = 3;
</code></pre>



<a name="0x4_taproot_builder_ErrorUnreachable"></a>



<pre><code><b>const</b> <a href="taproot_builder.md#0x4_taproot_builder_ErrorUnreachable">ErrorUnreachable</a>: u64 = 4;
</code></pre>



<a name="0x4_taproot_builder_TAG_TAP_BRANCH"></a>



<pre><code><b>const</b> <a href="taproot_builder.md#0x4_taproot_builder_TAG_TAP_BRANCH">TAG_TAP_BRANCH</a>: <a href="">vector</a>&lt;u8&gt; = [84, 97, 112, 66, 114, 97, 110, 99, 104];
</code></pre>



<a name="0x4_taproot_builder_TAG_TAP_LEAF"></a>



<pre><code><b>const</b> <a href="taproot_builder.md#0x4_taproot_builder_TAG_TAP_LEAF">TAG_TAP_LEAF</a>: <a href="">vector</a>&lt;u8&gt; = [84, 97, 112, 76, 101, 97, 102];
</code></pre>



<a name="0x4_taproot_builder_TAPROOT_CONTROL_MAX_NODE_COUNT"></a>



<pre><code><b>const</b> <a href="taproot_builder.md#0x4_taproot_builder_TAPROOT_CONTROL_MAX_NODE_COUNT">TAPROOT_CONTROL_MAX_NODE_COUNT</a>: u64 = 128;
</code></pre>



<a name="0x4_taproot_builder_TAPROOT_LEAF_TAPSCRIPT"></a>

Tapscript leaf version.


<pre><code><b>const</b> <a href="taproot_builder.md#0x4_taproot_builder_TAPROOT_LEAF_TAPSCRIPT">TAPROOT_LEAF_TAPSCRIPT</a>: u8 = 192;
</code></pre>



<a name="0x4_taproot_builder_new"></a>

## Function `new`



<pre><code><b>public</b> <b>fun</b> <a href="taproot_builder.md#0x4_taproot_builder_new">new</a>(): <a href="taproot_builder.md#0x4_taproot_builder_TaprootBuilder">taproot_builder::TaprootBuilder</a>
</code></pre>



<a name="0x4_taproot_builder_add_leaf"></a>

## Function `add_leaf`



<pre><code><b>public</b> <b>fun</b> <a href="taproot_builder.md#0x4_taproot_builder_add_leaf">add_leaf</a>(builder: &<b>mut</b> <a href="taproot_builder.md#0x4_taproot_builder_TaprootBuilder">taproot_builder::TaprootBuilder</a>, depth: u8, <a href="script_buf.md#0x4_script_buf">script_buf</a>: <a href="script_buf.md#0x4_script_buf_ScriptBuf">script_buf::ScriptBuf</a>): &<b>mut</b> <a href="taproot_builder.md#0x4_taproot_builder_TaprootBuilder">taproot_builder::TaprootBuilder</a>
</code></pre>



<a name="0x4_taproot_builder_finalize"></a>

## Function `finalize`

Finalize the builder, return the state root,
We use the address to represent the hash.


<pre><code><b>public</b> <b>fun</b> <a href="taproot_builder.md#0x4_taproot_builder_finalize">finalize</a>(builder: <a href="taproot_builder.md#0x4_taproot_builder_TaprootBuilder">taproot_builder::TaprootBuilder</a>): <a href="_Result">result::Result</a>&lt;<b>address</b>, <a href="taproot_builder.md#0x4_taproot_builder_TaprootBuilder">taproot_builder::TaprootBuilder</a>&gt;
</code></pre>
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// SPDX-License-Identifier: Apache-2.0

/// Taproot is a module that provides Bitcoin Taproot related functions.
module rooch_nursery::taproot_builder {
module bitcoin_move::taproot_builder {

use std::vector;
use std::option::{Self, Option, is_none, is_some, none, destroy_some};
use moveos_std::bcs;
use moveos_std::compare;
use bitcoin_move::script_buf::{Self,ScriptBuf};
use rooch_nursery::result::{err, ok, Result};
use moveos_std::result::{err, ok, Result};

/// Tapscript leaf version.
// https://github.com/bitcoin/bitcoin/blob/e826b22da252e0599c61d21c98ff89f366b3120f/src/script_buf/interpreter.h#L226
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#[test_only]
module rooch_nursery::taproot_builder_tests {
module bitcoin_move::taproot_builder_tests {
use bitcoin_move::opcode;
use bitcoin_move::script_buf;
use rooch_nursery::taproot_builder;
use rooch_nursery::result;
use bitcoin_move::taproot_builder;
use moveos_std::result;

#[test]
fun test_taproot_builder() {
Expand Down
1 change: 1 addition & 0 deletions frameworks/moveos-stdlib/doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ This is the reference documentation of the MoveOS standard library.
- [`0x2::module_store`](module_store.md#0x2_module_store)
- [`0x2::move_module`](move_module.md#0x2_move_module)
- [`0x2::object`](object.md#0x2_object)
- [`0x2::result`](result.md#0x2_result)
- [`0x2::rlp`](rlp.md#0x2_rlp)
- [`0x2::signer`](signer.md#0x2_signer)
- [`0x2::simple_map`](simple_map.md#0x2_simple_map)
Expand Down
Loading

0 comments on commit 7808213

Please sign in to comment.