Skip to content

Commit

Permalink
[bitcoin-move] babylon integration (#2734)
Browse files Browse the repository at this point in the history
* [draft] babylon integration

* derive babylon utxo

* fix: build

* format code and fix build

* Update docs

---------

Co-authored-by: mx819812523 <mx819812523@gamil.com>
Co-authored-by: jolestar <jolestar@gmail.com>
  • Loading branch information
3 people authored Oct 9, 2024
1 parent 7ea5048 commit bc167cb
Show file tree
Hide file tree
Showing 8 changed files with 466 additions and 0 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 @@ -12,6 +12,7 @@ This is the reference documentation of the Bitcoin Move Framework.
## Index


- [`0x4::bbn`](bbn.md#0x4_bbn)
- [`0x4::bitcoin`](bitcoin.md#0x4_bitcoin)
- [`0x4::bitcoin_hash`](bitcoin_hash.md#0x4_bitcoin_hash)
- [`0x4::bitcoin_multisign_validator`](bitcoin_multisign_validator.md#0x4_bitcoin_multisign_validator)
Expand Down
153 changes: 153 additions & 0 deletions frameworks/bitcoin-move/doc/bbn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@

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

# Module `0x4::bbn`



- [Resource `BBNGlobalParam`](#0x4_bbn_BBNGlobalParam)
- [Resource `BBNGlobalParams`](#0x4_bbn_BBNGlobalParams)
- [Struct `BBNOpReturnData`](#0x4_bbn_BBNOpReturnData)
- [Constants](#@Constants_0)
- [Function `genesis_init`](#0x4_bbn_genesis_init)
- [Function `try_get_bbn_op_return_data`](#0x4_bbn_try_get_bbn_op_return_data)
- [Function `try_get_staking_output`](#0x4_bbn_try_get_staking_output)
- [Function `derive_bbn_utxo`](#0x4_bbn_derive_bbn_utxo)


<pre><code><b>use</b> <a href="">0x1::option</a>;
<b>use</b> <a href="">0x1::vector</a>;
<b>use</b> <a href="">0x2::object</a>;
<b>use</b> <a href="">0x3::bitcoin_address</a>;
<b>use</b> <a href="bitcoin.md#0x4_bitcoin">0x4::bitcoin</a>;
<b>use</b> <a href="script_buf.md#0x4_script_buf">0x4::script_buf</a>;
<b>use</b> <a href="types.md#0x4_types">0x4::types</a>;
<b>use</b> <a href="utxo.md#0x4_utxo">0x4::utxo</a>;
</code></pre>



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

## Resource `BBNGlobalParam`



<pre><code><b>struct</b> <a href="bbn.md#0x4_bbn_BBNGlobalParam">BBNGlobalParam</a> <b>has</b> store, key
</code></pre>



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

## Resource `BBNGlobalParams`



<pre><code><b>struct</b> <a href="bbn.md#0x4_bbn_BBNGlobalParams">BBNGlobalParams</a> <b>has</b> key
</code></pre>



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

## Struct `BBNOpReturnData`



<pre><code><b>struct</b> <a href="bbn.md#0x4_bbn_BBNOpReturnData">BBNOpReturnData</a> <b>has</b> <b>copy</b>, drop, store
</code></pre>



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

## Constants


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



<pre><code><b>const</b> <a href="bbn.md#0x4_bbn_ErrorNotBabylonOpReturn">ErrorNotBabylonOpReturn</a>: u64 = 2;
</code></pre>



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



<pre><code><b>const</b> <a href="bbn.md#0x4_bbn_ErrorNotBabylonUTXO">ErrorNotBabylonUTXO</a>: u64 = 0;
</code></pre>



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



<pre><code><b>const</b> <a href="bbn.md#0x4_bbn_ErrorNotTransaction">ErrorNotTransaction</a>: u64 = 1;
</code></pre>



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



<pre><code><b>const</b> <a href="bbn.md#0x4_bbn_ErrorTransactionLockTime">ErrorTransactionLockTime</a>: u64 = 3;
</code></pre>



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



<pre><code><b>const</b> <a href="bbn.md#0x4_bbn_UNSPENDABLEKEYPATHKEY">UNSPENDABLEKEYPATHKEY</a>: <a href="">vector</a>&lt;u8&gt; = [48, 50, 53, 48, 57, 50, 57, 98, 55, 52, 99, 49, 97, 48, 52, 57, 53, 52, 98, 55, 56, 98, 52, 98, 54, 48, 51, 53, 101, 57, 55, 97, 53, 101, 48, 55, 56, 97, 53, 97, 48, 102, 50, 56, 101, 99, 57, 54, 100, 53, 52, 55, 98, 102, 101, 101, 57, 97, 99, 101, 56, 48, 51, 97, 99, 48];
</code></pre>



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

## Function `genesis_init`



<pre><code><b>public</b>(<b>friend</b>) <b>fun</b> <a href="bbn.md#0x4_bbn_genesis_init">genesis_init</a>()
</code></pre>



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

## Function `try_get_bbn_op_return_data`



<pre><code><b>public</b> <b>fun</b> <a href="bbn.md#0x4_bbn_try_get_bbn_op_return_data">try_get_bbn_op_return_data</a>(<a href="">transaction</a>: <a href="types.md#0x4_types_Transaction">types::Transaction</a>): (bool, u64, <a href="bbn.md#0x4_bbn_BBNOpReturnData">bbn::BBNOpReturnData</a>)
</code></pre>



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

## Function `try_get_staking_output`



<pre><code><b>public</b> <b>fun</b> <a href="bbn.md#0x4_bbn_try_get_staking_output">try_get_staking_output</a>(<a href="">transaction</a>: <a href="types.md#0x4_types_Transaction">types::Transaction</a>, staking_output_script: &<a href="">vector</a>&lt;u8&gt;): (bool, u64, <a href="_Option">option::Option</a>&lt;<a href="_ObjectID">object::ObjectID</a>&gt;)
</code></pre>



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

## Function `derive_bbn_utxo`



<pre><code><b>public</b> <b>fun</b> <a href="bbn.md#0x4_bbn_derive_bbn_utxo">derive_bbn_utxo</a>(utxo_obj: &<a href="_Object">object::Object</a>&lt;<a href="utxo.md#0x4_utxo_UTXO">utxo::UTXO</a>&gt;)
</code></pre>
1 change: 1 addition & 0 deletions frameworks/bitcoin-move/doc/genesis.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<b>use</b> <a href="">0x2::signer</a>;
<b>use</b> <a href="">0x2::tx_context</a>;
<b>use</b> <a href="">0x3::bitcoin_address</a>;
<b>use</b> <a href="bbn.md#0x4_bbn">0x4::bbn</a>;
<b>use</b> <a href="bitcoin.md#0x4_bitcoin">0x4::bitcoin</a>;
<b>use</b> <a href="bitcoin_multisign_validator.md#0x4_bitcoin_multisign_validator">0x4::bitcoin_multisign_validator</a>;
<b>use</b> <a href="multisign_account.md#0x4_multisign_account">0x4::multisign_account</a>;
Expand Down
21 changes: 21 additions & 0 deletions frameworks/bitcoin-move/doc/script_buf.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [Function `is_witness_program`](#0x4_script_buf_is_witness_program)
- [Function `witness_program`](#0x4_script_buf_witness_program)
- [Function `is_op_return`](#0x4_script_buf_is_op_return)
- [Function `unpack_bbn_stake_data`](#0x4_script_buf_unpack_bbn_stake_data)
- [Function `push_opcode`](#0x4_script_buf_push_opcode)
- [Function `push_data`](#0x4_script_buf_push_data)
- [Function `push_int`](#0x4_script_buf_push_int)
Expand Down Expand Up @@ -68,6 +69,15 @@



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



<pre><code><b>const</b> <a href="script_buf.md#0x4_script_buf_ErrorInvalidBytesLen">ErrorInvalidBytesLen</a>: u64 = 2;
</code></pre>



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


Expand Down Expand Up @@ -228,6 +238,17 @@ Checks if the given script is an OP_RETURN script.



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

## Function `unpack_bbn_stake_data`



<pre><code><b>public</b> <b>fun</b> <a href="script_buf.md#0x4_script_buf_unpack_bbn_stake_data">unpack_bbn_stake_data</a>(self: &<a href="script_buf.md#0x4_script_buf_ScriptBuf">script_buf::ScriptBuf</a>): (<a href="">vector</a>&lt;u8&gt;, u64, <a href="">vector</a>&lt;u8&gt;, <a href="">vector</a>&lt;u8&gt;, u16)
</code></pre>



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

## Function `push_opcode`
Expand Down
Loading

0 comments on commit bc167cb

Please sign in to comment.