{"id":47887412,"url":"https://github.com/lightningdevkit/orange-sdk","last_synced_at":"2026-04-04T02:21:18.057Z","repository":{"id":340677451,"uuid":"976202146","full_name":"lightningdevkit/orange-sdk","owner":"lightningdevkit","description":null,"archived":false,"fork":false,"pushed_at":"2026-03-25T21:02:51.000Z","size":717,"stargazers_count":9,"open_issues_count":13,"forks_count":2,"subscribers_count":8,"default_branch":"master","last_synced_at":"2026-03-29T14:31:37.058Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lightningdevkit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-01T17:22:59.000Z","updated_at":"2026-03-25T21:02:57.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/lightningdevkit/orange-sdk","commit_stats":null,"previous_names":["lightningdevkit/orange-sdk"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/lightningdevkit/orange-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightningdevkit%2Forange-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightningdevkit%2Forange-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightningdevkit%2Forange-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightningdevkit%2Forange-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lightningdevkit","download_url":"https://codeload.github.com/lightningdevkit/orange-sdk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lightningdevkit%2Forange-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31385028,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T01:22:39.193Z","status":"online","status_checked_at":"2026-04-04T02:00:07.569Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-04T02:21:17.508Z","updated_at":"2026-04-04T02:21:18.040Z","avatar_url":"https://github.com/lightningdevkit.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# orange-sdk\n\n`orange-sdk` is the simplest library for integrating Bitcoin and Lightning capabilities into your applications. It implements a graduated custody model that seamlessly combines trusted custody for small balances with self-custodial Lightning channels for larger amounts.\n\n## Key Features\n\n*   **Graduated Custody Model:** Small balances are held in a trusted wallet backend (e.g., Spark, Cashu) for instant, low-fee transactions, while larger balances automatically move to self-custodial Lightning channels\n*   **Automatic Rebalancing:** Intelligently opens Lightning channels and moves funds into self-custody based on configurable thresholds\n*   **Unified Balance:** Despite funds being in multiple places, everything is accessible through a single wallet API\n*   **Smart Payment Routing:** Automatically selects the best funding source (trusted or Lightning) with fallbacks\n*   **Event-Driven:** Asynchronous event system for payment notifications and channel updates\n\n## How it Works\n\nThe wallet automatically manages fund distribution based on configurable thresholds:\n\n1. **Receiving payments**: Small amounts go to the trusted wallet, larger amounts go to Lightning channels or on-chain addresses\n2. **Automatic rebalancing**: When the trusted balance exceeds `trusted_balance_limit`, funds are automatically transferred to Lightning channels\n3. **Sending payments**: The wallet intelligently selects the best funding source with automatic fallbacks\n\n### Payment Flow\n\n```text\n                             ┌─────────────┐\n                             │ Third Party │\n                             └──────┬──────┘\n                                    │\n                ┌───────────────────┼───────────────────┐\n                │                   │                   │\n                │                   │                   │\n   under trusted_balance_limit      │       over onchain_receive_threshold\n                │           over trusted_balance_limit  │\n                │                   │                   │\n                │                   │                   │\n                ▼                   ▼                   ▼\n        ┌──────────────┐    ┌──────────────┐   ┌──────────────┐\n        │   Trusted    │◄───│  LN Channel  │◄──│   Onchain    │\n        │   Wallet     │    │              │   │   Wallet     │\n        └──────────────┘    └──────┬───────┘   └──────────────┘\n                                   │                   │\n                                   │   splice in,      │\n                        channel    │   when over       │\n                        operations │   threshold       │\n                        (bidir)    │                   │\n                                   │                   │\n                                   │                   │\n                                   └───────────────────┘\n\nLegend:\n  - Payments from Third Party route based on amount thresholds\n  - Onchain funds can splice into LN Channel when rebalance is enabled\n  - Onchain funds below threshold go to Trusted Wallet\n  - Channel force closes pause rebalances to avoid channel open and close loops\n```\n\n## Getting Started\n\nAdd orange-sdk to your `Cargo.toml`:\n\n```toml\n[dependencies]\norange-sdk = \"0.1\"\n```\n\n### Basic Example\n\n```rust,no_run\nuse orange_sdk::bitcoin::Network;\nuse orange_sdk::bitcoin_payment_instructions::amount::Amount;\nuse orange_sdk::trusted_wallet::spark::SparkWalletConfig;\nuse orange_sdk::{ChainSource, StorageConfig, Tunables, Wallet, WalletConfig};\nuse orange_sdk::{ExtraConfig, LoggerType, Mnemonic, Seed};\nuse std::str::FromStr;\n\n#[tokio::main]\nasync fn main() {\n    // Configure the wallet\n    let config = WalletConfig {\n        storage_config: StorageConfig::LocalSQLite(\"./wallet\".to_string()),\n        logger_type: LoggerType::LogFacade,\n        chain_source: ChainSource::Electrum(\n            \"ssl://electrum.blockstream.info:60002\".to_string(),\n        ),\n        lsp: (\"127.0.0.1:9735\".parse().unwrap(), \"03abcd...\".parse().unwrap(), None),\n        scorer_url: None,\n        rgs_url: None,\n        network: Network::Bitcoin,\n        seed: Seed::Mnemonic {\n            mnemonic: Mnemonic::from_str(\"your mnemonic words here\").unwrap(),\n            passphrase: None,\n        },\n        tunables: Tunables {\n            trusted_balance_limit: Amount::from_sats(100_000).unwrap(),\n            rebalance_min: Amount::from_sats(5_000).unwrap(),\n            onchain_receive_threshold: Amount::from_sats(10_000).unwrap(),\n            enable_amountless_receive_on_chain: true,\n        },\n        extra_config: ExtraConfig::Spark(SparkWalletConfig::default()),\n    };\n\n    // Initialize the wallet\n    let wallet = Wallet::new(config).await.unwrap();\n\n    // Check balance\n    let balance = wallet.get_balance().await.unwrap();\n    println!(\"Available: {:?}\", balance.available_balance());\n    println!(\"Trusted: {:?}\", balance.trusted);\n    println!(\"Lightning: {:?}\", balance.lightning);\n    println!(\"Pending: {:?}\", balance.pending_balance);\n\n    // Generate a receive URI\n    let uri = wallet.get_single_use_receive_uri(Some(Amount::from_sats(50_000).unwrap())).await.unwrap();\n    println!(\"Pay me: {}\", uri);\n\n    // Parse and pay an invoice\n    let instructions = wallet.parse_payment_instructions(\"lnbc...\").await.unwrap();\n    let payment_info = orange_sdk::PaymentInfo::build(instructions, Some(Amount::from_sats(1_000).unwrap())).unwrap();\n    wallet.pay(\u0026payment_info).await.unwrap();\n\n    // Listen for events\n    loop {\n        let event = wallet.next_event_async().await;\n        println!(\"Event: {:?}\", event);\n        wallet.event_handled().unwrap();\n    }\n}\n```\n\n## Configuration\n\nThe wallet's behavior is controlled by `Tunables`:\n\n- **`trusted_balance_limit`**: Maximum balance in trusted wallet before triggering rebalance (default: 100,000 sats)\n- **`rebalance_min`**: Minimum amount to rebalance, avoids unnecessary small transfers (default: 5,000 sats)\n- **`onchain_receive_threshold`**: Amount above which on-chain addresses are included in payment URIs (default: 10,000 sats)\n- **`enable_amountless_receive_on_chain`**: Whether to include on-chain addresses for variable amount receives (default: true)\n\n## Supported Backends\n\n### Trusted Wallet Backends\n- **Spark** - Custodial Lightning wallet (default)\n- **Cashu** - Ecash-based wallet\n\n### Chain Sources\n- Electrum servers\n- Esplora servers (with optional Basic auth)\n- Bitcoin Core RPC\n\n## Documentation\n\nFor detailed API documentation, run:\n\n```bash\ncargo doc --open\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nSee [LICENSE](LICENSE.md) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flightningdevkit%2Forange-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flightningdevkit%2Forange-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flightningdevkit%2Forange-sdk/lists"}