FB Farming Tools is a completely open-source toolkit for Fractal Bitcoin non-custodial staking. This project demonstrates the technical implementation behind FB Farming's staking system, proving it is truly non-custodial by providing users with direct access to the staking address generation rules and emergency withdrawal tools.
Key Components:
- Staking Address Generation: Transparent algorithm using Taproot technology
- Emergency Withdrawal Tool: Independent recovery mechanism that works even if the main platform is unavailable
- Complete Source Code: All staking logic is open and verifiable
- β Fully Non-custodial: Uses Taproot technology where only user private keys can unlock funds
- β No Backdoors: Uses BIP-341 standard provably unspendable internal pubkey
- β Open Source Transparency: All source code is public and independently verifiable
- β Emergency Withdrawal: Users can withdraw funds independently even if website fails
The FB Farming staking system uses a deterministic address generation algorithm that ensures complete user control:
Staking Address = P2TR(internal_pubkey, script_tree)
Where:
- internal_pubkey = 50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0
- script_tree = { version: 192, script: [user_pubkey, OP_CHECKSIG] }
- Internal Pubkey: Uses BIP-341 standard provably unspendable pubkey
- Leaf Script: Simple
[User_Pubkey] OP_CHECKSIG- only user can sign - Deterministic: Same user pubkey always generates same staking address
- No Backdoors: Internal pubkey has no known private key
Users can always recover funds independently:
- Generate Address: Use your wallet's public key with the generation algorithm
- Find UTXOs: Query blockchain for unspent outputs at your staking address
- Create Transaction: Build unstaking transaction sending funds to your address
- Sign & Broadcast: Sign with your private key and broadcast to network
This process requires NO permission from any third party.
- Node.js >= 14.0.0
- Yarn or npm
- Unisat Wallet browser extension
# Clone repository
git clone https://github.com/your-org/fb-farming-tools
cd fb-farming-tools
# Install dependencies
yarn install
# Install web dependencies
cd web
yarn install# Start frontend application
yarn start:web
# Or from root directory
cd web && yarn start- Input user pubkey to generate corresponding stake address
- Real-time address security verification
- Display script structure and technical details
- Automatically fetch address balance
- Verify stake address can only be unlocked by user private key
- Display Taproot script structure
- Prove internal pubkey is unspendable
- Provide complete security analysis
- Web Interface: User-friendly emergency withdrawal application
- Automatic Address Generation: Derives staking address from user's wallet
- Complete UTXO Recovery: Withdraws all available staked funds
- Offline Capable: Can work without internet (except for balance checking)
- Independent Operation: Functions completely separate from main platform
- PSBT Support: Generates Partially Signed Bitcoin Transactions for wallet signing
- Complete display of core algorithm source code
- Detailed security explanations
- Technical principle explanations
- Independent verification guide
fb-farming-tools/
βββ lib/ # Core staking library
β βββ constant.ts # Taproot constants
β βββ stake-utils.ts # Address generation utilities
βββ src/ # Unified export interface
β βββ index.ts # Main library exports
βββ web/ # Emergency withdrawal web app
β βββ src/
β β βββ App.tsx # Main React application
β β βββ lib/ # Frontend-specific utilities
β β β βββ constant.ts # Frontend constants
β β β βββ stake-utils.ts # Address generation
β β β βββ tx-utils.ts # Transaction creation
β β βββ utils.ts # Helper utilities
β βββ public/ # Static assets
β βββ package.json # Frontend dependencies
βββ package.json # Main project config
βββ README.md # This documentation
Generate staking address using the same algorithm as FB Farming
interface StakeAddressParams {
pubkey: string; // User public key (hex format)
networkType: NetworkType; // Network type (MAINNET)
}
const address = getStakeAddress({
pubkey: "03e61e6043687e474d7b37f56e46ed24a9f5da845746c81eb0b4fe4b2d3d5a7950",
networkType: NetworkType.MAINNET,
});
// Returns: "bc1p..." (Taproot address)
// This address will match exactly what FB Farming generatesBuild Taproot payment for stake address (low-level function)
const payment = buildStakePayment(
internalPubkey, // BIP-341 unspendable pubkey
leafPubkey, // User's public key
psbtNetwork // Bitcoin network
);
// Returns payment object with address, scripts, and control blocks# Build core library
yarn build
# Run tests
yarn test
# Start frontend dev server
yarn start:web# Build library
yarn build:lib
# Build frontend
yarn build:web-
Review Source Code:
- All core logic is in
lib/directory - Key files:
lib/stake-utils.ts,web/src/lib/tx-utils.ts
- All core logic is in
-
Verify Internal Pubkey:
# Confirm using BIP-341 standard unspendable pubkey echo "50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"
-
Test Address Generation:
// Generate address with your pubkey const address = getStakeAddress({ pubkey: "your_pubkey_here", networkType: NetworkType.MAINNET, }); // Verify generated address matches official system
-
Test Unlock Function:
- Use small amounts for testing
- Verify only your private key can unlock
- Confirm no other unlock paths exist
- Internal pubkey source: BIP-341 Standard
- Script type: Pay-to-Taproot (P2TR)
- Unlock condition: User private key signature only
When to use: The main FB Farming website is down or inaccessible, but you need to withdraw your staked funds.
-
Access Emergency Tool:
cd web yarn install yarn startNavigate to http://localhost:3000
-
Connect Wallet:
- Install and unlock Unisat Wallet
- Connect to the emergency withdrawal tool
- Switch to Fractal Bitcoin network
-
Automatic Recovery:
- Tool automatically generates your staking address
- Fetches your current staked balance
- Shows all available UTXOs for withdrawal
-
Execute Withdrawal:
- Review the emergency withdrawal warning
- Set transaction fee rate
- Sign and broadcast the withdrawal transaction
- Note: This forfeits any pending staking rewards
When to use: You want to implement your own recovery tool or understand the technical details.
// 1. Generate your staking address
const stakeAddress = getStakeAddress({
pubkey: "your_wallet_pubkey",
networkType: NetworkType.MAINNET,
});
// 2. Find your UTXOs
const utxos = await getAddressUtxos(stakeAddress);
// 3. Use the web emergency tool or build your own transaction
// The emergency withdrawal tool shows how to create unstaking transactions
// 4. For implementation details, see:
// - web/src/lib/tx-utils.ts: createUnstakeTx() function
// - lib/stake-utils.ts: buildStakePayment() and getStakeAddress()
// - web/src/App.tsx: Complete emergency withdrawal implementation# Run address generation example
yarn run:example
# Execute tests
ts-node test/createLockAddresses.tsA: This system uses Taproot technology with unspendable internal pubkey, mathematically guaranteeing only user private keys can unlock funds. We cannot access user funds.
A: You have multiple independent recovery options:
- Web Emergency Tool: Use the included React application for guided withdrawal
- Direct Code Usage: Use the TypeScript libraries to build your own withdrawal tool
- Manual Construction: Use any Bitcoin library to create the withdrawal transaction
- Community Tools: Other developers can build compatible tools using the open-source specification
All methods work completely independently of any centralized service.
A: Complete Verification Process:
-
Review Address Generation:
// Check lib/constant.ts const TAPROOT_ONLY_SCRIPT_PUBKEY = "50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0";
-
Verify Internal Pubkey:
- Confirm this matches BIP-341 standard unspendable pubkey
- Check: https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki
- This pubkey has no known private key - mathematically proven
-
Inspect Script Tree:
// Only unlock condition is user signature const lockScript = [toXOnly(user_pubkey), bitcoin.opcodes.OP_CHECKSIG];
-
Test Address Generation:
- Generate address with your pubkey
- Verify it matches FB Farming's generated address
- Confirms same algorithm is used
-
Verify No Alternative Unlock Paths:
- Script tree contains only one leaf (user signature)
- Internal pubkey cannot be used to spend
- No time locks, multisig, or other conditions
A: Currently supports Fractal Bitcoin mainnet. Other networks can be supported by modifying NetworkType.
- Fork this repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
This project is licensed under the MIT License - see LICENSE file for details.
- This tool is for educational and demonstration purposes only
- Please conduct thorough testing before use
- Cryptocurrency investment involves risks, please operate cautiously
- We are not responsible for any fund losses
Remember: Your keys, your coins. This is true non-custodial. π