-
Notifications
You must be signed in to change notification settings - Fork 8
Custom VTXO Script Builder #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…xample (#1) * feat: Add custom VTXo script support This commit adds comprehensive support for custom VTXo script generation, allowing users to define custom spending conditions while maintaining ARK protocol compatibility. ## Changes ### Core Implementation - **wallet/script_builder.go**: New VtxoScriptBuilder interface defining the contract for custom script generation with BuildOffchainScript and BuildBoardingScript methods - **wallet/default_script_builder.go**: Default implementation using standard ARK scripts, ensuring backward compatibility - **wallet/script_utils.go**: Utility functions for script validation and taproot key extraction from generated scripts ### Integration - **types.go**: Added ScriptBuilder field to InitArgs and InitWithWalletArgs structs for passing custom builders during initialization - **base_client.go**: - Added getWalletWithScriptBuilder() function to propagate script builders through wallet creation - Modified getSingleKeyWallet() to accept ScriptBuilder parameter - Updated init() to pass ScriptBuilder from InitArgs - **wallet/singlekey/bitcoin_wallet.go**: - Added scriptBuilder field to bitcoinWallet struct - Created NewBitcoinWalletWithScriptBuilder() constructor - Modified getArkAddresses() to use script builder instead of hardcoded script.NewDefaultVtxoScript() - Added comprehensive validation and error handling for custom scripts ### Testing & Examples - **wallet/script_builder_test.go**: Comprehensive unit tests covering: - Default script builder functionality - Script validation - Taproot key extraction - Custom script builder implementation - Error cases - **example/custom_script_builder/main.go**: Complete working example demonstrating: - Custom script builder implementation - Extended timelock scripts - Logging wrapper pattern - Integration with ARK client ### Documentation - **README.md**: Added comprehensive section on custom VTXo scripts including: - Interface implementation guide - Usage examples - Default behavior explanation - Security and compatibility considerations ## Features 1. **Backward Compatible**: Existing code works unchanged; nil ScriptBuilder uses default implementation 2. **Modular Design**: Clean interface separation allows easy testing and extension 3. **Comprehensive Validation**: Generated scripts are validated before use to catch errors early 4. **Flexible**: Supports both offchain and boarding script customization 5. **Well-Tested**: Unit tests ensure reliability and demonstrate usage ## Use Cases - Custom timelock configurations - Additional spending conditions - Logging and monitoring of script generation - Protocol extensions and experiments - Testing and development ## API Stability This is a new feature with no breaking changes to existing APIs. The VtxoScriptBuilder interface is designed to be stable and extensible. * fix: Remove unused ScriptBuilder from InitWithWalletArgs InitWithWalletArgs receives a pre-created wallet, so ScriptBuilder cannot be used at that point. Users who want custom scripts with InitWithWallet should create the wallet using NewBitcoinWalletWithScriptBuilder() directly. This commit: - Removes misleading ScriptBuilder field from InitWithWalletArgs - Updates README with clear examples for both Init() and InitWithWallet() - Adds comment to Wallet field explaining where to use ScriptBuilder Addresses critical issue found in code review. * Apply suggestions from code review Signed-off-by: Marco Argentieri <[email protected]> * feat: Add Lightning Network channel script example This commit adds a comprehensive example demonstrating how to create Lightning Network channel funding outputs using Arkade's custom VTXo script feature. Key Features: - Dual-path Taproot structure (standard Lightning + CSV timeout) - 2-of-2 multisig between channel participants (Alice and Bob) - Server key excluded from Lightning scripts (only in VTXO cooperative path) - HTLC/VTXO expiry coordination guidance - Complete documentation and implementation notes Files Added: - example/lightning_channel_scripts/main.go: Full working implementation - example/lightning_channel_scripts/README.md: Comprehensive documentation Documentation Includes: - Channel lifecycle (funding, operation, renewal, force close) - Critical HTLC expiry constraint - Integration guidance for LND - Security considerations and anti-patterns - Reference to production implementation (lampo.rs) This example demonstrates a real-world use case for custom VTXo scripts and shows how Arkade can serve as a channel factory for Lightning Network while maintaining full BOLT compliance. * Update README.md Signed-off-by: Marco Argentieri <[email protected]> * Update README.md Signed-off-by: Marco Argentieri <[email protected]> * Update README.md Signed-off-by: Marco Argentieri <[email protected]> * Apply suggestion from @tiero Signed-off-by: Marco Argentieri <[email protected]> * Update example/lightning_channel_scripts/main.go Signed-off-by: Marco Argentieri <[email protected]> * Apply suggestions from code review Signed-off-by: Marco Argentieri <[email protected]> --------- Signed-off-by: Marco Argentieri <[email protected]> Co-authored-by: Claude <[email protected]>
* Initial plan * Fix critical bugs: wrong return type, undefined require.AnError, wrong test assertion, API mismatch, undefined methods, wrong struct type Co-authored-by: tiero <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: tiero <[email protected]>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
No description provided.