diff --git a/.env b/.env.sample similarity index 73% rename from .env rename to .env.sample index 6c84e3a9..44cc2b69 100644 --- a/.env +++ b/.env.sample @@ -2,22 +2,31 @@ BITCOIN_NODE_SERVER = ELECTRUM_API_SERVER = -BITCOIN_API_EXPLORER_MAINNET = +BITCOIN_API_EXPLORER_MAINNET = false BITCOIN_API_EXPLORER_TESTNET = +BITCOIN_API_EXPLORER_SIGNET = false APP_DIR=.rgb-proxy-server -# LN +# lightning network -LNNDHUB_ENDPOINT = RGB_LIGHTNING_NODE = -# bitswap + +# oracle + +ORACLE_ENDPOINT = +ORACLE_PUBKEY = + +# web + +LOCAL_HOST = + +# network 1 STRESS_TEST=false BITCOIN_NETWORK_MAINNET=false BITCOIN_NETWORK_SIGNET=false BITCOIN_NETWORK_TESTNET=true -BITSWAP_ENDPOINT= ## dex @@ -26,7 +35,7 @@ DEX_SEED= # 0.5...1 DEX_FEE_PERC= -# network +# network 2 BITCOIN_NETWORK_TESTNET=https://mempool.space/testnet BITCOIN_NETWORK_MAINNET=https://mempool.space/ diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..592d0523 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,30 @@ +name: Publish docs + +on: + push: + branches: + - master + +jobs: + docs: + name: Publish docs + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-rust@1 + with: + name: fedimint + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + continue-on-error: true + + - name: Build docs + run: cargo doc --no-deps + + - if: github.repository == 'BiSwap/Bitswap' + name: Deploy docs + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./result/ + cname: https://bitswap-bifi.github.io/Bitswap-core/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c8c0769..70fbc654 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,12 @@ See last versions and releases around Bitswap development ## Alpha v1.0.17 -TBA +**Highlights** + +- Fixed Cargo.toml with LDK and RGB +- RGB PSBT +- OP_RETURN +- Fixed typos ## Alpha v1.0.16 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c3015f92..5ccdad28 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,6 +2,7 @@ - If your find some bug, please open "Issue" - If you want make a new upgrade or feature, please open PR +- We not 'listing' token on Core - We'll not integrate with sidechains or altcoins (chains) on DEX - We'll not support Taproot Assets, Runes, Ordinals, NFTs, etc - Check our [ossification DEX](https://github.com/BitSwap-BiFi/Bitswap-core/tree/main#ossification-dex) diff --git a/Cargo.toml b/Cargo.toml index 2750e08c..57bed4b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,15 +6,15 @@ members = ["rgb-core", "rust-dlc", "bitswap", "payjoin", "aluvm", "baid58"] name = "Bitswap-Core" version = "1.0.17-alpha" edition = "2021" -description = "AMM DEX on RGB Protocol" +description = "AMM DEX on RGB Protocol and Lightning Network" license = "Business Source License 1.1" [memmbers] -swap = "algorithm, dlc" +swap = "amm, dlc" dlc = "message" -algorithm = "amm contract" -ldk = "invoice" +amm_contract = "amm contract" +ldk = "invoice, paymenthash, rgb_assets" [dex.dependencies] swap = "pairs, ldk" @@ -22,19 +22,19 @@ bp-core = "tapret, op" [core_functions] -rgb-core = "0.11.0-beta.3" +rgb-core = "0.11.0-beta.4" rust-dlc = "0.4" bitswap = "1.0.13" -rust-aluvm = "0.11.0-beta.3" +rust-aluvm = "0.11.0-beta.4" rust-lighting = "0.0.118" rust-baid58 = "0.4.0" -bp-std = "0.11.0-beta.3" -bp-core="v0.11.0-beta.3" -rgb-std = "0.11.0-beta.3" -payjoin = "0.12.0" -rgb-schemata = "0.11.0-beta.3" +bp-std = "0.11.0-beta.4" +bp-core="v0.11.0-beta.4" +rgb-std = "0.11.0-beta.4" +payjoin = "0.13.0" +rgb-schemata = "0.11.0-beta.4" strict_types = "1.6.3" -rgb-runtime = "0.11.0-beta.1" +rgb-runtime = "0.11.0-beta.4" @@ -50,12 +50,12 @@ required-features = ["stl"] [dependencies] strict_encoding = "~2.3.1" strict_types = "~1.6.3" -bp-core = { version = "~0.11.0-alpha.3 } +bp-core = { version = "~0.11.0-alpha.4"} aluvm = { version = "~0.11.0-beta.3", features = ["std"] } commit_verify = { version = "~0.10.3", features = ["rand", "derive"] } single_use_seals = "~0.10.0" baid58 = "0.4.0" -rgb-std = { version = "0.11.0-beta.3", optional = true } +rgb-std = { version = "0.11.0-beta.4", optional = true } psbt = { workspace = true } [lihghtning] @@ -71,10 +71,10 @@ lightning-rapid-gossip-sync = { version = "0.0.119" } amplify = "~4.5.0" strict_encoding = "~2.6.1" strict_types = "~1.6.3" -aluvm = { version = "~0.11.0-beta.1", features = ["std"] } +aluvm = { version = "~0.11.0-beta.4", features = ["std"] } commit_verify = { version = "~0.10.6", features = ["rand", "derive"] } single_use_seals = "~0.10.1" -bp-core = { version = "~0.10.10" } +bp-core = { version = "~0.11.0" } secp256k1-zkp = { version = "0.28.0", features = ["rand", "rand-std", "global-context"] } baid58 = "~0.4.4" mime = "~0.3.17" @@ -135,15 +135,15 @@ baid58 = "0.4.4" strict_encoding = "2.5.0" strict_types = "1.6.0" commit_verify = { version = "0.10.5", features = ["stl"] } -bp-core = { version = "0.11.0", features = ["stl"] } -rgb-core = { version = "0.11.0", features = ["stl"] } +bp-core = { version = "0.11.0-beta.4", features = ["stl"] } +rgb-core = { version = "0.11.0-beta.4, features = ["stl"] } [ldk] tokio = { version = "1.14", features = [ "macros", "rt", "rt-multi-thread", "sync", "time" ] } -lightning = { version = "0.0.117", path = "../lightning", features = ["_test_utils"] } +lightning = { version = "0.0.119", path = "../lightning", features = ["_test_utils"] } lightning-invoice = { version = "0.24.0", path = "../lightning-invoice" } -lightning-persister = { version = "0.0.116", path = "../lightning-persister" } +lightning-persister = { version = "0.0.119", path = "../lightning-persister" } bech32 = { version = "0.9.0", default-features = false } @@ -161,7 +161,7 @@ bitcoin = {version = "0.29.2"} dlc = {version = "0.4.0", path = "../dlc"} dlc-messages = {version = "0.4.0", path = "../dlc-messages"} dlc-trie = {version = "0.4.0", path = "../dlc-trie"} -lightning = {version = "0.0.116" } +lightning = {version = "0.0.119" } log = "0.4.14" rand_chacha = {version = "0.3.1", optional = true} serde = {version = "1.0", optional = true} @@ -185,7 +185,7 @@ simple-wallet = {path = "../simple-wallet"} bitcoin = {version = "0.29.2"} dlc = {version = "0.4.0", path = "../dlc"} -lightning = {version = "0.0.116" } +lightning = {version = "0.0.119" } secp256k1-zkp = {version = "0.7.0", features = ["bitcoin_hashes", "rand", "rand-std"]} serde = {version = "1.0", features = ["derive"], optional = true} @@ -310,7 +310,7 @@ sha2 = "0.10.7" [bifrost] amplify = { version = "3.13.0", features = ["hex", "rand"] } lnpbp = "0.9.0" -bp-core = "0.11.0" +bp-core = "0.11.0-beta.4" strict_encoding = { version = "0.11.0", optional = true, features = ["chrono", "miniscript"] } lightning_encoding = { version = "0.9.0", optional = true } bitcoin_scripts = "0.9.0" diff --git a/README.md b/README.md index 7377c9fb..e32f6d1c 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ How there's no lunch free, you can lose sats in these scenarios: ## Roadmap -- [x] CLI +- [x] CLI powered by RGB CLI - [x] On-Chain RGB Assets with Swap using [Bitcoin Protocol](https://github.com/BP-WG/bp-core) - [x] RGB PSBT - [x] RGB wallet (new version stable) @@ -72,7 +72,6 @@ How there's no lunch free, you can lose sats in these scenarios: - [x] Payjoin and Taproot full implementation (WIP) - [x] Complete PRs pendents (WIP) - [x] Add [RGB CLI](https://github.com/RGB-WG/rgb) as tool complementary for CLI from DEX -- [x] Integration with Bitlight wallet (WIP) - [x] OP_RETURN (WIP) - [x] API integration from RLN (WIP) - [x] RGB Proxy (WIP) @@ -85,17 +84,18 @@ How there's no lunch free, you can lose sats in these scenarios: - [x] Prime (WIP) - [x] Complete PRs pendents (WIP) - [x] WASM (WIP) -- [ ] RGB Core, STD, BP, AluVM and many more to v0.11 - Part.2 +- [x] RGB Core, STD, BP, AluVM and many more to v0.11 - Part.2 (WIP) +- [x] AMM lib (WIP) +- [x] Web server and domain - [ ] Liquid integration - [ ] User friendly UI for allow mint tokens, send, receive and swap tokens on Lightning Network and DEX - [ ] Taproot Channels by LDK - [ ] Mainnet - [ ] Beta app - [ ] UI/UX -- [x] Web server and domain - [ ] Official USDT implementation by Bitifinex - [ ] Integration with APIs from [RGBex](https://rgbex.io/) -- [ ] Bitlight Wallet +- [ ] [Bitlight Wallet](https://bitlightlabs.com) - [ ] [BitMask](https://bitmask.app/) - [ ] Storm - [ ] Contractrum diff --git a/doc/architecture.md b/doc/architecture.md index e5397339..957c20ee 100644 --- a/doc/architecture.md +++ b/doc/architecture.md @@ -20,4 +20,5 @@ Discover architecture repository about Bitswap - Liquid: TBD - Prime: TBD - Bifrost: TBD +- Storm: TBD diff --git a/server/amm/src/lib.rs b/server/amm/src/lib.rs new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/server/amm/src/lib.rs @@ -0,0 +1 @@ + diff --git a/src/Cargo.toml b/src/Cargo.toml index 61ea7770..d3bfcaef 100644 --- a/src/Cargo.toml +++ b/src/Cargo.toml @@ -1,4 +1,18 @@ [package] -name = "Core" +name = "Src_core" version = "1.0.17-alpha" +lib = +bifrost = +lightning = +bitcoin = +error = +proxy = +rgb = +testnet = +validators = +util = +web = +struct = +constants = + diff --git a/src/aluvm/Cargo.toml b/src/aluvm/Cargo.toml new file mode 100644 index 00000000..78690dcc --- /dev/null +++ b/src/aluvm/Cargo.toml @@ -0,0 +1,3 @@ +[workspcae] +name = "src/aluvm" +version = "1.0.17-alpha" diff --git a/src/cli/Cargo.toml b/src/cli/Cargo.toml new file mode 100644 index 00000000..4125bf21 --- /dev/null +++ b/src/cli/Cargo.toml @@ -0,0 +1,6 @@ +[workspace] + +cli = "1.0.17-alpha" + +[dev.depedencies] +src = "cli" diff --git a/src/cli/cli.rs b/src/cli/cli.rs index f79904d7..068d9270 100644 --- a/src/cli/cli.rs +++ b/src/cli/cli.rs @@ -1,3 +1,8 @@ +use ldk::wallet::Wallet; +use rgb::core::contract::Contract; +use rgb::core::fungible::{Mint, OutpointValue, ValueSum}; +use rgb::core::issue::Amount; +use rgb_contract::cli; use lightning::wallet::Wallet; use rgbstd::interface::{Mint, OutpointValue, ValueSum, Amount, ContractID}; use std::error::Error; @@ -34,10 +39,7 @@ fn main() -> Result<(), Box> { match args[0] { "swaps" => { let swap = swap::BTC(); - let swap = swap::USDT(); - } - "mint" => { - let mint = mint::USDT(); + let swap = swap::RGB20(); } "enable_channel" => { let channel = open::new(); @@ -51,13 +53,13 @@ fn main() -> Result<(), Box> { "enter_liquidity" => { let mut input = String::new(); let input = asset::BTC:(); - let input = asset::USDT(); + let input = asset::RGB20(); } "exit_liquidity" => { let mut output = String::new(); let output = asset::BTC:(); - let output = asset::USDT(); + let output = asset::RGB20(); } "exit" => { // Exit the program diff --git a/src/cli/command.sh b/src/cli/command.sh index b7d69d6e..01620d77 100644 --- a/src/cli/command.sh +++ b/src/cli/command.sh @@ -2,40 +2,81 @@ # Function to perform swaps function perform_swaps() { - # Your code here - echo "Performing swaps..." + # Two variables to swap + var1="Value1" + var2="Value2" + + echo "Before swapping: var1=$var1, var2=$var2" + + # Swapping logic + temp=$var1 + var1=$var2 + var2=$temp + + echo "After swapping: var1=$var1, var2=$var2" } + echo "Performing swaps..." + + # Swapping assets -# Function to mint new RGB assets -function mint_assets() { - # Your code here - echo "Minting assets..." + tem=$var1 + var1=$var2 + var2=$temp + price=$temp } # Function to enable an open channel function enable_channel() { - # Your code here + tem=$var1 + var1=$var2 + var2=$temp + price=$temp + channel=$temp echo "Enabling channel..." } # Function to disable a close channel function disable_channel() { - # Your code here + tem=$var1 + var1=$var2 + var2=$temp + price=$temp + disable_channel=$temp echo "Disabling channel..." } # Function to enter liquidity for RGB assets or Bitcoin function enter_liquidity() { - # Your code here - echo "Entering liquidity..." -} + tem=$var1 + var1=$var2 + var2=$temp + price=$temp + liquidity=$temp +[ echo "Entering liquidity..."} # Function to exit liquidity for RGB assets or Bitcoin function exit_liquidity() { - # Your code here + tem=$var1 + var1=$var2 + var2=$temp + price=$temp + exit_liquidity=$temp echo "Exiting liquidity..." } +# Function to check DLCs prices + +function oracle_price() { + tem=$var1 + var1=$var2 + var2=$temp + price=$temp + oracle=$temp + echo "Oracle Price..." + +} + + while true; do # Display the command prompt read -p "> " input @@ -48,9 +89,7 @@ while true; do "swaps") perform_swaps ;; - "mint") - mint_assets - ;; + "enable_channel") enable_channel ;; diff --git a/src/contract/asset.rs b/src/contract/asset.rs index 2ae51e87..4f2e08bb 100644 --- a/src/contract/asset.rs +++ b/src/contract/asset.rs @@ -28,7 +28,6 @@ struct RGB20Asset { name: String, symbol: String, swap: String, - uxto: String, lp: String, schema: String, decimal: Number, @@ -44,7 +43,6 @@ impl RGB20Asset { symbol, total_supply, decimal, - utxo, balances: HashMap::new(), } } diff --git a/src/contract/dlc.rs b/src/contract/dlc.rs index c9b112d3..b0ef035f 100644 --- a/src/contract/dlc.rs +++ b/src/contract/dlc.rs @@ -11,8 +11,8 @@ use bitcoin::Network; use secp256k1::Secp256k1; fn main() { - // Establish connection with RGB Node - let node = Node::new("http://rgb-node-url:port"); + // Establish connection with Oracle + let edndpoint = Endpoint::new("http://oracle"); // Create a new DLC contract let mut dlc = ContractDescriptor::new(); diff --git a/src/contract/rgb20.rs b/src/contract/rgb20.rs new file mode 100644 index 00000000..c05910a0 --- /dev/null +++ b/src/contract/rgb20.rs @@ -0,0 +1,40 @@ +use aluvm::reg::RegS; +use aluvm::data::ByteStr; +use aluvm::isa::{BytesOp, ControlFlowOp, Instr}; +use rgbstd::vm::opcodes::{INSTR_PCCS, INSTR_PCVS}; +use rgbstd::interface::RGB20; +use rgbstd::interface::{Amount, ContractID, Fungible, Divisible}; +use rgbstd::vm::{SubSchema, RgbIsa}; +use rgb_schemata::{nia_rgb20, nia_schema}; + +impl rgb20::interface { + // Add your implementations here + fn nia_rgb20() -> IfaceImpl { + let schema = nia_schema(); + let iface = rgb20(); + let aluvm = aluvm(); + + fn IfaceImpl = { + let version = V1 + let schema_id = schema_id(); + let iface_id = iface_id(); + let script = let script(); + let global_state = let global_state(); + let nominal = let nominal(); + let data = let data(); + let created = let created(); + let issued_suply = let issued_supply(); +} + +impl rgb20::schemata { + // Add your implementations here + fn schemata() - IfaveImpl { + let schema = schema(); + + fn schemata = { + let schema = let schema(); + let subschema = let subschema(); + let alu_id = let alu_id(); + +} + diff --git a/src/dex/Cargo.toml b/src/dex/Cargo.toml index 8b137891..9435bbae 100644 --- a/src/dex/Cargo.toml +++ b/src/dex/Cargo.toml @@ -1 +1,3 @@ - +[workspace] +name = "src/dex" +version = "1.0.17-alpha" diff --git a/src/dex/swap.rs b/src/dex/swap.rs index 949d6915..1071b141 100644 --- a/src/dex/swap.rs +++ b/src/dex/swap.rs @@ -13,6 +13,7 @@ use bpstd::secp256k1::serde::{Deserialize, Serialize}; use strict_encoding::{StrictDeserialize, StrictSerialize}; use std::str::FromStr; use std::str::bp; +use lightning::ChannelManager::BOLT12; use dlc::DLCMessage; diff --git a/src/lightning/swap.rs b/src/lightning/swap.rs index 90f22057..d4d1dd65 100644 --- a/src/lightning/swap.rs +++ b/src/lightning/swap.rs @@ -4,11 +4,19 @@ use std::convert::TryInto; use std::str::FromStr; use dlc::message::Oracle; use bp::psbt; -use lightning::ln::PaymentHash; +use lightning:::PaymentHash; use lightning::OnionMessage; +use lightning::OnChainSweep; +use lightning::ChainHash; +use lightning::Deref; +use lightning::PeeledOnion; +use lightning::SocketAddress; +use lightning::Display; +use lightning::ChannelManger::BOLT12; use rgb::contract::ContractId; + #[derive(Debug)] pub enum SwapType { BuyAsset { amount_rgb: u64, amount_msats: u64 }, @@ -161,7 +169,15 @@ pub fn get_current_timestamp() -> u64 { .unwrap() .as_secs() } +pub fn from_be_bytes(mut flags: Vec) -> Features { + +impl core::fmt::Display for OutPoint { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{}:{}", self.txid, self.index) + } +} + fn main() { // Example usage of SwapString parsing let swap_string = "123:abc:buy:456:789:def"; diff --git a/src/op/lib.rs b/src/op/lib.rs new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/src/op/lib.rs @@ -0,0 +1 @@ + diff --git a/src/op/op.rs b/src/op/op.rs index 7b616dc5..69a403c7 100644 --- a/src/op/op.rs +++ b/src/op/op.rs @@ -9,8 +9,13 @@ impl opcode = { // OP code for contract impl op_contract = { + let ContractOp = let ContractOP; + // OP for timestamp impl op_timechain = { let timechainOp = let timechainOp; let ByteCode = let ByteCode; + +// OP for VM +impl op_vm = { diff --git a/src/op/script.rs b/src/op/script.rs new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/src/op/script.rs @@ -0,0 +1 @@ + diff --git a/src/storm/app.rs b/src/storm/app.rs new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/src/storm/app.rs @@ -0,0 +1 @@ + diff --git a/src/storm/channel.rs b/src/storm/channel.rs new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/src/storm/channel.rs @@ -0,0 +1 @@ + diff --git a/src/storm/data.rs b/src/storm/data.rs new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/src/storm/data.rs @@ -0,0 +1 @@ + diff --git a/src/web/Cargo.toml b/src/web/Cargo.toml new file mode 100644 index 00000000..3e80e7c6 --- /dev/null +++ b/src/web/Cargo.toml @@ -0,0 +1,4 @@ +[workspace] + +name = "src/web" +version = "v1.0.17-alpha"