Skip to content

BounceBit-Labs/btcstake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BTC Staking Tool

Lock BTC with CLTV and create BB chain staking record.

Requirements

  • Bitcoin Core v22.0+ (with RPC enabled)
  • Python 3.7+

Installation

git clone https://github.com/BounceBit-Labs/btcstake.git
cd btcstake
pip install -r requirements.txt

Testing

You can test the functionality on Bitcoin regtest network using:

cd src
./regtest.sh

This script performs a complete test of the staking functionality on a local Bitcoin regtest network, including:

  • Setting up regtest environment
  • Creating and funding test addresses
  • Testing stake and unlock operations
  • Verifying OP_RETURN data

OP_RETURN Data (Required)

Generate BB chain staking record:

./opreturn.py \
  --bb_address=<bb_chain_address> \
  --days=<lock_days> \
  --amount_btc=<amount>

Example output:

BB Address: 0x1234...
Amount BTC: 0.001
Amount mBTC: 1
Days: 30
OP_RETURN: 46535450177100...

Reference Implementation

The following tools are provided as reference only:

1. Lock BTC

./stake.py \
  --pubkey=<public_key> \
  --days=<lock_days> \
  --amount-btc=<amount> \
  --bb-address=<bb_chain_address> \
  --change-address=<btc_address> \
  --utxos=<txid:vout,...>

2. Unlock BTC

./spend.py \
  --utxo=<txid:vout> \
  --redeem-script=<script> \
  --address=<destination>

Options

  • -v, --verbose: Show detailed output
  • -t, --test: Test mode
  • --config: Load config from JSON file

Transaction Structure

  • Inputs: Simple UTXOs (pubkeyhash/pubkey)
  • Outputs: P2WSH + Change + OP_RETURN
  • Signing: Only requires scriptPubKey for inputs

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published