From 132b8ba2b30ad33b823ccb0dd6164fba071971d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zoe=20Faltib=C3=A0?= Date: Thu, 25 Apr 2024 12:15:06 +0200 Subject: [PATCH] bootstrap project --- .github/workflows/checks.yml | 70 + .gitignore | 4 + .gitmodules | 63 + Cargo.lock | 2943 ++++++++++++++++++++++++++++++++++ Cargo.toml | 124 ++ LICENSE | 201 +++ README.md | 74 + amplify-derive | 1 + amplify-nonasync | 1 + amplify-num | 1 + ascii-armor | 1 + bp-core | 1 + bp-electrum-client | 1 + bp-esplora-client | 1 + bp-std | 1 + bp-wallet | 1 + client_side_validation | 1 + codecov.yml | 6 + rgb | 1 + rgb-core | 1 + rgb-interfaces | 1 + rgb-schemata | 1 + rgb-std | 1 + rust-aluvm | 1 + rust-amplify | 1 + rust-baid64 | 1 + strict-encoding | 1 + strict-types | 1 + tests/coverage.sh | 59 + tests/docker-compose.yml | 26 + tests/fixtures/rgb_logo.jpeg | Bin 0 -> 4553 bytes tests/issuance.rs | 201 +++ tests/start_services.sh | 69 + tests/transfers.rs | 769 +++++++++ tests/utils/chain.rs | 244 +++ tests/utils/helpers.rs | 1271 +++++++++++++++ tests/utils/mod.rs | 90 ++ vesper | 1 + 38 files changed, 6235 insertions(+) create mode 100644 .github/workflows/checks.yml create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 LICENSE create mode 160000 amplify-derive create mode 160000 amplify-nonasync create mode 160000 amplify-num create mode 160000 ascii-armor create mode 160000 bp-core create mode 160000 bp-electrum-client create mode 160000 bp-esplora-client create mode 160000 bp-std create mode 160000 bp-wallet create mode 160000 client_side_validation create mode 100644 codecov.yml create mode 160000 rgb create mode 160000 rgb-core create mode 160000 rgb-interfaces create mode 160000 rgb-schemata create mode 160000 rgb-std create mode 160000 rust-aluvm create mode 160000 rust-amplify create mode 160000 rust-baid64 create mode 160000 strict-encoding create mode 160000 strict-types create mode 100755 tests/coverage.sh create mode 100644 tests/docker-compose.yml create mode 100644 tests/fixtures/rgb_logo.jpeg create mode 100644 tests/issuance.rs create mode 100755 tests/start_services.sh create mode 100644 tests/transfers.rs create mode 100644 tests/utils/chain.rs create mode 100644 tests/utils/helpers.rs create mode 100644 tests/utils/mod.rs create mode 160000 vesper diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..2d67a69 --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,70 @@ +name: Code checks + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + lint: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: clippy + - name: Lint + run: cargo clippy --all-targets -- -D warnings + + format: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: rustfmt + - name: Format + run: cargo fmt --all -- --check + + test_and_coverage: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: true + + - name: Setup rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: llvm-tools-preview + toolchain: stable + + - name: Install llvm-cov + env: + LLVM_COV_RELEASES: https://github.com/taiki-e/cargo-llvm-cov/releases + run: | + host=$(rustc -Vv | grep host | sed 's/host: //') + curl -fsSL $LLVM_COV_RELEASES/latest/download/cargo-llvm-cov-$host.tar.gz | tar xzf - -C "$HOME/.cargo/bin" + + - name: Test and generate coverage report + run: | + INDEXER=esplora cargo llvm-cov --output-path coverage.lcov + INDEXER=electrum cargo llvm-cov --no-clean --output-path coverage.lcov + + - name: Upload coverage report + uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: true + file: coverage.lcov + flags: rust + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e562211 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +**/target +**/tests/tmp +**/tests/mainnet +/.vim diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..7b781f5 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,63 @@ +[submodule "rgb-std"] + path = rgb-std + url = https://github.com/RGB-WG/rgb-std.git +[submodule "rust-aluvm"] + path = rust-aluvm + url = https://github.com/aluvm/rust-aluvm +[submodule "rgb-interfaces"] + path = rgb-interfaces + url = https://github.com/RGB-WG/rgb-interfaces +[submodule "client_side_validation"] + path = client_side_validation + url = https://github.com/LNP-BP/client_side_validation/ +[submodule "bp-core"] + path = bp-core + url = https://github.com/BP-WG/bp-core +[submodule "rgb-core"] + path = rgb-core + url = https://github.com/RGB-WG/rgb-core +[submodule "bp-std"] + path = bp-std + url = https://github.com/BP-WG/bp-std +[submodule "rgb-schemata"] + path = rgb-schemata + url = https://github.com/RGB-WG/rgb-schemata +[submodule "strict-types"] + path = strict-types + url = https://github.com/strict-types/strict-types +[submodule "strict-encoding"] + path = strict-encoding + url = https://github.com/strict-types/strict-encoding +[submodule "bp-electrum-client"] + path = bp-electrum-client + url = https://github.com/BP-WG/bp-electrum-client/ +[submodule "rust-amplify"] + path = rust-amplify + url = https://github.com/rust-amplify/rust-amplify +[submodule "rgb"] + path = rgb + url = https://github.com/RGB-WG/rgb +[submodule "bp-wallet"] + path = bp-wallet + url = https://github.com/BP-WG/bp-wallet +[submodule "amplify-num"] + path = amplify-num + url = https://github.com/rust-amplify/amplify-num.git +[submodule "amplify-derive"] + path = amplify-derive + url = https://github.com/rust-amplify/amplify-derive.git +[submodule "ascii-armor"] + path = ascii-armor + url = https://github.com/UBIDECO/ascii-armor.git +[submodule "bp-esplora-client"] + path = bp-esplora-client + url = https://github.com/BP-WG/bp-esplora-client.git +[submodule "vesper"] + path = vesper + url = https://github.com/UBIDECO/vesper.git +[submodule "rust-baid64"] + path = rust-baid64 + url = https://github.com/UBIDECO/rust-baid64.git +[submodule "amplify-nonasync"] + path = amplify-nonasync + url = https://github.com/rust-amplify/amplify-nonasync.git diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..f81305e --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,2943 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "aluvm" +version = "0.11.0-beta.8" +dependencies = [ + "amplify 4.7.0", + "ascii-armor", + "baid64", + "blake3", + "getrandom", + "half", + "paste", + "ripemd", + "serde", + "sha2", + "strict_encoding", + "strict_types", + "wasm-bindgen", +] + +[[package]] +name = "amplify" +version = "4.7.0" +dependencies = [ + "amplify_apfloat", + "amplify_derive", + "amplify_num", + "amplify_syn", + "ascii", + "rand", + "serde", + "stringly_conversions", + "wasm-bindgen", +] + +[[package]] +name = "amplify" +version = "5.0.0-beta.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d41888768802fc62c27b46427127b119e8a16e1f1f59495aced93a340f55eb25" +dependencies = [ + "amplify_derive", + "amplify_num", + "ascii", + "wasm-bindgen", +] + +[[package]] +name = "amplify_apfloat" +version = "0.3.1" +dependencies = [ + "amplify_num", + "bitflags 2.5.0", + "wasm-bindgen", +] + +[[package]] +name = "amplify_derive" +version = "4.0.1" +dependencies = [ + "amplify_syn", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "amplify_num" +version = "0.5.3" +dependencies = [ + "serde", + "wasm-bindgen", +] + +[[package]] +name = "amplify_syn" +version = "2.0.1" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "ascii" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16" +dependencies = [ + "serde", +] + +[[package]] +name = "ascii-armor" +version = "0.7.2" +dependencies = [ + "amplify 4.7.0", + "baid64", + "base85", + "sha2", + "strict_encoding", +] + +[[package]] +name = "autocfg" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" + +[[package]] +name = "aws-lc-rs" +version = "1.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7d844e282b4b56750b2d4e893b2205581ded8709fddd2b6aa5418c150ca877" +dependencies = [ + "aws-lc-sys", + "mirai-annotations", + "paste", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3a2c29203f6bf296d01141cc8bb9dbd5ecd4c27843f2ee0767bcd5985a927da" +dependencies = [ + "bindgen", + "cc", + "cmake", + "dunce", + "fs_extra", + "libc", + "paste", +] + +[[package]] +name = "backtrace" +version = "0.3.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "baid64" +version = "0.2.2" +dependencies = [ + "amplify 4.7.0", + "base64", + "mnemonic", + "sha2", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base85" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36915bbaca237c626689b5bd14d02f2ba7a5a359d30a2a08be697392e3718079" +dependencies = [ + "thiserror", +] + +[[package]] +name = "bech32" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" + +[[package]] +name = "bindgen" +version = "0.69.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" +dependencies = [ + "bitflags 2.5.0", + "cexpr", + "clang-sys", + "itertools", + "lazy_static", + "lazycell", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.66", + "which", +] + +[[package]] +name = "bitcoin-io" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "340e09e8399c7bd8912f495af6aa58bea0c9214773417ffaa8f6460f93aaee56" + +[[package]] +name = "bitcoin-private" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73290177011694f38ec25e165d0387ab7ea749a4b81cd4c80dae5988229f7a57" + +[[package]] +name = "bitcoin_hashes" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb18c03d0db0247e147a21a6faafd5a7eb851c743db062de72018b6b7e8e4d16" +dependencies = [ + "bitcoin-io", + "hex-conservative", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[package]] +name = "blake3" +version = "1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d82033247fd8e890df8f740e407ad4d038debb9eb1f40533fffb32e7d17dc6f7" +dependencies = [ + "arrayref", + "arrayvec", + "cc", + "cfg-if", + "constant_time_eq", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bp-consensus" +version = "0.11.0-beta.8" +dependencies = [ + "amplify 4.7.0", + "chrono", + "commit_verify", + "secp256k1", + "serde", + "strict_encoding", + "strict_types", +] + +[[package]] +name = "bp-core" +version = "0.11.0-beta.8" +dependencies = [ + "amplify 4.7.0", + "bp-consensus", + "bp-dbc", + "bp-seals", + "commit_verify", + "getrandom", + "serde", + "single_use_seals", + "strict_encoding", + "strict_types", + "wasm-bindgen", +] + +[[package]] +name = "bp-dbc" +version = "0.11.0-beta.8" +dependencies = [ + "amplify 4.7.0", + "base85", + "bp-consensus", + "commit_verify", + "secp256k1", + "serde", + "strict_encoding", +] + +[[package]] +name = "bp-derive" +version = "0.11.0-beta.8" +dependencies = [ + "amplify 4.7.0", + "bp-consensus", + "bp-invoice", + "commit_verify", + "hmac", + "indexmap 2.4.0", + "serde", + "sha2", +] + +[[package]] +name = "bp-electrum" +version = "0.11.0-beta.8.1" +dependencies = [ + "amplify 4.7.0", + "bp-std", + "byteorder", + "libc", + "log", + "rustls", + "serde", + "serde_json", + "sha2", + "webpki-roots", + "winapi", +] + +[[package]] +name = "bp-esplora" +version = "0.11.0-beta.8" +dependencies = [ + "amplify 4.7.0", + "bp-std", + "log", + "reqwest", + "serde", + "serde_with", + "sha2", + "ureq", +] + +[[package]] +name = "bp-invoice" +version = "0.11.0-beta.8" +dependencies = [ + "amplify 4.7.0", + "bech32", + "bp-consensus", + "commit_verify", + "serde", +] + +[[package]] +name = "bp-seals" +version = "0.11.0-beta.8" +dependencies = [ + "amplify 4.7.0", + "baid64", + "bp-consensus", + "bp-dbc", + "commit_verify", + "rand", + "serde", + "single_use_seals", + "strict_encoding", +] + +[[package]] +name = "bp-std" +version = "0.11.0-beta.8" +dependencies = [ + "amplify 4.7.0", + "bp-consensus", + "bp-derive", + "bp-invoice", + "descriptors", + "getrandom", + "psbt", + "secp256k1", + "serde", + "wasm-bindgen", +] + +[[package]] +name = "bp-wallet" +version = "0.11.0-beta.8" +dependencies = [ + "amplify 4.7.0", + "bp-electrum", + "bp-esplora", + "bp-std", + "descriptors", + "log", + "nonasync", + "psbt", + "serde", + "serde_json", + "serde_yaml", + "sha2", + "strict_encoding", + "toml", +] + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" + +[[package]] +name = "cc" +version = "1.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476" +dependencies = [ + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-targets 0.52.6", +] + +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "cmake" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +dependencies = [ + "cc", +] + +[[package]] +name = "commit_encoding_derive" +version = "0.11.0-beta.8" +dependencies = [ + "amplify 4.7.0", + "amplify_syn", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "commit_verify" +version = "0.11.0-beta.8" +dependencies = [ + "amplify 4.7.0", + "commit_encoding_derive", + "rand", + "ripemd", + "serde", + "sha2", + "strict_encoding", + "strict_types", + "vesper-lang", +] + +[[package]] +name = "constant_time_eq" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "darling" +version = "0.20.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54e36fcd13ed84ffdfda6f5be89b31287cbb80c439841fe69e04841435464391" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c2cf1c23a687a1feeb728783b993c4e1ad83d99f351801977dd809b48d0a70f" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.66", +] + +[[package]] +name = "darling_macro" +version = "0.20.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", + "serde", +] + +[[package]] +name = "descriptors" +version = "0.11.0-beta.8" +dependencies = [ + "amplify 4.7.0", + "bp-derive", + "indexmap 2.4.0", + "serde", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", + "subtle", +] + +[[package]] +name = "dunce" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" + +[[package]] +name = "either" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "fast32" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27ea9bdb2356e5a92403cf23ac493f9b43bd71e4ffd0f800862b841dd723994c" + +[[package]] +name = "fastrand" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "flate2" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "fluent-uri" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17c704e9dbe1ddd863da1e6ff3567795087b1eb201ce80d8fa81162e1516500d" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-executor" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-timer" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "half" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" +dependencies = [ + "cfg-if", + "crunchy", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-conservative" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5313b072ce3c597065a808dbf612c4c8e8590bdbf8b579508bf7a762c5eae6cd" +dependencies = [ + "arrayvec", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "hyper" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b875924a60b96e5d7b9ae7b066540b1dd1cbd90d1828f54c92e02a283351c56" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "socket2", + "tokio", + "tower", + "tower-service", + "tracing", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "indexmap" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" +dependencies = [ + "equivalent", + "hashbrown 0.14.3", + "serde", +] + +[[package]] +name = "ipnet" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "jobserver" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" +dependencies = [ + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "libc" +version = "0.2.153" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" + +[[package]] +name = "libloading" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" +dependencies = [ + "cfg-if", + "windows-targets 0.52.6", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "memchr" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + +[[package]] +name = "mirai-annotations" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9be0862c1b3f26a88803c4a49de6889c10e608b3ee9344e6ef5b45fb37ad3d1" + +[[package]] +name = "mnemonic" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b8f3a258db515d5e91a904ce4ae3f73e091149b90cadbdb93d210bee07f63b" + +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "nonasync" +version = "0.1.0" +dependencies = [ + "amplify 5.0.0-beta.1", + "log", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-traits" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "object" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "openssl" +version = "0.10.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +dependencies = [ + "bitflags 2.5.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "petgraph" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" +dependencies = [ + "fixedbitset", + "indexmap 2.4.0", +] + +[[package]] +name = "pin-project" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "prettyplease" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" +dependencies = [ + "proc-macro2", + "syn 2.0.66", +] + +[[package]] +name = "proc-macro2" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "psbt" +version = "0.11.0-beta.8" +dependencies = [ + "amplify 4.7.0", + "base64", + "bp-core", + "bp-derive", + "chrono", + "commit_verify", + "descriptors", + "indexmap 2.4.0", + "serde", + "strict_encoding", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "regex" +version = "1.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" + +[[package]] +name = "relative-path" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba39f3699c378cd8970968dcbff9c43159ea4cfbd88d43c00b22f2ef10a435d2" + +[[package]] +name = "reqwest" +version = "0.12.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" +dependencies = [ + "base64", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-tls", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-native-tls", + "tokio-socks", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "windows-registry", +] + +[[package]] +name = "rgb-core" +version = "0.11.0-beta.8" +dependencies = [ + "aluvm", + "amplify 4.7.0", + "baid64", + "bp-core", + "chrono", + "commit_verify", + "getrandom", + "mime", + "secp256k1-zkp", + "serde", + "single_use_seals", + "strict_encoding", + "strict_types", + "wasm-bindgen", +] + +[[package]] +name = "rgb-integration-tests" +version = "0.1.0" +dependencies = [ + "amplify 4.7.0", + "bitcoin_hashes", + "bp-core", + "bp-electrum", + "bp-esplora", + "bp-invoice", + "bp-std", + "bp-wallet", + "descriptors", + "once_cell", + "psbt", + "rand", + "rgb-interfaces", + "rgb-psbt", + "rgb-runtime", + "rgb-schemata", + "rgb-std", + "rstest", + "rstest_reuse", + "serde_yaml", + "strict_encoding", + "strict_types", + "strum", + "strum_macros", + "time", + "tree_magic_mini", +] + +[[package]] +name = "rgb-interfaces" +version = "0.11.0-beta.8" +dependencies = [ + "aluvm", + "amplify 4.7.0", + "bp-core", + "chrono", + "getrandom", + "rgb-std", + "serde_json", + "sha2", + "strict_encoding", + "strict_types", + "wasm-bindgen", +] + +[[package]] +name = "rgb-invoice" +version = "0.11.0-beta.8" +dependencies = [ + "amplify 4.7.0", + "baid64", + "bp-core", + "bp-invoice", + "fast32", + "fluent-uri", + "indexmap 2.4.0", + "percent-encoding", + "rand", + "rgb-core", + "serde", + "strict_encoding", + "strict_types", +] + +[[package]] +name = "rgb-psbt" +version = "0.11.0-beta.8" +dependencies = [ + "amplify 4.7.0", + "baid64", + "bp-core", + "bp-std", + "commit_verify", + "getrandom", + "psbt", + "rgb-std", + "strict_encoding", + "wasm-bindgen", +] + +[[package]] +name = "rgb-runtime" +version = "0.11.0-beta.8" +dependencies = [ + "amplify 4.7.0", + "baid64", + "bp-core", + "bp-electrum", + "bp-esplora", + "bp-std", + "bp-wallet", + "chrono", + "commit_verify", + "descriptors", + "getrandom", + "indexmap 2.4.0", + "nonasync", + "rgb-psbt", + "rgb-std", + "serde", + "serde_yaml", + "strict_types", + "wasm-bindgen", +] + +[[package]] +name = "rgb-schemata" +version = "0.11.0-beta.8" +dependencies = [ + "aluvm", + "amplify 4.7.0", + "bp-core", + "chrono", + "rgb-interfaces", + "rgb-std", + "serde", + "serde_json", + "sha2", + "strict_encoding", + "strict_types", +] + +[[package]] +name = "rgb-std" +version = "0.11.0-beta.8" +dependencies = [ + "aluvm", + "amplify 4.7.0", + "ascii-armor", + "baid64", + "base85", + "bp-core", + "chrono", + "commit_verify", + "getrandom", + "indexmap 2.4.0", + "nonasync", + "rand", + "rgb-core", + "rgb-invoice", + "serde", + "strict_encoding", + "strict_types", + "wasm-bindgen", +] + +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "ripemd" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" +dependencies = [ + "digest", +] + +[[package]] +name = "rstest" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d5316d2a1479eeef1ea21e7f9ddc67c191d497abc8fc3ba2467857abbb68330" +dependencies = [ + "futures", + "futures-timer", + "rstest_macros", + "rustc_version", +] + +[[package]] +name = "rstest_macros" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04a9df72cc1f67020b0d63ad9bfe4a323e459ea7eb68e03bd9824db49f9a4c25" +dependencies = [ + "cfg-if", + "glob", + "proc-macro2", + "quote", + "regex", + "relative-path", + "rustc_version", + "syn 2.0.66", + "unicode-ident", +] + +[[package]] +name = "rstest_reuse" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88530b681abe67924d42cca181d070e3ac20e0740569441a9e35a7cedd2b34a4" +dependencies = [ + "quote", + "rand", + "rustc_version", + "syn 2.0.66", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags 2.5.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls" +version = "0.23.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebbbdb961df0ad3f2652da8f3fdc4b36122f568f968f45ad3316f26c025c677b" +dependencies = [ + "aws-lc-rs", + "log", + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pemfile" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +dependencies = [ + "base64", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "beb461507cee2c2ff151784c52762cf4d9ff6a61f3e80968600ed24fa837fa54" + +[[package]] +name = "rustls-webpki" +version = "0.102.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3bce581c0dd41bce533ce695a1437fa16a7ab5ac3ccfa99fe1a620a7885eabf" +dependencies = [ + "aws-lc-rs", + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" + +[[package]] +name = "ryu" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" + +[[package]] +name = "schannel" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "secp256k1" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e0cc0f1cf93f4969faf3ea1c7d8a9faed25918d96affa959720823dfe86d4f3" +dependencies = [ + "rand", + "secp256k1-sys", + "serde", +] + +[[package]] +name = "secp256k1-sys" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1433bd67156263443f14d603720b082dd3121779323fce20cba2aa07b874bc1b" +dependencies = [ + "cc", +] + +[[package]] +name = "secp256k1-zkp" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52a44aed3002b5ae975f8624c5df3a949cfbf00479e18778b6058fcd213b76e3" +dependencies = [ + "bitcoin-private", + "rand", + "secp256k1", + "secp256k1-zkp-sys", + "serde", +] + +[[package]] +name = "secp256k1-zkp-sys" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c6eea7919e0cab992510edfbf40bd9342c0a3c2bb910f2c51355c2cb2d69839" +dependencies = [ + "cc", + "secp256k1-sys", +] + +[[package]] +name = "security-framework" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" + +[[package]] +name = "serde" +version = "1.0.198" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.198" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "serde_json" +version = "1.0.116" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_spanned" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_str_helpers" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b744a7c94f2f3785496af33a0d93857dfc0c521e25c38e993e9c5bb45f09c841" +dependencies = [ + "serde", + "serde_derive", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_with" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +dependencies = [ + "base64", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.4.0", + "serde", + "serde_derive", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "serde_yaml" +version = "0.9.34+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" +dependencies = [ + "indexmap 2.4.0", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "single_use_seals" +version = "0.11.0-beta.8" +dependencies = [ + "amplify_derive", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "socket2" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "socks" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0c3dbbd9ae980613c6dd8e28a9407b50509d3803b57624d5dfe8315218cd58b" +dependencies = [ + "byteorder", + "libc", + "winapi", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "strict_encoding" +version = "2.7.0" +dependencies = [ + "amplify 4.7.0", + "half", + "serde", + "strict_encoding_derive", + "wasm-bindgen", +] + +[[package]] +name = "strict_encoding_derive" +version = "2.7.0" +dependencies = [ + "amplify_syn", + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "strict_types" +version = "2.7.0" +dependencies = [ + "amplify 4.7.0", + "ascii-armor", + "baid64", + "half", + "indexmap 2.4.0", + "serde", + "serde_json", + "serde_yaml", + "sha2", + "strict_encoding", + "toml", + "vesper-lang", + "wasm-bindgen", +] + +[[package]] +name = "stringly_conversions" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff63080f492dd4d289ffcaed8d7ece38adfb423db910eb342c0e04d409536a7a" +dependencies = [ + "paste", + "serde_str_helpers", +] + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "strum" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.66", +] + +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +dependencies = [ + "futures-core", +] + +[[package]] +name = "tempfile" +version = "3.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +dependencies = [ + "cfg-if", + "fastrand", + "rustix", + "windows-sys 0.52.0", +] + +[[package]] +name = "thiserror" +version = "1.0.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "time" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-socks" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51165dfa029d2a65969413a6cc96f354b86b464498702f174a4efa13608fd8c0" +dependencies = [ + "either", + "futures-util", + "thiserror", + "tokio", +] + +[[package]] +name = "toml" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +dependencies = [ + "indexmap 2.4.0", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", + "pin-project-lite", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "tree_magic_mini" +version = "3.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469a727cac55b41448315cc10427c069c618ac59bb6a4480283fcd811749bdc2" +dependencies = [ + "fnv", + "home", + "memchr", + "nom", + "once_cell", + "petgraph", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-normalization" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unsafe-libyaml" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "ureq" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b74fc6b57825be3373f7054754755f03ac3a8f5d70015ccad699ba2029956f4a" +dependencies = [ + "base64", + "flate2", + "log", + "once_cell", + "rustls", + "rustls-pki-types", + "serde", + "serde_json", + "socks", + "url", + "webpki-roots", +] + +[[package]] +name = "url" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "vesper-lang" +version = "0.1.0" +dependencies = [ + "amplify 4.7.0", + "strict_encoding", +] + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.66", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" + +[[package]] +name = "web-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "0.26.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +dependencies = [ + "windows-result", + "windows-strings", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "0.6.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +dependencies = [ + "memchr", +] + +[[package]] +name = "zeroize" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63381fa6624bf92130a6b87c0d07380116f80b565c42cf0d754136f0238359ef" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..39a5aa0 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,124 @@ +[package] +name = "rgb-integration-tests" +version = "0.1.0" +authors = [ + "Zoe Faltibà ", + "Dr Maxim Orlovsky ", + "Nicola Busanello ", +] +edition = "2021" +rust-version = "1.75.0" +repository = "https://github.com/RGB-WG/rgb-integration-tests" +homepage = "https://github.com/RGB-WG/rgb-integration-tests" +license = "Apache-2.0" +description = "RGB integration tests" + +[dependencies] +bitcoin_hashes = "0.14.0" +once_cell = "1.19.0" +rand = "0.8.5" +rstest = "0.19.0" +rstest_reuse = "0.6.0" +serde_yaml = "0.9" +strum = { version = "0.26.2", features = ["derive"] } +strum_macros = "0.26.2" +time = "0.3.34" +tree_magic_mini = "3.1.5" + +# RGB-related deps +## bp-core +bp-core = { path = "./bp-core" } +## bp-electrum-client +bp-electrum = { path = "./bp-electrum-client" } +## bp-esplora +bp-esplora = { path = "./bp-esplora-client" } +## bp-std +bp-std = { path = "./bp-std", features = ["signers"] } +descriptors = { path = "./bp-std/descriptors" } +bp-invoice = { path = "./bp-std/invoice" } +psbt = { path = "./bp-std/psbt" } +## bp-wallet +bp-wallet = { path = "./bp-wallet", features = [ + "electrum", + "esplora", + "fs", +] } +## rgb +rgb-runtime = { path = "./rgb", features = [ + "electrum_blocking", + "esplora_blocking", + "fs", + "serde", +] } +rgb-psbt = { path = "./rgb/psbt" } +## rgb-interfaces +rgb-interfaces = { path = "./rgb-interfaces" } +## rgb-schemata +rgb-schemata = { path = "./rgb-schemata" } +## rgb-std +rgb-std = { path = "./rgb-std", features = ["fs"] } +## rust-amplify +amplify = { path = "./rust-amplify" } +## strict-encoding +strict_encoding = { path = "./strict-encoding/rust" } +## strict-types +strict_types = { path = "./strict-types" } + +[patch.crates-io] +# patching all RGB-related deps, to measure code coverage +## amplify-derive +amplify_derive = { path = "./amplify-derive" } +amplify_syn = { path = "./amplify-derive/syn" } +## amplify-nonasync +nonasync = { path = "./amplify-nonasync" } +## amplify-num +amplify_apfloat = { path = "./amplify-num/apfloat" } +amplify_num = { path = "./amplify-num/num" } +## ascii-armor +ascii-armor = { path = "./ascii-armor" } +## baid64 +baid64 = { path = "./rust-baid64" } +## bp-core +bp-core = { path = "./bp-core" } +bp-consensus = { path = "./bp-core/consensus" } +bp-dbc = { path = "./bp-core/dbc" } +bp-seals = { path = "./bp-core/seals" } +## bp-electrum-client +bp-electrum = { path = "./bp-electrum-client" } +## bp-esplora-client +bp-esplora = { path = "./bp-esplora-client" } +## bp-std +bp-derive = { path = "./bp-std/derive" } +bp-std = { path = "./bp-std" } +descriptors = { path = "./bp-std/descriptors" } +bp-invoice = { path = "./bp-std/invoice" } +psbt = { path = "./bp-std/psbt" } +## bp-wallet +bp-wallet = { path = "./bp-wallet" } +## client_side_validation +commit_verify = { path = "./client_side_validation/commit_verify" } +commit_encoding_derive = { path = "./client_side_validation/commit_verify/derive" } +single_use_seals = { path = "./client_side_validation/single_use_seals" } +## rgb +rgb-runtime = { path = "./rgb" } +rgb-psbt = { path = "./rgb/psbt" } +## rgb-core +rgb-core = { path = "./rgb-core" } +## rgb-interfaces +rgb-interfaces = { path = "./rgb-interfaces" } +## rgb-schemata +rgb-schemata = { path = "./rgb-schemata" } +## rgb-std +rgb-std = { path = "./rgb-std" } +rgb-invoice = { path = "./rgb-std/invoice" } +## rust-aluvm +aluvm = { path = "./rust-aluvm" } +## rust-amplify +amplify = { path = "./rust-amplify" } +## strict-encoding +strict_encoding = { path = "./strict-encoding/rust" } +strict_encoding_derive = { path = "./strict-encoding/rust/derive" } +## strict-types +strict_types = { path = "./strict-types" } +## vesper +vesper-lang = { path = "./vesper" } diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e1465cf --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright (c) 2024 RGB-Tools developers + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index 7b59799..3abee8b 100644 --- a/README.md +++ b/README.md @@ -1 +1,75 @@ # RGB integration tests + +This repository contains integration tests for RGB. + +## Requirements +- Linux OS +- Docker with its `compose` plugin +- Rust + +## Run +Clone the project, including submodules: + +```sh +git clone https://github.com/RGB-WG/rgb-integration-tests --recurse-submodules +``` + +Note: after checking out to another commit, remember to run: +```sh +git submodule update +``` + +Then, from the project root, run the integration tests by running: +```sh +cargo test +``` + +:warning: **Warning:** if your machine has a lot of CPU cores, it could +happen that calls to indexers fail because of too many parallel requests. To +limit the test threads and avoid this issue set the `--test-threads` option +(e.g. `cargo test -- --test-threads=8`). + +### Test services + +Test services will be automatically (re)started by the test command and will +run in docker containers. +If you don't have the docker images they will be automatically pulled. Note +that in this case the first test execution will be slower. +Also note that there's no automatic shutdown of test services, you'll need to +manually remove the docker containers with: +```sh +docker compose -f tests/docker-compose.yml --profile='*' down -v --remove-orphans +``` + +The indexer used by the tests is configurable, currently esplora and electrum +are supported. You can change the indexer type by setting the `INDEXER` +environment variable, for example: +```sh +INDEXER=esplora cargo test # default +INDEXER=electrum cargo test +``` + +If you are developing new tests and want a faster execution, you can set +`SKIP_INIT=1` to avoid restarting the test services. Please note that you +cannot switch to another indexer when using this option, you'll have to use the +same indexer type from the previous test execution. + +### Coverage + +To run the tests and generate a code coverage report run: +```sh +./tests/coverage.sh +``` +This will generate a report in `target/llvm-cov/html/index.html` that you can +visualize on a browser (e.g. `firefox target/llvm-cov/html/index.html`). + +Coverage will be measured for all patched crates. + +The GitHub organizations of submodule repositories are: +- https://github.com/RGB-WG +- https://github.com/LNP-BP +- https://github.com/BP-WG +- https://github.com/aluvm +- https://github.com/strict-types +- https://github.com/rust-amplify +- https://github.com/UBIDECO diff --git a/amplify-derive b/amplify-derive new file mode 160000 index 0000000..bb36a49 --- /dev/null +++ b/amplify-derive @@ -0,0 +1 @@ +Subproject commit bb36a490d68ccf7d574b5926bfc7f8b9509776f2 diff --git a/amplify-nonasync b/amplify-nonasync new file mode 160000 index 0000000..b1bf354 --- /dev/null +++ b/amplify-nonasync @@ -0,0 +1 @@ +Subproject commit b1bf3542060beabe3dcdf66517be6ee3eb2ac302 diff --git a/amplify-num b/amplify-num new file mode 160000 index 0000000..be035c1 --- /dev/null +++ b/amplify-num @@ -0,0 +1 @@ +Subproject commit be035c1ed260313217bd799bd47cbc9bdfdf27ec diff --git a/ascii-armor b/ascii-armor new file mode 160000 index 0000000..3d8b4cb --- /dev/null +++ b/ascii-armor @@ -0,0 +1 @@ +Subproject commit 3d8b4cb5a20c6ec5ec41fae4d88f3f0004917072 diff --git a/bp-core b/bp-core new file mode 160000 index 0000000..923f728 --- /dev/null +++ b/bp-core @@ -0,0 +1 @@ +Subproject commit 923f728cefd2682462387e7f16b2967e22860237 diff --git a/bp-electrum-client b/bp-electrum-client new file mode 160000 index 0000000..5e35c13 --- /dev/null +++ b/bp-electrum-client @@ -0,0 +1 @@ +Subproject commit 5e35c13052e42757868963510730c96724347a17 diff --git a/bp-esplora-client b/bp-esplora-client new file mode 160000 index 0000000..d930558 --- /dev/null +++ b/bp-esplora-client @@ -0,0 +1 @@ +Subproject commit d930558ab30ecc2cf6d76f268fbc94aea35c7a26 diff --git a/bp-std b/bp-std new file mode 160000 index 0000000..6dd564c --- /dev/null +++ b/bp-std @@ -0,0 +1 @@ +Subproject commit 6dd564c90452ad8b358a6f9f3262114227a88d58 diff --git a/bp-wallet b/bp-wallet new file mode 160000 index 0000000..7487a1c --- /dev/null +++ b/bp-wallet @@ -0,0 +1 @@ +Subproject commit 7487a1c10c07ec313f1b8d77ce5acf41a8389cea diff --git a/client_side_validation b/client_side_validation new file mode 160000 index 0000000..cc3780a --- /dev/null +++ b/client_side_validation @@ -0,0 +1 @@ +Subproject commit cc3780aa01873067ef2370f870ddd3f4a52fd82b diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..a973dba --- /dev/null +++ b/codecov.yml @@ -0,0 +1,6 @@ +coverage: + status: + project: + default: + target: 100% + threshold: 3% diff --git a/rgb b/rgb new file mode 160000 index 0000000..56f8d4c --- /dev/null +++ b/rgb @@ -0,0 +1 @@ +Subproject commit 56f8d4cdedf85c728505d07d8452a3916cb70565 diff --git a/rgb-core b/rgb-core new file mode 160000 index 0000000..8be4962 --- /dev/null +++ b/rgb-core @@ -0,0 +1 @@ +Subproject commit 8be49626a968a45fc868db1e1454095b75349c17 diff --git a/rgb-interfaces b/rgb-interfaces new file mode 160000 index 0000000..5acc09c --- /dev/null +++ b/rgb-interfaces @@ -0,0 +1 @@ +Subproject commit 5acc09c2387f8d1f7eb0393983415d2d523225b4 diff --git a/rgb-schemata b/rgb-schemata new file mode 160000 index 0000000..954cfd8 --- /dev/null +++ b/rgb-schemata @@ -0,0 +1 @@ +Subproject commit 954cfd867e963f1f4c39eea3067fd2183d26f896 diff --git a/rgb-std b/rgb-std new file mode 160000 index 0000000..94aeb57 --- /dev/null +++ b/rgb-std @@ -0,0 +1 @@ +Subproject commit 94aeb57a3db7dfe89b8c03bd4a90a8eabae09ff3 diff --git a/rust-aluvm b/rust-aluvm new file mode 160000 index 0000000..55d53be --- /dev/null +++ b/rust-aluvm @@ -0,0 +1 @@ +Subproject commit 55d53be7badaecb3b258007c72d0afb533e66172 diff --git a/rust-amplify b/rust-amplify new file mode 160000 index 0000000..d01b9f5 --- /dev/null +++ b/rust-amplify @@ -0,0 +1 @@ +Subproject commit d01b9f52c23e839c6620f68d1bf9099152178f6d diff --git a/rust-baid64 b/rust-baid64 new file mode 160000 index 0000000..983854a --- /dev/null +++ b/rust-baid64 @@ -0,0 +1 @@ +Subproject commit 983854a1b9be7c2cd7d98b00ab4df3e633be393a diff --git a/strict-encoding b/strict-encoding new file mode 160000 index 0000000..b11845c --- /dev/null +++ b/strict-encoding @@ -0,0 +1 @@ +Subproject commit b11845c2d811d87c69a597b6602914141ca31227 diff --git a/strict-types b/strict-types new file mode 160000 index 0000000..f72bb5b --- /dev/null +++ b/strict-types @@ -0,0 +1 @@ +Subproject commit f72bb5b91132ebd403051df5ae42820b2f6c43c1 diff --git a/tests/coverage.sh b/tests/coverage.sh new file mode 100755 index 0000000..66a4ba4 --- /dev/null +++ b/tests/coverage.sh @@ -0,0 +1,59 @@ +#!/bin/bash -e +# +# script to run project tests and report code coverage +# uses llvm-cov (https://github.com/taiki-e/cargo-llvm-cov) + +LLVM_COV_OPTS="" +CARGO_TEST_OPTS="" + +_die() { + echo "err $*" + exit 1 +} + +_tit() { + echo + echo "========================================" + echo "$@" + echo "========================================" +} + +help() { + echo "$NAME [-h|--help] [-t|--test] [--no-clean]" + echo "" + echo "options:" + echo " -h --help show this help message" + echo " -t --test only run these test(s)" + echo " --no-clean don't cleanup before the run" +} + +# cmdline arguments +while [ -n "$1" ]; do + case $1 in + -h|--help) + help + exit 0 + ;; + -t|--test) + CARGO_TEST_OPTS="-- $2" + shift + ;; + *) + help + _die "unsupported argument \"$1\"" + ;; + esac + shift +done + +_tit "installing requirements" +rustup component add llvm-tools-preview +cargo install cargo-llvm-cov + +_tit "generating coverage report" +# shellcheck disable=2086 +INDEXER=esplora cargo llvm-cov --html $LLVM_COV_OPTS $CARGO_TEST_OPTS +INDEXER=electrum cargo llvm-cov --no-clean --html $LLVM_COV_OPTS $CARGO_TEST_OPTS + +## show html report location +echo "generated html report: target/llvm-cov/html/index.html" diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml new file mode 100644 index 0000000..197c884 --- /dev/null +++ b/tests/docker-compose.yml @@ -0,0 +1,26 @@ +version: '3.2' + +services: + bitcoind: + image: registry.gitlab.com/hashbeam/docker/bitcoind:25.0 + profiles: [electrum] + command: "-fallbackfee=0.0002" + electrs: + image: registry.gitlab.com/hashbeam/docker/electrs:0.9.14 + profiles: [electrum] + ports: + - 50001:50001 + depends_on: + - bitcoind + esplora: + image: blockstream/esplora:956c74f42eb6ad803d8aedc272ba83d3aa6dcf5c + profiles: [esplora] + command: /srv/explorer/run.sh bitcoin-regtest explorer + environment: + DEBUG: verbose + NO_PRECACHE: 1 + NO_ADDRESS_SEARCH: 1 + NO_REGTEST_MINING: 1 + ports: + - 50002:50001 + - 8094:80 diff --git a/tests/fixtures/rgb_logo.jpeg b/tests/fixtures/rgb_logo.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..00b3c3e8a05cee429c5025df44e76d2435c12eaa GIT binary patch literal 4553 zcmbW4cTiL7y2cm12qG9zM7l^5l_pKd1_T6*5FkXlfYOTyNG~FYM2fUf1qlQUErNg) zQRzqvJpzK#t4Il*=FZ%?_r5dFn)zmZ|NP!(eebs($~Vds5DhRhGBPnT zFf%bRv9K_+vVqvyPMu=oz>|4Be#Q1G+pnCG!C;t(mRY3ay}%&crwVG+8xj?S*`uRX&fqhsUvZxfTVbMp&}OUo;(Yuh`!ggxT^!Ql}NK=&^k>hoVf|AmK> z%0o*}Pe;%6Cl3v609ACH^bEqXj9i*fCVQW=B63feL0ZWLRV^%{@+Mo{4v&Xec`hl; zif#Xi^iQJy9Z=N&i|8+)zj!E<02>_*)i63v01RveOQ0I#TM-g(X#Z9R9jl}Z>Wdht z#*{_^UDP2BKy^TWidh1M0RFq;jjy9SK&I~)K(&{y8~RFhuzBn#=|GKcnK>+MAd6rH z#Vh#6!Z~JKM&1K2P(*@Xw%)Te&m3dVU-%x=uDK9=f$JxMS^+iSUk+V5`OCaF=yQCzJ-WNrh=nj__b1(bCafLuRNUnCB>H1 zHQcRtZ$(-+E&#>w-eQrAL<`FFYJCy!=g6Eu>*qZ{Ft9 z(^>Wrl$BNUG=9IT_4tSbQ|^XOP*-xUi2S-fe-7Msx;iAZDYq_XwkfB-+9*?4qi_kV zY5Q{aGs{;6#|`sdkm&QgyELTW)D7wCVG^gOOOy>HrhPgTt*mpjuQm3Eq&iMpEL>T=&faP_eNU}uZtf=*aaoo7fiZ#Uq`t%^~{$HJ|X-2Aj>(k?JalK zMxjHzJw?Tb#hX3x>2zI|3{sa9Kd$1hDqeZmd*R*W3V#>}LA^}WbZfe|v)KZ-3tojIIOYh4?6dK>xw+Z)>|3AI04R8vW^fR(;Mz?8jp9*+*9d9xQH- z;&CM0HST0xY;)`oF$Ao4B;V^QMJ_0scE!b+`h^wQ#*(BGLS$1?8a141FQhrmLM;j; zC0z;%h5y4HO9s&3*9w`d*SvU6xnx^dq289kvqL9u6uq)*XR)d5Ijt?ZPwEIB&p=PO zB72a?Re?Xgf9q8m-7in#b$Mnw!rmvDlXL%`W7##I6Ze*q*Sf{Rnq``+OOH&u$cL_P zvi*?vHHBY%b&u52os!e2SFYUb?aKB~D4nu$sqp3^>TBW}x)<+OROYOm`-s{c%V2FXu&!bK9q(%dAm{L>WrP4f+jhVE)>zgK3S6}KH zO14x+ZE$8U`!jxVBX0RFx$IxhelKF2;>A|>tmXVqGI!rvIFJ4*!w0uK@x9)S;jy)T z4Mo^DB__rJFV(8D!UcIx8w`D3YUW*n^XyFaION^XBxw=1s3RljD=7L20EU^Q4?Y*-3lMS z`esd8Q`*-XrSX4|S1+AC@PYYcZ)gZGfB(@T^*r%5)WXQ8|GrzcuWNQLF`--c(5N&o zb_e^kOl!0d=HD0*v^!?s3o)}X;@j3pIby7PKlRW)?J${>Bz_ZnxZw((m1&>=`7WR3 zZR6%-xcw_c3?Bhm;enY%d$PK8*Mqp(^!a3iMy~RbD(*d%hb|5)Xj2P4?Um}#<+FEF z6L=@~D1dwfnQJQlaPQ@=qT7!yIP##QNM_H`8qK|8$fRX3AYO50T~N#!MiyKMNDejm z9PLwLC3tWa)_%}}5hu0&;vlh?4M>c( zl|;0zkAYV>ohd+AZBPt%29eQ<0%&B+P=G$%I_z^Mp_95h|1f%j0{rka{@lr~PXU(B zxqyFq+WP849#}k{Od&<|x%1k1iZwe*t+H^L>a*<`-5P;py)OTa2s+YQZ1m~gkYeJC@B|wW+9_@>95#x< zCZoA;Dv9oraEvlW9Ni?UXSh~;HtCN+NX56Y`$p4ueQtnbP9g-C_pqkf(-q5sIi1R-7D0h&(yCh-aNZ{_d^IK!1c~kOVR^0{)?KQIALYyDT zUV_vd32Lb)m}BeX)6&PgCOZxE^*ve<3^Ep)h&v`jf3WBZV(f zkHWCjHB+l0UEw%KTZF9bbDQVH)MaGvu8I%03S4SBsYFB}MM_94^Cu0Y;x*5ddl>qN zpn2jxliL6r09D#G)f!%7gV64Tn{V(`nLo~x-!TZ<4QitJz2$zpS=B?I{pRuj=(roY%NHf zBO6(Y7zH1!nbdHRKWJDg%0RBIKd!7|c1V4@y!nApUT#jvMBdO{(Us;-E96$!?69}g z*jMuH>I@C-#e5;@46^r^x{a@93Gq1rk4>vc;AA3J7K?h2AeK;=tSw4gUQ)nR8|WOT z03WQ)syKb;*6)}kKXvfc{FpFC$jhaqcgS^b?UlzDy>AK#gj6(xfAVS}G!1Q63HCZ5 zQxAYp^k(d(ny=3dj_v+_OX4np$XRvd)?po>&x?XA`1a%@-_TbV%>7x1&}F%D#btMOS%Ghjfxe zyOXjMpx`aJcBz8e+m9Z-F4Qkb8_Usj!R5`6t^TkW2x=mPE_!1eX=!O-S&*;4vg0|j zU}qjrPJlZFWeI^g7aTPMzQ6*;9WS4ncZOgUgWaY`}7^C3F0eWJv zzH+ll$Ic_(aX;NaM|OYD!5q(UdxtW_(^7MK8wYv#06Scx+g!J3( zf#(Vp4{-D$o?g}KiHINVVC=kgb65xKPzA&+vG3$`jLUd&sh-nSS9u-os&{XAglJL% zX&d?6?W!%Km1lw+f5ZIL&Wh%I5EOZowHa|Vh5-i?A5Zewj**g-xUI5n`~9TN-eLRe ziK|eWRK&Z_5?`=3nLNp*fs>d*vz4(_opWLys{s^XuOous0MGqEZQ5^i>V>dDGU0y2 z{8|M1k@#=Hiok~KVK8`bt!?ju3+kDzw(2buLh2R>s`KZhhng`B)1x23F`;P{lUp5mXw;uPgOV}m zPc}wkJa7|k&hAHM!Q-ilIX_kS3cWY$SKQkd6MkmRr5kj|!_xNX;mt^_%E43AizSFT zeQWmJ>H1)Jp+q`9GmPZXz41l%y3l9XHQbCrU>n6;qVp zy1Z;9LWqor=D@@x?2ncAUUeC=`ORl{Vz++najzVSza*U4J<$1t^NUza%_})c{c(uz zotNwR77-LO^qcG)_o8>%5LT)hM(Ff%lOgb6A(A? za)Xe{wAGun;TQmStcP~S`OCCDoJ#CbHB+2(@KrIKMx%a@u9w6bTCi>o%Q`#sg=Bkz z;IF2VdM^ zxT^f066#FT|x%HDE0bOU< z?De(yaLG*)LP;Is_&uQFWnOVrWfs&TGm`02YCL>&baKmJ29Vjwn4Nr`^7$c73V(RS6u zxXYg68c-D%yEN~%52NNVZUcxKO3F0m_D;Wz0Afb{UB+Fxk8(12BOyQWiDv2eF~#0# z7%unN0mmuM3hsRGQsMjpqu4XiuT7)%>~RzYh~z~f?u;v`F`!ZqaH^k@|3e!7D(contract_id); + let spec = contract.spec(); + assert_eq!(spec.ticker.to_string(), ticker.to_string()); + assert_eq!(spec.name.to_string(), name.to_string()); + assert_eq!(spec.precision.decimals(), precision); + let terms = contract.contract_terms(); + assert_eq!(terms.text.to_string(), terms_text.to_string()); + let terms_media = terms.media.unwrap(); + assert_eq!(terms_media.ty.to_string(), "image/jpeg"); + assert_eq!( + terms_media.digest.to_string(), + "02d2cc5d7883885bb7472e4fe96a07344b1d7cf794cb06943e1cdb5c57754d8a" + ); + assert_eq!(contract.total_issued_supply().value(), issued_supply); + + let allocations = wallet.contract_fungible_allocations(&contract_iface); + assert_eq!(allocations.len(), 1); + let allocation = allocations[0]; + assert_eq!(allocation.seal.method(), close_method); + assert_eq!(allocation.state, Amount::from(issued_supply)); +} + +#[apply(descriptor_and_close_method)] +fn issue_uda(wallet_desc: DescriptorType, close_method: CloseMethod) { + println!("wallet_desc {wallet_desc:?} close_method {close_method:?}"); + + initialize(); + + let mut wallet = get_wallet(&wallet_desc); + + let ticker = "TCKR"; + let name = "asset name"; + let details = Some("some details"); + let terms_text = "Ricardian contract"; + let terms_media_fpath = Some(MEDIA_FPATH); + let data = vec![1u8, 3u8, 9u8]; + let preview_ty = "image/jpeg"; + let token_data_preview = EmbeddedMedia { + ty: MediaType::with(preview_ty), + data: Confined::try_from(data.clone()).unwrap(), + }; + let proof = vec![2u8, 4u8, 6u8, 10u8]; + let token_data_reserves = ProofOfReserves { + utxo: Outpoint::from_str(FAKE_TXID).unwrap(), + proof: Confined::try_from(proof.clone()).unwrap(), + }; + let token_data_ticker = "TDTCKR"; + let token_data_name = "token data name"; + let token_data_details = "token data details"; + let token_data_attachment = attachment_from_fpath(MEDIA_FPATH); + let mut token_data_attachments = BTreeMap::new(); + for (idx, attachment_fpath) in ["README.md", "Cargo.toml"].iter().enumerate() { + token_data_attachments.insert(idx as u8, attachment_from_fpath(attachment_fpath)); + } + let token_data = uda_token_data( + token_data_ticker, + token_data_name, + token_data_details, + token_data_preview.clone(), + token_data_attachment.clone(), + token_data_attachments.clone(), + token_data_reserves.clone(), + ); + let asset_info = AssetInfo::uda( + ticker, + name, + details, + terms_text, + terms_media_fpath, + token_data, + ); + let (contract_id, iface_type_name) = wallet.issue_with_info(asset_info, close_method, None); + + let contract_iface = wallet.contract_iface(contract_id, &iface_type_name); + let contract = wallet.contract_iface_class::(contract_id); + let spec = contract.spec(); + assert_eq!(spec.ticker.to_string(), ticker.to_string()); + assert_eq!(spec.name.to_string(), name.to_string()); + assert_eq!(spec.precision.decimals(), 0); + let terms = contract.contract_terms(); + assert_eq!(terms.text.to_string(), terms_text.to_string()); + let terms_media = terms.media.unwrap(); + assert_eq!(terms_media.ty.to_string(), "image/jpeg"); + assert_eq!( + terms_media.digest.to_string(), + "02d2cc5d7883885bb7472e4fe96a07344b1d7cf794cb06943e1cdb5c57754d8a" + ); + let token_data = contract.token_data(); + assert_eq!(token_data.index, TokenIndex::from_inner(0)); + assert_eq!(token_data.ticker.unwrap().to_string(), token_data_ticker); + assert_eq!(token_data.name.unwrap().to_string(), token_data_name); + assert_eq!(token_data.details.unwrap().to_string(), token_data_details); + assert_eq!(token_data.preview.unwrap(), token_data_preview); + assert_eq!(token_data.media.unwrap(), token_data_attachment); + assert_eq!( + token_data.attachments.to_unconfined(), + token_data_attachments + ); + assert_eq!(token_data.reserves.unwrap(), token_data_reserves); + + let allocations = wallet.contract_data_allocations(&contract_iface); + assert_eq!(allocations.len(), 1); + let allocation = &allocations[0]; + assert_eq!(allocation.seal.method(), close_method); + assert_eq!(allocation.state.to_string(), "000000000100000000000000"); +} + +#[apply(descriptor_and_close_method)] +fn issue_cfa(wallet_desc: DescriptorType, close_method: CloseMethod) { + println!("wallet_desc {wallet_desc:?} close_method {close_method:?}"); + + initialize(); + + let mut wallet = get_wallet(&wallet_desc); + + let issued_supply = 999; + let name = "asset name"; + let precision = 2; + let details = Some("some details"); + let terms_text = "Ricardian contract"; + let terms_media_fpath = Some(MEDIA_FPATH); + let asset_info = AssetInfo::cfa( + name, + precision, + details, + terms_text, + terms_media_fpath, + issued_supply, + ); + let (contract_id, iface_type_name) = wallet.issue_with_info(asset_info, close_method, None); + + let contract_iface = wallet.contract_iface(contract_id, &iface_type_name); + let contract = wallet.contract_iface_class::(contract_id); + assert_eq!(contract.name().to_string(), name.to_string()); + assert_eq!( + contract.details().map(|d| d.to_string()), + details.map(|d| d.to_string()) + ); + assert_eq!(contract.precision().decimals(), precision); + let terms = contract.contract_terms(); + assert_eq!(terms.text.to_string(), terms_text.to_string()); + let terms_media = terms.media.unwrap(); + assert_eq!(terms_media.ty.to_string(), "image/jpeg"); + assert_eq!( + terms_media.digest.to_string(), + "02d2cc5d7883885bb7472e4fe96a07344b1d7cf794cb06943e1cdb5c57754d8a" + ); + assert_eq!(contract.total_issued_supply().value(), issued_supply); + + let allocations = wallet.contract_fungible_allocations(&contract_iface); + assert_eq!(allocations.len(), 1); + let allocation = allocations[0]; + assert_eq!(allocation.seal.method(), close_method); + assert_eq!(allocation.state, Amount::from(issued_supply)); +} diff --git a/tests/start_services.sh b/tests/start_services.sh new file mode 100755 index 0000000..3f41528 --- /dev/null +++ b/tests/start_services.sh @@ -0,0 +1,69 @@ +#!/bin/bash +set -eu + +_die () { + echo "ERR: $*" + exit 1 +} + +COMPOSE_BASE="docker compose" +if ! $COMPOSE_BASE >/dev/null; then + echo "could not call docker compose (hint: install docker compose plugin)" + exit 1 +fi +COMPOSE_BASE="$COMPOSE_BASE -f tests/docker-compose.yml" +PROFILE=${PROFILE:-"esplora"} +COMPOSE="$COMPOSE_BASE --profile $PROFILE" +TEST_DIR="./tests/tmp" + +# see docker-compose.yml for the exposed ports +if [ "$PROFILE" == "esplora" ]; then + BCLI="$COMPOSE exec -T esplora cli" + EXPOSED_PORTS=(8094 50002) +elif [ "$PROFILE" == "electrum" ]; then + BCLI="$COMPOSE exec -T -u blits bitcoind bitcoin-cli -regtest" + EXPOSED_PORTS=(50001) +else + _die "invalid profile" +fi + +# restart services (down + up) checking for ports availability +$COMPOSE_BASE --profile '*' down -v --remove-orphans +rm -rf $TEST_DIR +mkdir -p $TEST_DIR +for port in "${EXPOSED_PORTS[@]}"; do + if [ -n "$(ss -HOlnt "sport = :$port")" ];then + _die "port $port is already bound, services can't be started" + fi +done +$COMPOSE up -d + +# wait for services (pre-mining) +if [ "$PROFILE" == "esplora" ]; then + # wait for esplora to have completed setup + until $COMPOSE logs esplora |grep -q 'Bootstrapped 100%'; do + sleep 1 + done +elif [ "$PROFILE" == "electrum" ]; then + # wait for bitcoind to be up + until $COMPOSE logs bitcoind |grep 'Bound to'; do + sleep 1 + done +fi + +# prepare bitcoin funds +$BCLI createwallet miner +$BCLI -rpcwallet=miner -generate 103 + +# wait for services (post-mining) +if [ "$PROFILE" == "esplora" ]; then + # wait for esplora to have completed setup + until $COMPOSE logs esplora |grep -q 'Electrum RPC server running'; do + sleep 1 + done +elif [ "$PROFILE" == "electrum" ]; then + # wait for electrs to have completed startup + until $COMPOSE logs electrs |grep 'finished full compaction'; do + sleep 1 + done +fi diff --git a/tests/transfers.rs b/tests/transfers.rs new file mode 100644 index 0000000..083b3c5 --- /dev/null +++ b/tests/transfers.rs @@ -0,0 +1,769 @@ +pub mod utils; + +use utils::*; + +type TT = TransferType; +type DT = DescriptorType; +type AS = AssetSchema; + +#[rstest] +// blinded: nia - nia +#[case(TT::Blinded, DT::Wpkh, DT::Wpkh, AS::Nia, AS::Nia)] +#[case(TT::Blinded, DT::Wpkh, DT::Tr, AS::Nia, AS::Nia)] +#[case(TT::Blinded, DT::Tr, DT::Wpkh, AS::Nia, AS::Nia)] +#[case(TT::Blinded, DT::Tr, DT::Tr, AS::Nia, AS::Nia)] +// blinded: nia - cfa +#[case(TT::Blinded, DT::Wpkh, DT::Wpkh, AS::Nia, AS::Cfa)] +#[case(TT::Blinded, DT::Wpkh, DT::Tr, AS::Nia, AS::Cfa)] +#[case(TT::Blinded, DT::Tr, DT::Wpkh, AS::Nia, AS::Cfa)] +#[case(TT::Blinded, DT::Tr, DT::Tr, AS::Nia, AS::Cfa)] +// blinded: nia - uda +#[case(TT::Blinded, DT::Wpkh, DT::Wpkh, AS::Nia, AS::Uda)] +#[case(TT::Blinded, DT::Wpkh, DT::Tr, AS::Nia, AS::Uda)] +#[case(TT::Blinded, DT::Tr, DT::Wpkh, AS::Nia, AS::Uda)] +#[case(TT::Blinded, DT::Tr, DT::Tr, AS::Nia, AS::Uda)] +// blinded: cfa - cfa +#[case(TT::Blinded, DT::Wpkh, DT::Wpkh, AS::Cfa, AS::Cfa)] +#[case(TT::Blinded, DT::Wpkh, DT::Tr, AS::Cfa, AS::Cfa)] +#[case(TT::Blinded, DT::Tr, DT::Wpkh, AS::Cfa, AS::Cfa)] +#[case(TT::Blinded, DT::Tr, DT::Tr, AS::Cfa, AS::Cfa)] +// blinded: cfa - nia +#[case(TT::Blinded, DT::Wpkh, DT::Wpkh, AS::Cfa, AS::Nia)] +#[case(TT::Blinded, DT::Wpkh, DT::Tr, AS::Cfa, AS::Nia)] +#[case(TT::Blinded, DT::Tr, DT::Wpkh, AS::Cfa, AS::Nia)] +#[case(TT::Blinded, DT::Tr, DT::Tr, AS::Cfa, AS::Nia)] +// blinded: cfa - uda +#[case(TT::Blinded, DT::Wpkh, DT::Wpkh, AS::Cfa, AS::Uda)] +#[case(TT::Blinded, DT::Wpkh, DT::Tr, AS::Cfa, AS::Uda)] +#[case(TT::Blinded, DT::Tr, DT::Wpkh, AS::Cfa, AS::Uda)] +#[case(TT::Blinded, DT::Tr, DT::Tr, AS::Cfa, AS::Uda)] +// blinded: uda - uda +#[case(TT::Blinded, DT::Wpkh, DT::Wpkh, AS::Uda, AS::Uda)] +#[case(TT::Blinded, DT::Wpkh, DT::Tr, AS::Uda, AS::Uda)] +#[case(TT::Blinded, DT::Tr, DT::Wpkh, AS::Uda, AS::Uda)] +#[case(TT::Blinded, DT::Tr, DT::Tr, AS::Uda, AS::Uda)] +// blinded: uda - nia +#[case(TT::Blinded, DT::Wpkh, DT::Wpkh, AS::Uda, AS::Nia)] +#[case(TT::Blinded, DT::Wpkh, DT::Tr, AS::Uda, AS::Nia)] +#[case(TT::Blinded, DT::Tr, DT::Wpkh, AS::Uda, AS::Nia)] +#[case(TT::Blinded, DT::Tr, DT::Tr, AS::Uda, AS::Nia)] +// blinded: uda - cfa +#[case(TT::Blinded, DT::Wpkh, DT::Wpkh, AS::Uda, AS::Cfa)] +#[case(TT::Blinded, DT::Wpkh, DT::Tr, AS::Uda, AS::Cfa)] +#[case(TT::Blinded, DT::Tr, DT::Wpkh, AS::Uda, AS::Cfa)] +#[case(TT::Blinded, DT::Tr, DT::Tr, AS::Uda, AS::Cfa)] +// witness: nia - nia +#[case(TT::Witness, DT::Wpkh, DT::Wpkh, AS::Nia, AS::Nia)] +#[case(TT::Witness, DT::Wpkh, DT::Tr, AS::Nia, AS::Nia)] +#[case(TT::Witness, DT::Tr, DT::Wpkh, AS::Nia, AS::Nia)] +#[case(TT::Witness, DT::Tr, DT::Tr, AS::Nia, AS::Nia)] +// witness: nia - cfa +#[case(TT::Witness, DT::Wpkh, DT::Wpkh, AS::Nia, AS::Cfa)] +#[case(TT::Witness, DT::Wpkh, DT::Tr, AS::Nia, AS::Cfa)] +#[case(TT::Witness, DT::Tr, DT::Wpkh, AS::Nia, AS::Cfa)] +#[case(TT::Witness, DT::Tr, DT::Tr, AS::Nia, AS::Cfa)] +// witness: nia - uda +#[case(TT::Witness, DT::Wpkh, DT::Wpkh, AS::Nia, AS::Uda)] +#[case(TT::Witness, DT::Wpkh, DT::Tr, AS::Nia, AS::Uda)] +#[case(TT::Witness, DT::Tr, DT::Wpkh, AS::Nia, AS::Uda)] +#[case(TT::Witness, DT::Tr, DT::Tr, AS::Nia, AS::Uda)] +// witness: cfa - cfa +#[case(TT::Witness, DT::Wpkh, DT::Wpkh, AS::Cfa, AS::Cfa)] +#[case(TT::Witness, DT::Wpkh, DT::Tr, AS::Cfa, AS::Cfa)] +#[case(TT::Witness, DT::Tr, DT::Wpkh, AS::Cfa, AS::Cfa)] +#[case(TT::Witness, DT::Tr, DT::Tr, AS::Cfa, AS::Cfa)] +// witness: cfa - nia +#[case(TT::Witness, DT::Wpkh, DT::Wpkh, AS::Cfa, AS::Nia)] +#[case(TT::Witness, DT::Wpkh, DT::Tr, AS::Cfa, AS::Nia)] +#[case(TT::Witness, DT::Tr, DT::Wpkh, AS::Cfa, AS::Nia)] +#[case(TT::Witness, DT::Tr, DT::Tr, AS::Cfa, AS::Nia)] +// witness: cfa - uda +#[case(TT::Witness, DT::Wpkh, DT::Wpkh, AS::Cfa, AS::Uda)] +#[case(TT::Witness, DT::Wpkh, DT::Tr, AS::Cfa, AS::Uda)] +#[case(TT::Witness, DT::Tr, DT::Wpkh, AS::Cfa, AS::Uda)] +#[case(TT::Witness, DT::Tr, DT::Tr, AS::Cfa, AS::Uda)] +// witness: uda - uda +#[case(TT::Witness, DT::Wpkh, DT::Wpkh, AS::Uda, AS::Uda)] +#[case(TT::Witness, DT::Wpkh, DT::Tr, AS::Uda, AS::Uda)] +#[case(TT::Witness, DT::Tr, DT::Wpkh, AS::Uda, AS::Uda)] +#[case(TT::Witness, DT::Tr, DT::Tr, AS::Uda, AS::Uda)] +// witness: uda - nia +#[case(TT::Witness, DT::Wpkh, DT::Wpkh, AS::Uda, AS::Nia)] +#[case(TT::Witness, DT::Wpkh, DT::Tr, AS::Uda, AS::Nia)] +#[case(TT::Witness, DT::Tr, DT::Wpkh, AS::Uda, AS::Nia)] +#[case(TT::Witness, DT::Tr, DT::Tr, AS::Uda, AS::Nia)] +// witness: uda - cfa +#[case(TT::Witness, DT::Wpkh, DT::Wpkh, AS::Uda, AS::Cfa)] +#[case(TT::Witness, DT::Wpkh, DT::Tr, AS::Uda, AS::Cfa)] +#[case(TT::Witness, DT::Tr, DT::Wpkh, AS::Uda, AS::Cfa)] +#[case(TT::Witness, DT::Tr, DT::Tr, AS::Uda, AS::Cfa)] +fn transfer_loop( + #[case] transfer_type: TransferType, + #[case] wlt_1_desc: DescriptorType, + #[case] wlt_2_desc: DescriptorType, + #[case] asset_schema_1: AssetSchema, + #[case] asset_schema_2: AssetSchema, +) { + println!( + "transfer_type {transfer_type:?} wlt_1_desc {wlt_1_desc:?} wlt_2_desc {wlt_2_desc:?} \ + asset_schema_1 {asset_schema_1:?} asset_schema_2 {asset_schema_2:?}" + ); + + initialize(); + + let mut wlt_1 = get_wallet(&wlt_1_desc); + let mut wlt_2 = get_wallet(&wlt_2_desc); + + let issued_supply_1 = 999; + let issued_supply_2 = 666; + + let mut sats = 9000; + + // wlt_1 issues 2 assets on the same UTXO + let utxo = wlt_1.get_utxo(None); + let (contract_id_1, iface_type_name_1) = match asset_schema_1 { + AssetSchema::Nia => wlt_1.issue_nia(issued_supply_1, wlt_1.close_method(), Some(&utxo)), + AssetSchema::Uda => wlt_1.issue_uda(wlt_1.close_method(), Some(&utxo)), + AssetSchema::Cfa => wlt_1.issue_cfa(issued_supply_1, wlt_1.close_method(), Some(&utxo)), + }; + let (contract_id_2, iface_type_name_2) = match asset_schema_2 { + AssetSchema::Nia => wlt_1.issue_nia(issued_supply_2, wlt_1.close_method(), Some(&utxo)), + AssetSchema::Uda => wlt_1.issue_uda(wlt_1.close_method(), Some(&utxo)), + AssetSchema::Cfa => wlt_1.issue_cfa(issued_supply_2, wlt_1.close_method(), Some(&utxo)), + }; + wlt_1.check_allocations( + contract_id_1, + &iface_type_name_1, + asset_schema_1, + vec![issued_supply_1], + true, + ); + wlt_1.check_allocations( + contract_id_2, + &iface_type_name_2, + asset_schema_2, + vec![issued_supply_2], + true, + ); + + // wlt_1 spends asset 1, moving the other with a blank transition + let amount_1 = if asset_schema_1 == AssetSchema::Uda { + 1 + } else { + 99 + }; + wlt_1.send( + &mut wlt_2, + transfer_type, + contract_id_1, + &iface_type_name_1, + amount_1, + sats, + ); + wlt_1.check_allocations( + contract_id_1, + &iface_type_name_1, + asset_schema_1, + vec![issued_supply_1 - amount_1], + false, + ); + wlt_1.check_allocations( + contract_id_2, + &iface_type_name_2, + asset_schema_2, + vec![issued_supply_2], + true, + ); + wlt_2.check_allocations( + contract_id_1, + &iface_type_name_1, + asset_schema_1, + vec![amount_1], + true, + ); + + // wlt_1 spends asset 1 change (only if possible) + let amount_2 = 33; + if asset_schema_1 != AssetSchema::Uda { + wlt_1.send( + &mut wlt_2, + transfer_type, + contract_id_1, + &iface_type_name_1, + amount_2, + sats, + ); + wlt_1.check_allocations( + contract_id_1, + &iface_type_name_1, + asset_schema_1, + vec![issued_supply_1 - amount_1 - amount_2], + false, + ); + wlt_1.check_allocations( + contract_id_2, + &iface_type_name_2, + asset_schema_2, + vec![issued_supply_2], + true, + ); + wlt_2.check_allocations( + contract_id_1, + &iface_type_name_1, + asset_schema_1, + vec![amount_1, amount_2], + true, + ); + } + + // wlt_1 spends asset 2 + let amount_3 = if asset_schema_2 == AssetSchema::Uda { + 1 + } else { + 22 + }; + wlt_1.send( + &mut wlt_2, + transfer_type, + contract_id_2, + &iface_type_name_2, + amount_3, + sats, + ); + wlt_1.check_allocations( + contract_id_1, + &iface_type_name_1, + asset_schema_1, + vec![issued_supply_1 - amount_1 - amount_2], + false, + ); + wlt_1.check_allocations( + contract_id_2, + &iface_type_name_2, + asset_schema_2, + vec![issued_supply_2 - amount_3], + false, + ); + wlt_2.check_allocations( + contract_id_1, + &iface_type_name_1, + asset_schema_1, + vec![amount_1, amount_2], + true, + ); + wlt_2.check_allocations( + contract_id_2, + &iface_type_name_2, + asset_schema_2, + vec![amount_3], + true, + ); + + // wlt_2 spends received allocation(s) of asset 1 + let amount_4 = if asset_schema_1 == AssetSchema::Uda { + 1 + } else { + 111 + }; + sats -= 1000; + wlt_2.send( + &mut wlt_1, + transfer_type, + contract_id_1, + &iface_type_name_1, + amount_4, + sats, + ); + wlt_1.check_allocations( + contract_id_1, + &iface_type_name_1, + asset_schema_1, + vec![issued_supply_1 - amount_1 - amount_2, amount_4], + true, + ); + wlt_1.check_allocations( + contract_id_2, + &iface_type_name_2, + asset_schema_2, + vec![issued_supply_2 - amount_3], + false, + ); + wlt_2.check_allocations( + contract_id_1, + &iface_type_name_1, + asset_schema_1, + vec![amount_1 + amount_2 - amount_4], + false, + ); + wlt_2.check_allocations( + contract_id_2, + &iface_type_name_2, + asset_schema_2, + vec![amount_3], + true, + ); + + // wlt_2 spends asset 2 + let amount_5 = if asset_schema_2 == AssetSchema::Uda { + 1 + } else { + 11 + }; + sats -= 1000; + wlt_2.send( + &mut wlt_1, + transfer_type, + contract_id_2, + &iface_type_name_2, + amount_5, + sats, + ); + wlt_1.check_allocations( + contract_id_1, + &iface_type_name_1, + asset_schema_1, + vec![issued_supply_1 - amount_1 - amount_2, amount_4], + true, + ); + wlt_1.check_allocations( + contract_id_2, + &iface_type_name_2, + asset_schema_2, + vec![issued_supply_2 - amount_3, amount_5], + true, + ); + wlt_2.check_allocations( + contract_id_1, + &iface_type_name_1, + asset_schema_1, + vec![amount_1 + amount_2 - amount_4], + false, + ); + wlt_2.check_allocations( + contract_id_2, + &iface_type_name_2, + asset_schema_2, + vec![amount_3 - amount_5], + false, + ); + + // wlt_1 spends asset 1, received back + let amount_6 = if asset_schema_1 == AssetSchema::Uda { + 1 + } else { + issued_supply_1 - amount_1 - amount_2 + amount_4 + }; + sats -= 1000; + wlt_1.send( + &mut wlt_2, + transfer_type, + contract_id_1, + &iface_type_name_1, + amount_6, + sats, + ); + wlt_1.check_allocations( + contract_id_1, + &iface_type_name_1, + asset_schema_1, + vec![], + false, + ); + wlt_1.check_allocations( + contract_id_2, + &iface_type_name_2, + asset_schema_2, + vec![issued_supply_2 - amount_3, amount_5], + true, + ); + wlt_2.check_allocations( + contract_id_1, + &iface_type_name_1, + asset_schema_1, + vec![amount_1 + amount_2 - amount_4, amount_6], + true, + ); + wlt_2.check_allocations( + contract_id_2, + &iface_type_name_2, + asset_schema_2, + vec![amount_3 - amount_5], + false, + ); + + // wlt_1 spends asset 2, received back + let amount_7 = if asset_schema_2 == AssetSchema::Uda { + 1 + } else { + issued_supply_2 - amount_3 + amount_5 + }; + sats -= 1000; + wlt_1.send( + &mut wlt_2, + transfer_type, + contract_id_2, + &iface_type_name_2, + amount_7, + sats, + ); + wlt_1.check_allocations( + contract_id_1, + &iface_type_name_1, + asset_schema_1, + vec![], + false, + ); + wlt_1.check_allocations( + contract_id_2, + &iface_type_name_2, + asset_schema_2, + vec![], + false, + ); + wlt_2.check_allocations( + contract_id_1, + &iface_type_name_1, + asset_schema_1, + vec![amount_1 + amount_2 - amount_4, amount_6], + true, + ); + wlt_2.check_allocations( + contract_id_2, + &iface_type_name_2, + asset_schema_2, + vec![amount_3 - amount_5, amount_7], + true, + ); +} + +#[test] +fn same_transfer_twice() { + initialize(); + + let mut wlt_1 = get_wallet(&DescriptorType::Wpkh); + let mut wlt_2 = get_wallet(&DescriptorType::Wpkh); + + let amount = 600; + + let (contract_id, iface_type_name) = wlt_1.issue_nia(amount, wlt_1.close_method(), None); + + stop_mining(); + let initial_height = get_height(); + + let invoice = wlt_2.invoice( + contract_id, + &iface_type_name, + amount, + wlt_2.close_method(), + InvoiceType::Witness, + ); + let _ = wlt_1.transfer(invoice.clone(), None, Some(500)); + + // retry with higher fees, TX hasn't been mined + let mid_height = get_height(); + assert_eq!(initial_height, mid_height); + + let _ = wlt_1.transfer(invoice, None, Some(1000)); + + let final_height = get_height(); + assert_eq!(initial_height, final_height); + resume_mining(); +} + +#[test] +fn accept_0conf() { + initialize(); + + let mut wlt_1 = get_wallet(&DescriptorType::Wpkh); + let mut wlt_2 = get_wallet(&DescriptorType::Wpkh); + + let issue_supply = 600; + let (contract_id, iface_type_name) = wlt_1.issue_nia(issue_supply, wlt_1.close_method(), None); + + let amt = 200; + let invoice = wlt_2.invoice( + contract_id, + &iface_type_name, + amt, + wlt_2.close_method(), + InvoiceType::Witness, + ); + let (consignment, _) = wlt_1.transfer(invoice.clone(), None, None); + + wlt_2.accept_transfer(consignment.clone()); + + // TODO: check if it's correct that sender sees 2 allocations + /* + wlt_1.sync(); + wlt_1.check_allocations( + contract_id, + &iface_type_name, + AssetSchema::Nia, + vec![issue_supply - amt], + false, + ); + */ + wlt_2.check_allocations( + contract_id, + &iface_type_name, + AssetSchema::Nia, + vec![amt], + false, + ); +} + +#[test] +fn ln_transfers() { + initialize(); + + let mut wlt_1 = get_wallet(&DescriptorType::Wpkh); + let mut wlt_2 = get_wallet(&DescriptorType::Wpkh); + let pre_funding_height = get_height(); + + let utxo = wlt_1.get_utxo(Some(10_000)); + let (contract_id, iface_type_name) = wlt_1.issue_nia(600, wlt_1.close_method(), Some(&utxo)); + + println!("\n1. fake commitment TX (no HTLCs)"); + let beneficiaries = vec![ + (wlt_2.get_address(), Some(2000)), + (wlt_1.get_address(), None), + ]; + let (mut psbt, _meta) = wlt_1.construct_psbt(vec![utxo], beneficiaries, None); + let coloring_info = ColoringInfo { + asset_info_map: HashMap::from([( + contract_id, + AssetColoringInfo { + iface: iface_type_name.clone(), + input_outpoints: vec![utxo], + output_map: HashMap::from([(0, 100), (1, 500)]), + static_blinding: Some(666), + }, + )]), + static_blinding: Some(666), + nonce: Some(u64::MAX - 1), + }; + let (fascia, _asset_beneficiaries) = wlt_1.color_psbt(&mut psbt, coloring_info.clone()); + wlt_1.consume_fascia(fascia.clone(), psbt.txid()); + wlt_1.debug_logs(contract_id, &iface_type_name); + + let htlc_vout = 2; + let htlc_rgb_amt = 200; + let htlc_btc_amt = 4000; + let htlc_derived_addr = wlt_1.get_derived_address(); + + println!("\n2. fake commitment TX (1 HTLC)"); + let beneficiaries = vec![ + (wlt_2.get_address(), Some(2000)), + (wlt_1.get_address(), None), + (htlc_derived_addr.addr, Some(htlc_btc_amt)), + ]; + let (mut psbt, _meta) = wlt_1.construct_psbt(vec![utxo], beneficiaries, None); + let coloring_info = ColoringInfo { + asset_info_map: HashMap::from([( + contract_id, + AssetColoringInfo { + iface: iface_type_name.clone(), + input_outpoints: vec![utxo], + output_map: HashMap::from([(0, 100), (1, 300), (htlc_vout, htlc_rgb_amt)]), + static_blinding: Some(666), + }, + )]), + static_blinding: Some(666), + nonce: Some(u64::MAX - 1), + }; + let (fascia, _asset_beneficiaries) = wlt_1.color_psbt(&mut psbt, coloring_info.clone()); + wlt_1.consume_fascia(fascia.clone(), psbt.txid()); + wlt_1.debug_logs(contract_id, &iface_type_name); + + println!("\n3. fake HTLC TX"); + let witness_id = fascia.witness_id(); + let txid = witness_id.as_reduced_unsafe(); + let input_outpoint = Outpoint::new(*txid, htlc_vout); + let beneficiaries = vec![(wlt_1.get_address(), None)]; + let (mut psbt, _meta) = wlt_1.construct_psbt_offchain( + vec![(input_outpoint, htlc_btc_amt, htlc_derived_addr.terminal)], + beneficiaries, + None, + ); + let coloring_info = ColoringInfo { + asset_info_map: HashMap::from([( + contract_id, + AssetColoringInfo { + iface: iface_type_name.clone(), + input_outpoints: vec![input_outpoint], + output_map: HashMap::from([(0, htlc_rgb_amt)]), + static_blinding: Some(666), + }, + )]), + static_blinding: Some(666), + nonce: Some(u64::MAX), + }; + let (fascia, _asset_beneficiaries) = wlt_1.color_psbt(&mut psbt, coloring_info); + wlt_1.consume_fascia(fascia.clone(), psbt.txid()); + wlt_1.debug_logs(contract_id, &iface_type_name); + + println!("\n4. fake commitment TX (no HTLCs)"); + let beneficiaries = vec![ + (wlt_2.get_address(), Some(3000)), + (wlt_1.get_address(), None), + ]; + let (mut psbt, _meta) = wlt_1.construct_psbt(vec![utxo], beneficiaries, None); + let coloring_info = ColoringInfo { + asset_info_map: HashMap::from([( + contract_id, + AssetColoringInfo { + iface: iface_type_name.clone(), + input_outpoints: vec![utxo], + output_map: HashMap::from([(0, 100), (1, 500)]), + static_blinding: Some(666), + }, + )]), + static_blinding: Some(666), + nonce: Some(u64::MAX - 1), + }; + let (fascia, _asset_beneficiaries) = wlt_1.color_psbt(&mut psbt, coloring_info); + wlt_1.consume_fascia(fascia.clone(), psbt.txid()); + wlt_1.debug_logs(contract_id, &iface_type_name); + let mut old_psbt = psbt.clone(); + + println!("\n5. fake commitment TX (1 HTLC)"); + let htlc_rgb_amt = 180; + let beneficiaries = vec![ + (wlt_2.get_address(), Some(2000)), + (wlt_1.get_address(), None), + (htlc_derived_addr.addr, Some(htlc_btc_amt)), + ]; + let (mut psbt, _meta) = wlt_1.construct_psbt(vec![utxo], beneficiaries, None); + let coloring_info = ColoringInfo { + asset_info_map: HashMap::from([( + contract_id, + AssetColoringInfo { + iface: iface_type_name.clone(), + input_outpoints: vec![utxo], + output_map: HashMap::from([(0, 122), (1, 298), (htlc_vout, htlc_rgb_amt)]), + static_blinding: Some(666), + }, + )]), + static_blinding: Some(666), + nonce: Some(u64::MAX - 1), + }; + let (fascia, _asset_beneficiaries) = wlt_1.color_psbt(&mut psbt, coloring_info.clone()); + wlt_1.consume_fascia(fascia.clone(), psbt.txid()); + wlt_1.debug_logs(contract_id, &iface_type_name); + + println!("\n6. fake HTLC TX"); + let witness_id = fascia.witness_id(); + let txid = witness_id.as_reduced_unsafe(); + let input_outpoint = Outpoint::new(*txid, htlc_vout); + let beneficiaries = vec![(wlt_1.get_address(), None)]; + let (mut psbt, _meta) = wlt_1.construct_psbt_offchain( + vec![(input_outpoint, htlc_btc_amt, htlc_derived_addr.terminal)], + beneficiaries, + None, + ); + let coloring_info = ColoringInfo { + asset_info_map: HashMap::from([( + contract_id, + AssetColoringInfo { + iface: iface_type_name.clone(), + input_outpoints: vec![input_outpoint], + output_map: HashMap::from([(0, htlc_rgb_amt)]), + static_blinding: Some(666), + }, + )]), + static_blinding: Some(666), + nonce: Some(u64::MAX), + }; + let (fascia, _asset_beneficiaries) = wlt_1.color_psbt(&mut psbt, coloring_info); + wlt_1.consume_fascia(fascia.clone(), psbt.txid()); + wlt_1.debug_logs(contract_id, &iface_type_name); + + println!("\n7. broadcast old PSBT"); + let tx = wlt_1.sign_finalize(&mut old_psbt); + wlt_1.broadcast_tx(&tx); + mine(false); + wlt_1.sync(); + wlt_1.update_witnesses(pre_funding_height); + let mut wlt_3 = get_wallet(&DescriptorType::Wpkh); + wlt_1.send( + &mut wlt_3, + TransferType::Blinded, + contract_id, + &iface_type_name, + 500, + 1000, + ); +} + +#[test] +fn mainnet_wlt_receiving_test_asset() { + initialize(); + + let mut wlt_1 = get_wallet(&DescriptorType::Wpkh); + let mut wlt_2 = get_mainnet_wallet(); + + let (contract_id, iface_type_name) = wlt_1.issue_nia(700, wlt_1.close_method(), None); + + let utxo = + Outpoint::from_str("bebcfcb200a17763f6932a6d6fca9448a4b46c5b737cc3810769a7403ef79ce6:0") + .unwrap(); + let invoice = wlt_2.invoice( + contract_id, + &iface_type_name, + 150, + wlt_2.close_method(), + InvoiceType::Blinded(Some(utxo)), + ); + let (consignment, _) = wlt_1.transfer(invoice.clone(), None, Some(500)); + mine(false); + match consignment.validate(&wlt_2.get_resolver(), wlt_2.testnet()) { + Err((status, _invalid_consignment)) => { + assert_eq!( + status.failures, + vec![Failure::NetworkMismatch(wlt_2.testnet())] + ) + } + _ => panic!("validation must fail"), + } +} + +#[test] +#[ignore = "this was working, fix needed"] +fn tapret_wlt_receiving_opret() { + initialize(); + + let mut wlt_1 = get_wallet(&DescriptorType::Tr); + let mut wlt_2 = get_wallet(&DescriptorType::Wpkh); + + let (contract_id, iface_type_name) = wlt_1.issue_nia(600, wlt_1.close_method(), None); + + println!("1st transfer"); + wlt_1.send( + &mut wlt_2, + TransferType::Blinded, + contract_id, + &iface_type_name, + 400, + 5000, + ); + + println!("2nd transfer"); + let invoice = wlt_1.invoice( + contract_id, + &iface_type_name, + 100, + CloseMethod::OpretFirst, + InvoiceType::Witness, + ); + wlt_2.send_to_invoice(&mut wlt_1, invoice, None, None); + + println!("3rd transfer"); + wlt_1.send( + &mut wlt_2, + TransferType::Blinded, + contract_id, + &iface_type_name, + 300, + 1000, + ); +} diff --git a/tests/utils/chain.rs b/tests/utils/chain.rs new file mode 100644 index 0000000..ed54e81 --- /dev/null +++ b/tests/utils/chain.rs @@ -0,0 +1,244 @@ +use super::*; + +static INIT: Once = Once::new(); + +pub static INDEXER: OnceLock = OnceLock::new(); + +#[derive(Clone, Default, PartialEq, Eq, Debug)] +pub enum Indexer { + Electrum, + #[default] + Esplora, +} + +impl fmt::Display for Indexer { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", format!("{:?}", self).to_lowercase()) + } +} + +pub fn initialize() { + INIT.call_once(|| { + INDEXER.get_or_init(|| match std::env::var("INDEXER") { + Ok(val) if val.to_lowercase() == Indexer::Esplora.to_string() => Indexer::Esplora, + Ok(val) if val.to_lowercase() == Indexer::Electrum.to_string() => Indexer::Electrum, + Err(VarError::NotPresent) => Indexer::Esplora, + _ => { + panic!("invalid indexer. possible values: `esplora` (default), `electrum`") + } + }); + if std::env::var("SKIP_INIT").is_ok() { + println!("skipping services initialization"); + return; + } + let start_services_file = PathBuf::from("tests").join("start_services.sh"); + println!("starting test services..."); + let output = Command::new(start_services_file) + .env("PROFILE", INDEXER.get().unwrap().to_string()) + .output() + .expect("failed to start test services"); + if !output.status.success() { + println!("{output:?}"); + panic!("failed to start test services"); + } + _wait_indexer_sync(); + }); +} + +static MINER: Lazy> = Lazy::new(|| RwLock::new(Miner { no_mine_count: 0 })); + +#[derive(Clone, Debug)] +pub struct Miner { + no_mine_count: u32, +} + +fn _bitcoin_cli() -> Vec { + let compose_file = PathBuf::from("tests").join("docker-compose.yml"); + let mut cmd = vec![ + s!("-f"), + compose_file.to_string_lossy().to_string(), + s!("exec"), + s!("-T"), + ]; + match INDEXER.get().unwrap() { + Indexer::Electrum => cmd.extend(vec![ + "-u".to_string(), + "blits".to_string(), + "bitcoind".to_string(), + "bitcoin-cli".to_string(), + "-regtest".to_string(), + ]), + Indexer::Esplora => cmd.extend(vec!["esplora".to_string(), "cli".to_string()]), + }; + cmd +} + +impl Miner { + fn mine(&self) -> bool { + if self.no_mine_count > 0 { + return false; + } + self.force_mine() + } + + fn force_mine(&self) -> bool { + let output = Command::new("docker") + .stdin(Stdio::null()) + .arg("compose") + .args(_bitcoin_cli()) + .arg("-rpcwallet=miner") + .arg("-generate") + .arg("1") + .output() + .expect("failed to mine"); + if !output.status.success() { + println!("{output:?}"); + panic!("failed to mine"); + } + _wait_indexer_sync(); + true + } + + fn stop_mining(&mut self) { + self.no_mine_count += 1; + } + + fn resume_mining(&mut self) { + if self.no_mine_count > 0 { + self.no_mine_count -= 1; + } + } +} + +pub fn mine(resume: bool) { + let t_0 = OffsetDateTime::now_utc(); + if resume { + resume_mining(); + } + loop { + if (OffsetDateTime::now_utc() - t_0).as_seconds_f32() > 120.0 { + println!("forcibly breaking mining wait"); + resume_mining(); + } + let mined = MINER.read().as_ref().unwrap().mine(); + if mined { + break; + } + std::thread::sleep(std::time::Duration::from_millis(500)); + } +} + +pub fn mine_but_no_resume() { + let t_0 = OffsetDateTime::now_utc(); + loop { + if (OffsetDateTime::now_utc() - t_0).as_seconds_f32() > 120.0 { + println!("forcibly breaking mining wait"); + resume_mining(); + } + let miner = MINER.write().unwrap(); + if miner.no_mine_count <= 1 { + miner.force_mine(); + break; + } + drop(miner); + std::thread::sleep(std::time::Duration::from_millis(500)); + } +} + +pub fn stop_mining() { + MINER.write().unwrap().stop_mining() +} + +pub fn stop_mining_when_alone() { + let t_0 = OffsetDateTime::now_utc(); + loop { + if (OffsetDateTime::now_utc() - t_0).as_seconds_f32() > 120.0 { + println!("forcibly breaking stop wait"); + stop_mining(); + } + let mut miner = MINER.write().unwrap(); + if miner.no_mine_count == 0 { + miner.stop_mining(); + break; + } + drop(miner); + std::thread::sleep(std::time::Duration::from_millis(500)); + } +} + +pub fn resume_mining() { + MINER.write().unwrap().resume_mining() +} + +pub fn get_height() -> u32 { + let output = Command::new("docker") + .stdin(Stdio::null()) + .stderr(Stdio::null()) + .arg("compose") + .args(_bitcoin_cli()) + .arg("getblockcount") + .output() + .expect("failed to call getblockcount"); + if !output.status.success() { + println!("{output:?}"); + panic!("failed to get block count"); + } + let blockcount_str = + std::str::from_utf8(&output.stdout).expect("could not parse blockcount output"); + blockcount_str + .trim() + .parse::() + .expect("could not parse blockcount") +} + +fn _wait_indexer_sync() { + let t_0 = OffsetDateTime::now_utc(); + let blockcount = get_height(); + loop { + std::thread::sleep(std::time::Duration::from_millis(100)); + match INDEXER.get().unwrap() { + Indexer::Electrum => { + let electrum_client = + ElectrumClient::new(ELECTRUM_REGTEST_URL).expect("cannot get electrum client"); + if electrum_client.block_header(blockcount as usize).is_ok() { + break; + } + } + Indexer::Esplora => { + let esplora_client = EsploraClient::new_esplora(ESPLORA_REGTEST_URL).unwrap(); + if esplora_client.block_hash(blockcount).is_ok() { + break; + } + } + } + if (OffsetDateTime::now_utc() - t_0).as_seconds_f32() > 25.0 { + panic!("indexer not syncing with bitcoind"); + } + } +} + +pub fn send_to_address(address: String, sats: Option) -> String { + let sats = Sats::from_sats(sats.unwrap_or(100_000_000)); + let btc = format!("{}.{:0>8}", sats.btc_floor(), sats.sats_rem()); + let output = Command::new("docker") + .stdin(Stdio::null()) + .arg("compose") + .args(_bitcoin_cli()) + .arg("-rpcwallet=miner") + .arg("sendtoaddress") + .arg(address) + .arg(btc) + .output() + .expect("failed to fund wallet"); + if !output.status.success() { + println!("{output:?}"); + panic!("failed to send to address"); + } + String::from_utf8(output.stdout).unwrap().trim().to_string() +} + +pub fn fund_wallet(address: String, sats: Option) -> String { + let txid = send_to_address(address, sats); + mine(false); + txid +} diff --git a/tests/utils/helpers.rs b/tests/utils/helpers.rs new file mode 100644 index 0000000..9aaf6b1 --- /dev/null +++ b/tests/utils/helpers.rs @@ -0,0 +1,1271 @@ +use super::*; + +pub struct TestWallet { + wallet: RgbWallet>, + descriptor: RgbDescr, + signer: Option, + wallet_dir: PathBuf, +} + +enum WalletAccount { + Private(XprivAccount), + Public(XpubAccount), +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub enum DescriptorType { + Wpkh, + Tr, +} + +impl fmt::Display for DescriptorType { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", format!("{:?}", self).to_lowercase()) + } +} + +#[derive(Debug, Copy, Clone)] +pub enum TransferType { + Blinded, + Witness, +} + +impl fmt::Display for TransferType { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", format!("{:?}", self).to_lowercase()) + } +} + +pub enum InvoiceType { + Blinded(Option), + Witness, +} + +/// RGB asset-specific information to color a transaction +#[derive(Clone, Debug)] +pub struct AssetColoringInfo { + /// Contract iface + pub iface: TypeName, + /// Input outpoints of the assets being spent + pub input_outpoints: Vec, + /// Map of vouts and asset amounts to color the transaction outputs + pub output_map: HashMap, + /// Static blinding to keep the transaction construction deterministic + pub static_blinding: Option, +} + +/// RGB information to color a transaction +#[derive(Clone, Debug)] +pub struct ColoringInfo { + /// Asset-specific information + pub asset_info_map: HashMap, + /// Static blinding to keep the transaction construction deterministic + pub static_blinding: Option, + /// Nonce for offchain TXs ordering + pub nonce: Option, +} + +/// Map of contract ID and list of its beneficiaries +pub type AssetBeneficiariesMap = BTreeMap>>; + +#[derive(Debug, EnumIter, Copy, Clone, PartialEq)] +pub enum AssetSchema { + Nia, + Uda, + Cfa, +} + +impl fmt::Display for AssetSchema { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", format!("{:?}", self).to_lowercase()) + } +} + +#[derive(Debug)] +pub enum AssetInfo { + Nia { + spec: AssetSpec, + terms: ContractTerms, + issued_supply: u64, + }, + Uda { + spec: AssetSpec, + terms: ContractTerms, + token_data: TokenData, + }, + Cfa { + name: Name, + precision: Precision, + details: Option
, + terms: ContractTerms, + issued_supply: u64, + }, +} + +impl AssetSchema { + fn iface_type_name(&self) -> TypeName { + tn!(match self { + Self::Nia => "RGB20Fixed", + Self::Uda => "RGB21Unique", + Self::Cfa => "RGB25Base", + }) + } + + fn schema(&self) -> Schema { + match self { + Self::Nia => NonInflatableAsset::schema(), + Self::Uda => UniqueDigitalAsset::schema(), + Self::Cfa => CollectibleFungibleAsset::schema(), + } + } + + fn issue_impl(&self) -> IfaceImpl { + match self { + Self::Nia => NonInflatableAsset::issue_impl(), + Self::Uda => UniqueDigitalAsset::issue_impl(), + Self::Cfa => CollectibleFungibleAsset::issue_impl(), + } + } + + fn scripts(&self) -> Scripts { + match self { + Self::Nia => NonInflatableAsset::scripts(), + Self::Uda => UniqueDigitalAsset::scripts(), + Self::Cfa => CollectibleFungibleAsset::scripts(), + } + } + + fn types(&self) -> TypeSystem { + match self { + Self::Nia => NonInflatableAsset::types(), + Self::Uda => UniqueDigitalAsset::types(), + Self::Cfa => CollectibleFungibleAsset::types(), + } + } + + fn iface(&self) -> Iface { + match self { + Self::Nia => Rgb20::iface(&Rgb20::FIXED), + Self::Uda => Rgb21::iface(&Rgb21::NONE), + Self::Cfa => Rgb25::iface(&Rgb25::NONE), + } + } + + fn get_valid_kit(&self) -> ValidKit { + let mut kit = Kit::default(); + kit.schemata.push(self.schema()).unwrap(); + kit.ifaces.push(self.iface()).unwrap(); + kit.iimpls.push(self.issue_impl()).unwrap(); + kit.scripts.extend(self.scripts().into_values()).unwrap(); + kit.types = self.types(); + kit.validate().unwrap() + } +} + +impl AssetInfo { + fn asset_schema(&self) -> AssetSchema { + match self { + Self::Nia { .. } => AssetSchema::Nia, + Self::Uda { .. } => AssetSchema::Uda, + Self::Cfa { .. } => AssetSchema::Cfa, + } + } + + fn iface_type_name(&self) -> TypeName { + self.asset_schema().iface_type_name() + } + + fn schema(&self) -> Schema { + self.asset_schema().schema() + } + + fn issue_impl(&self) -> IfaceImpl { + self.asset_schema().issue_impl() + } + + fn scripts(&self) -> Scripts { + self.asset_schema().scripts() + } + + fn types(&self) -> TypeSystem { + self.asset_schema().types() + } + + fn iface(&self) -> Iface { + self.asset_schema().iface() + } + + pub fn nia( + ticker: &str, + name: &str, + precision: u8, + details: Option<&str>, + terms_text: &str, + terms_media_fpath: Option<&str>, + issued_supply: u64, + ) -> Self { + let spec = AssetSpec::with( + ticker, + name, + Precision::try_from(precision).unwrap(), + details, + ) + .unwrap(); + let text = RicardianContract::from_str(terms_text).unwrap(); + let attachment = terms_media_fpath.map(attachment_from_fpath); + let terms = ContractTerms { + text, + media: attachment, + }; + Self::Nia { + spec, + terms, + issued_supply, + } + } + + pub fn uda( + ticker: &str, + name: &str, + details: Option<&str>, + terms_text: &str, + terms_media_fpath: Option<&str>, + token_data: TokenData, + ) -> AssetInfo { + let spec = AssetSpec::with(ticker, name, Precision::try_from(0).unwrap(), details).unwrap(); + let text = RicardianContract::from_str(terms_text).unwrap(); + let attachment = terms_media_fpath.map(attachment_from_fpath); + let terms = ContractTerms { + text, + media: attachment.clone(), + }; + Self::Uda { + spec, + terms, + token_data, + } + } + + pub fn cfa( + name: &str, + precision: u8, + details: Option<&str>, + terms_text: &str, + terms_media_fpath: Option<&str>, + issued_supply: u64, + ) -> AssetInfo { + let text = RicardianContract::from_str(terms_text).unwrap(); + let attachment = terms_media_fpath.map(attachment_from_fpath); + let terms = ContractTerms { + text, + media: attachment, + }; + Self::Cfa { + name: Name::try_from(name.to_owned()).unwrap(), + precision: Precision::try_from(precision).unwrap(), + details: details.map(|d| Details::try_from(d.to_owned()).unwrap()), + terms, + issued_supply, + } + } + + fn add_global_state(&self, mut builder: ContractBuilder) -> ContractBuilder { + match self { + Self::Nia { + spec, + terms, + issued_supply, + } => builder + .add_global_state("spec", spec.clone()) + .unwrap() + .add_global_state("terms", terms.clone()) + .unwrap() + .add_global_state("issuedSupply", Amount::from(*issued_supply)) + .unwrap(), + Self::Uda { + spec, + terms, + token_data, + } => builder + .add_global_state("spec", spec.clone()) + .unwrap() + .add_global_state("terms", terms.clone()) + .unwrap() + .add_global_state("tokens", token_data.clone()) + .unwrap(), + Self::Cfa { + name, + precision, + details, + terms, + issued_supply, + } => { + builder = builder + .add_global_state("name", name.clone()) + .unwrap() + .add_global_state("precision", *precision) + .unwrap() + .add_global_state("terms", terms.clone()) + .unwrap() + .add_global_state("issuedSupply", Amount::from(*issued_supply)) + .unwrap(); + if let Some(details) = details { + builder = builder + .add_global_state("details", details.clone()) + .unwrap() + } + builder + } + } + } + + fn add_asset_owner( + &self, + builder: ContractBuilder, + builder_seal: BuilderSeal>, + ) -> ContractBuilder { + match self { + Self::Nia { issued_supply, .. } | Self::Cfa { issued_supply, .. } => builder + .add_fungible_state("assetOwner", builder_seal, *issued_supply) + .unwrap(), + Self::Uda { token_data, .. } => { + let fraction = OwnedFraction::from_inner(1); + let allocation = Allocation::with(token_data.index, fraction); + builder + .add_data("assetOwner", builder_seal, allocation) + .unwrap() + } + } + } +} + +fn _get_wallet( + descriptor_type: &DescriptorType, + network: Network, + wallet_dir: PathBuf, + wallet_account: WalletAccount, +) -> TestWallet { + std::fs::create_dir_all(&wallet_dir).unwrap(); + println!("wallet dir: {wallet_dir:?}"); + + let xpub_account = match wallet_account { + WalletAccount::Private(ref xpriv_account) => &xpriv_account.to_xpub_account(), + WalletAccount::Public(ref xpub_account) => xpub_account, + }; + const OPRET_KEYCHAINS: [Keychain; 3] = [ + Keychain::INNER, + Keychain::OUTER, + Keychain::with(RgbKeychain::Rgb as u8), + ]; + const TAPRET_KEYCHAINS: [Keychain; 4] = [ + Keychain::INNER, + Keychain::OUTER, + Keychain::with(RgbKeychain::Rgb as u8), + Keychain::with(RgbKeychain::Tapret as u8), + ]; + let keychains: &[Keychain] = match *descriptor_type { + DescriptorType::Tr => &TAPRET_KEYCHAINS[..], + DescriptorType::Wpkh => &OPRET_KEYCHAINS[..], + }; + let xpub_derivable = XpubDerivable::with(xpub_account.clone(), keychains); + + let descriptor = match descriptor_type { + DescriptorType::Wpkh => RgbDescr::Wpkh(Wpkh::from(xpub_derivable)), + DescriptorType::Tr => RgbDescr::TapretKey(TapretKey::from(xpub_derivable)), + }; + + let name = "bp_wallet_name"; + let mut bp_wallet = Wallet::new_layer1(descriptor.clone(), network); + bp_wallet.set_name(name.to_string()); + let bp_dir = wallet_dir.join(name); + let bp_wallet_provider = FsTextStore::new(bp_dir).unwrap(); + bp_wallet.make_persistent(bp_wallet_provider, true).unwrap(); + + let stock_provider = FsBinStore::new(wallet_dir.clone()).unwrap(); + let mut stock = Stock::in_memory(); + stock.make_persistent(stock_provider, true).unwrap(); + let mut wallet = RgbWallet::new(stock, bp_wallet); + + for asset_schema in AssetSchema::iter() { + let valid_kit = asset_schema.get_valid_kit(); + wallet.stock_mut().import_kit(valid_kit).unwrap(); + } + + let signer = match wallet_account { + WalletAccount::Private(xpriv_account) => Some(TestnetSigner::new(xpriv_account)), + WalletAccount::Public(_) => None, + }; + + let mut wallet = TestWallet { + wallet, + descriptor, + signer, + wallet_dir, + }; + + // TODO: remove if once found solution for esplora 'Too many requests' error + if network.is_testnet() { + wallet.sync(); + } + + wallet +} + +pub fn get_wallet(descriptor_type: &DescriptorType) -> TestWallet { + let mut seed = vec![0u8; 128]; + rand::thread_rng().fill_bytes(&mut seed); + + let xpriv_account = XprivAccount::with_seed(true, &seed).derive(h![86, 1, 0]); + + let fingerprint = xpriv_account.account_fp().to_string(); + let wallet_dir = PathBuf::from("tests").join("tmp").join(fingerprint); + + _get_wallet( + descriptor_type, + Network::Regtest, + wallet_dir, + WalletAccount::Private(xpriv_account), + ) +} + +pub fn get_mainnet_wallet() -> TestWallet { + let xpub_account = XpubAccount::from_str( + "[c32338a7/86h/0h/0h]xpub6CmiK1xc7YwL472qm4zxeURFX8yMCSasioXujBjVMMzA3AKZr6KLQEmkzDge1Ezn2p43ZUysyx6gfajFVVnhtQ1AwbXEHrioLioXXgj2xW5" + ).unwrap(); + + let wallet_dir = PathBuf::from("tests").join("mainnet"); + + _get_wallet( + &DescriptorType::Wpkh, + Network::Mainnet, + wallet_dir, + WalletAccount::Public(xpub_account), + ) +} + +pub fn attachment_from_fpath(fpath: &str) -> Attachment { + let file_bytes = std::fs::read(fpath).unwrap(); + let file_hash: sha256::Hash = Hash::hash(&file_bytes[..]); + let digest = file_hash.to_byte_array().into(); + let mime = tree_magic_mini::from_filepath(fpath.as_ref()) + .unwrap() + .to_string(); + let media_ty: &'static str = Box::leak(mime.clone().into_boxed_str()); + let media_type = MediaType::with(media_ty); + Attachment { + ty: media_type, + digest, + } +} + +fn uda_token_data_minimal() -> TokenData { + TokenData { + index: TokenIndex::from_inner(UDA_FIXED_INDEX), + ..Default::default() + } +} + +pub fn uda_token_data( + ticker: &str, + name: &str, + details: &str, + preview: EmbeddedMedia, + media: Attachment, + attachments: BTreeMap, + reserves: ProofOfReserves, +) -> TokenData { + let mut token_data = uda_token_data_minimal(); + token_data.preview = Some(preview); + token_data.media = Some(media); + token_data.attachments = Confined::try_from(attachments.clone()).unwrap(); + token_data.reserves = Some(reserves); + token_data.ticker = Some(Ticker::try_from(ticker.to_string()).unwrap()); + token_data.name = Some(Name::try_from(name.to_string()).unwrap()); + token_data.details = Some(Details::try_from(details.to_string()).unwrap()); + token_data +} + +impl TestWallet { + pub fn network(&self) -> Network { + self.wallet.wallet().network() + } + + pub fn testnet(&self) -> bool { + self.network().is_testnet() + } + + pub fn keychain(&self) -> RgbKeychain { + RgbKeychain::for_method(self.close_method()) + } + + pub fn get_derived_address(&mut self) -> DerivedAddr { + self.wallet + .wallet() + .addresses(self.keychain()) + .next() + .expect("no addresses left") + } + + pub fn get_address(&mut self) -> Address { + self.get_derived_address().addr + } + + pub fn get_utxo(&mut self, sats: Option) -> Outpoint { + let address = self.get_address(); + let txid = Txid::from_str(&fund_wallet(address.to_string(), sats)).unwrap(); + self.sync(); + let mut vout = None; + let coins = self.wallet.wallet().address_coins(); + assert!(!coins.is_empty()); + for (_derived_addr, utxos) in coins { + for utxo in utxos { + if utxo.outpoint.txid == txid { + vout = Some(utxo.outpoint.vout_u32()); + } + } + } + Outpoint { + txid, + vout: Vout::from_u32(vout.unwrap()), + } + } + + fn get_indexer_url(&self) -> String { + match INDEXER.get().unwrap() { + Indexer::Electrum => match self.network() { + Network::Regtest => ELECTRUM_REGTEST_URL, + Network::Mainnet => ELECTRUM_MAINNET_URL, + _ => unimplemented!("network not yet supported"), + }, + Indexer::Esplora => match self.network() { + Network::Regtest => ESPLORA_REGTEST_URL, + Network::Mainnet => ESPLORA_MAINNET_URL, + _ => unimplemented!("network not yet supported"), + }, + } + .to_string() + } + + fn get_indexer(&self) -> AnyIndexer { + let indexer_url = self.get_indexer_url(); + match INDEXER.get().unwrap() { + Indexer::Electrum => { + AnyIndexer::Electrum(Box::new(ElectrumClient::new(&indexer_url).unwrap())) + } + Indexer::Esplora => { + AnyIndexer::Esplora(Box::new(EsploraClient::new_esplora(&indexer_url).unwrap())) + } + } + } + + pub fn get_resolver(&self) -> AnyResolver { + let indexer_url = self.get_indexer_url(); + match INDEXER.get().unwrap() { + Indexer::Electrum => AnyResolver::electrum_blocking(&indexer_url, None).unwrap(), + Indexer::Esplora => AnyResolver::esplora_blocking(&indexer_url, None).unwrap(), + } + } + + pub fn broadcast_tx(&self, tx: &Tx) { + match self.get_indexer() { + AnyIndexer::Electrum(inner) => { + inner.transaction_broadcast(tx).unwrap(); + } + AnyIndexer::Esplora(inner) => { + inner.publish(tx).unwrap(); + } + _ => unreachable!("unsupported indexer"), + } + } + + pub fn sync(&mut self) { + let indexer = self.get_indexer(); + self.wallet + .wallet_mut() + .update(&indexer) + .into_result() + .unwrap(); + } + + pub fn close_method(&self) -> CloseMethod { + self.wallet.wallet().seal_close_method() + } + + pub fn issue_with_info( + &mut self, + asset_info: AssetInfo, + close_method: CloseMethod, + outpoint: Option<&Outpoint>, + ) -> (ContractId, TypeName) { + let outpoint = if let Some(outpoint) = outpoint { + *outpoint + } else { + self.get_utxo(None) + }; + + let blind_seal = match close_method { + CloseMethod::TapretFirst => BlindSeal::tapret_first_rand(outpoint.txid, outpoint.vout), + CloseMethod::OpretFirst => BlindSeal::opret_first_rand(outpoint.txid, outpoint.vout), + }; + let genesis_seal = GenesisSeal::from(blind_seal); + let seal: XChain> = XChain::with(Layer1::Bitcoin, genesis_seal); + let builder_seal = BuilderSeal::from(seal); + + let mut builder = ContractBuilder::with( + Identity::default(), + asset_info.iface(), + asset_info.schema(), + asset_info.issue_impl(), + asset_info.types(), + asset_info.scripts(), + ); + + builder = asset_info.add_global_state(builder); + + builder = asset_info.add_asset_owner(builder, builder_seal); + + let contract = builder.issue_contract().expect("failure issuing contract"); + let resolver = self.get_resolver(); + self.wallet + .stock_mut() + .import_contract(contract.clone(), resolver) + .unwrap(); + + (contract.contract_id(), asset_info.iface_type_name()) + } + + pub fn issue_nia( + &mut self, + issued_supply: u64, + close_method: CloseMethod, + outpoint: Option<&Outpoint>, + ) -> (ContractId, TypeName) { + let asset_info = AssetInfo::nia( + "NIATCKR", + "NIA asset name", + 2, + None, + "NIA terms", + None, + issued_supply, + ); + self.issue_with_info(asset_info, close_method, outpoint) + } + + pub fn issue_uda( + &mut self, + close_method: CloseMethod, + outpoint: Option<&Outpoint>, + ) -> (ContractId, TypeName) { + let token_data = uda_token_data_minimal(); + let asset_info = AssetInfo::uda( + "UDATCKR", + "UDA asset name", + None, + "NIA terms", + None, + token_data, + ); + self.issue_with_info(asset_info, close_method, outpoint) + } + + pub fn issue_cfa( + &mut self, + issued_supply: u64, + close_method: CloseMethod, + outpoint: Option<&Outpoint>, + ) -> (ContractId, TypeName) { + let asset_info = + AssetInfo::cfa("CFA asset name", 0, None, "CFA terms", None, issued_supply); + self.issue_with_info(asset_info, close_method, outpoint) + } + + pub fn invoice( + &mut self, + contract_id: ContractId, + iface_type_name: &TypeName, + amount: u64, + close_method: CloseMethod, + invoice_type: InvoiceType, + ) -> RgbInvoice { + let network = self.wallet.wallet().network(); + let beneficiary = match invoice_type { + InvoiceType::Blinded(outpoint) => { + let outpoint = if let Some(outpoint) = outpoint { + outpoint + } else { + self.get_utxo(None) + }; + let seal = XChain::Bitcoin(GraphSeal::new_random( + close_method, + outpoint.txid, + outpoint.vout, + )); + self.wallet.stock_mut().store_secret_seal(seal).unwrap(); + Beneficiary::BlindedSeal(*seal.to_secret_seal().as_reduced_unsafe()) + } + InvoiceType::Witness => { + let address = self.get_address(); + Beneficiary::WitnessVout(Pay2Vout { + address: address.payload, + method: close_method, + }) + } + }; + + let mut builder = RgbInvoiceBuilder::new(XChainNet::bitcoin(network, beneficiary)) + .set_contract(contract_id) + .set_interface(iface_type_name.clone()); + if *iface_type_name == AssetSchema::Uda.iface_type_name() { + if amount != 1 { + panic!("UDA amount must be 1"); + } + builder = builder + .clone() + .set_allocation(UDA_FIXED_INDEX, amount) + .unwrap(); + } else { + builder = builder.clone().set_amount_raw(amount); + } + builder.finish() + } + + pub fn sign_finalize(&mut self, psbt: &mut Psbt) -> Tx { + let _sig_count = psbt.sign(self.signer.as_ref().unwrap()).unwrap(); + psbt.finalize(&self.descriptor); + psbt.extract().unwrap() + } + + pub fn transfer( + &mut self, + invoice: RgbInvoice, + sats: Option, + fee: Option, + ) -> (Transfer, Tx) { + self.sync(); + + let fee = Sats::from_sats(fee.unwrap_or(400)); + let sats = Sats::from_sats(sats.unwrap_or(2000)); + let params = TransferParams::with(fee, sats); + let (mut psbt, _psbt_meta, consignment) = self.wallet.pay(&invoice, params).unwrap(); + + let tx = self.sign_finalize(&mut psbt); + + let txid = tx.txid().to_string(); + println!("transfer txid: {txid}"); + + let mut tx_path = self.wallet_dir.join("tx"); + std::fs::create_dir_all(&tx_path).unwrap(); + tx_path.push(&txid); + tx_path.set_extension("yaml"); + let mut file = std::fs::File::options() + .read(true) + .write(true) + .create_new(true) + .open(tx_path) + .unwrap(); + serde_yaml::to_writer(&mut file, &tx).unwrap(); + writeln!(file, "\n---\n").unwrap(); + serde_yaml::to_writer(&mut file, &psbt).unwrap(); + + self.broadcast_tx(&tx); + + (consignment, tx) + } + + pub fn accept_transfer(&mut self, consignment: Transfer) { + self.sync(); + let resolver = self.get_resolver(); + let validated_consignment = consignment.validate(&resolver, self.testnet()).unwrap(); + let validation_status = validated_consignment.clone().into_validation_status(); + let validity = validation_status.validity(); + assert_eq!(validity, Validity::Valid); + let mut attempts = 0; + while let Err(e) = self + .wallet + .stock_mut() + .accept_transfer(validated_consignment.clone(), &resolver) + { + attempts += 1; + if attempts > 3 { + panic!("error accepting transfer: {e}"); + } + std::thread::sleep(std::time::Duration::from_millis(100)); + } + } + + pub fn contract_iface( + &self, + contract_id: ContractId, + iface_type_name: &TypeName, + ) -> ContractIface> { + self.wallet + .stock() + .contract_iface(contract_id, iface_type_name.clone()) + .unwrap() + } + + pub fn contract_iface_class( + &self, + contract_id: ContractId, + ) -> C::Wrapper> { + self.wallet + .stock() + .contract_iface_class::(contract_id) + .unwrap() + } + + pub fn contract_fungible_allocations( + &self, + contract_iface: &ContractIface, + ) -> Vec { + contract_iface + .fungible(fname!("assetOwner"), &self.wallet.wallet().filter()) + .unwrap() + .collect() + } + + pub fn contract_data_allocations( + &self, + contract_iface: &ContractIface, + ) -> Vec { + contract_iface + .data(fname!("assetOwner"), &self.wallet.wallet().filter()) + .unwrap() + .collect() + } + + pub fn debug_logs(&self, contract_id: ContractId, iface_type_name: &TypeName) { + let contract = self.contract_iface(contract_id, iface_type_name); + + println!("Global:"); + for global in &contract.iface.global_state { + if let Ok(values) = contract.global(global.name.clone()) { + for val in values { + println!(" {} := {}", global.name, val); + } + } + } + + println!("\nOwned:"); + for owned in &contract.iface.assignments { + println!(" {}:", owned.name); + if let Ok(allocations) = + contract.fungible(owned.name.clone(), &self.wallet.wallet().filter()) + { + for allocation in allocations { + println!( + " amount={}, utxo={}, witness={:?} # owned by the wallet", + allocation.state.value(), + allocation.seal, + allocation.witness + ); + } + } + if let Ok(allocations) = contract.fungible( + owned.name.clone(), + &FilterExclude(&self.wallet.wallet().filter()), + ) { + for allocation in allocations { + println!( + " amount={}, utxo={}, witness={:?} # owner unknown", + allocation.state.value(), + allocation.seal, + allocation.witness + ); + } + } + } + + let bp_runtime = self.wallet.wallet(); + println!("\nHeight\t{:>12}\t{:68}", "Amount, ṩ", "Outpoint"); + for (derived_addr, utxos) in bp_runtime.address_coins() { + println!("{}\t{}", derived_addr.addr, derived_addr.terminal); + for row in utxos { + println!("{}\t{: >12}\t{:68}", row.height, row.amount, row.outpoint); + } + println!() + } + + println!("\nWallet total balance: {} ṩ", bp_runtime.balance()); + } + + pub fn send( + &mut self, + recv_wlt: &mut TestWallet, + transfer_type: TransferType, + contract_id: ContractId, + iface_type_name: &TypeName, + amount: u64, + sats: u64, + ) -> (Transfer, Tx) { + let invoice = match transfer_type { + TransferType::Blinded => recv_wlt.invoice( + contract_id, + iface_type_name, + amount, + recv_wlt.close_method(), + InvoiceType::Blinded(None), + ), + TransferType::Witness => recv_wlt.invoice( + contract_id, + iface_type_name, + amount, + recv_wlt.close_method(), + InvoiceType::Witness, + ), + }; + self.send_to_invoice(recv_wlt, invoice, Some(sats), None) + } + + pub fn send_to_invoice( + &mut self, + recv_wlt: &mut TestWallet, + invoice: RgbInvoice, + sats: Option, + fee: Option, + ) -> (Transfer, Tx) { + let (consignment, tx) = self.transfer(invoice, sats, fee); + mine(false); + recv_wlt.accept_transfer(consignment.clone()); + self.sync(); + (consignment, tx) + } + + pub fn check_allocations( + &self, + contract_id: ContractId, + iface_type_name: &TypeName, + asset_schema: AssetSchema, + expected_fungible_allocations: Vec, + nonfungible_allocation: bool, + ) { + let contract_iface = self.contract_iface(contract_id, iface_type_name); + match asset_schema { + AssetSchema::Nia | AssetSchema::Cfa => { + let allocations = self.contract_fungible_allocations(&contract_iface); + assert_eq!(allocations.len(), expected_fungible_allocations.len()); + assert!(allocations + .iter() + .all(|a| a.seal.method() == self.close_method())); + for amount in expected_fungible_allocations { + assert_eq!( + allocations + .iter() + .filter(|a| a.state == Amount::from(amount)) + .count(), + 1 + ); + } + } + AssetSchema::Uda => { + let allocations = self.contract_data_allocations(&contract_iface); + let expected_allocations = if nonfungible_allocation { + assert_eq!( + allocations + .iter() + .filter(|a| a.state.to_string() == "000000000100000000000000") + .count(), + 1 + ); + 1 + } else { + 0 + }; + assert_eq!(allocations.len(), expected_allocations); + } + } + } + + fn _construct_psbt_offchain( + &mut self, + input_outpoints: Vec<(Outpoint, u64, Terminal)>, + beneficiaries: Vec<&PsbtBeneficiary>, + tx_params: TxParams, + ) -> (Psbt, PsbtMeta) { + let mut psbt = Psbt::create(PsbtVer::V2); + + for (outpoint, value, terminal) in input_outpoints { + psbt.construct_input_expect( + Prevout::new(outpoint, Sats::from(value)), + self.wallet.wallet().descriptor(), + terminal, + tx_params.seq_no, + ); + } + if psbt.inputs().count() == 0 { + panic!("no inputs"); + } + + let input_value = psbt.input_sum(); + let mut max = Vec::new(); + let mut output_value = Sats::ZERO; + for beneficiary in beneficiaries { + let amount = beneficiary.amount.unwrap_or(Sats::ZERO); + output_value.checked_add_assign(amount).unwrap(); + let out = psbt.construct_output_expect(beneficiary.script_pubkey(), amount); + if beneficiary.amount.is_max() { + max.push(out.index()); + } + } + let mut remaining_value = input_value + .checked_sub(output_value) + .unwrap() + .checked_sub(tx_params.fee) + .unwrap(); + if !max.is_empty() { + let portion = remaining_value / max.len(); + for out in psbt.outputs_mut() { + if max.contains(&out.index()) { + out.amount = portion; + } + } + remaining_value = Sats::ZERO; + } + + let (change_vout, change_terminal) = if remaining_value > Sats::from(546u64) { + let change_index = self + .wallet + .wallet_mut() + .next_derivation_index(tx_params.change_keychain, tx_params.change_shift); + let change_terminal = Terminal::new(tx_params.change_keychain, change_index); + let change_vout = psbt + .construct_change_expect( + self.wallet.wallet().descriptor(), + change_terminal, + remaining_value, + ) + .index(); + ( + Some(Vout::from_u32(change_vout as u32)), + Some(change_terminal), + ) + } else { + (None, None) + }; + + ( + psbt, + PsbtMeta { + change_vout, + change_terminal, + }, + ) + } + + fn _construct_beneficiaries( + &self, + beneficiaries: Vec<(Address, Option)>, + ) -> Vec { + beneficiaries + .into_iter() + .map(|(addr, amt)| { + let payment = if let Some(amt) = amt { + Payment::Fixed(Sats::from_sats(amt)) + } else { + Payment::Max + }; + PsbtBeneficiary::new(addr, payment) + }) + .collect() + } + + pub fn construct_psbt_offchain( + &mut self, + input_outpoints: Vec<(Outpoint, u64, Terminal)>, + beneficiaries: Vec<(Address, Option)>, + fee: Option, + ) -> (Psbt, PsbtMeta) { + let tx_params = TxParams::with(Sats::from_sats(fee.unwrap_or(400))); + let beneficiaries = self._construct_beneficiaries(beneficiaries); + let beneficiaries: Vec<&PsbtBeneficiary> = beneficiaries.iter().collect(); + + self._construct_psbt_offchain(input_outpoints, beneficiaries, tx_params) + } + + pub fn construct_psbt( + &mut self, + input_outpoints: Vec, + beneficiaries: Vec<(Address, Option)>, + fee: Option, + ) -> (Psbt, PsbtMeta) { + let tx_params = TxParams::with(Sats::from_sats(fee.unwrap_or(400))); + let beneficiaries = self._construct_beneficiaries(beneficiaries); + let beneficiaries: Vec<&PsbtBeneficiary> = beneficiaries.iter().collect(); + + self.wallet + .wallet_mut() + .construct_psbt(input_outpoints, beneficiaries, tx_params) + .unwrap() + } + + pub fn color_psbt( + &mut self, + psbt: &mut Psbt, + coloring_info: ColoringInfo, + ) -> (Fascia, AssetBeneficiariesMap) { + let _output = psbt.construct_output_expect(ScriptPubkey::op_return(&[]), Sats::ZERO); + + let prev_outputs = psbt + .to_unsigned_tx() + .inputs + .iter() + .map(|txin| txin.prev_output) + .map(|outpoint| XOutpoint::from(XChain::Bitcoin(outpoint))) + .collect::>(); + + let mut all_transitions: HashMap = HashMap::new(); + let mut asset_beneficiaries: AssetBeneficiariesMap = bmap![]; + let assignment_name = FieldName::from("assetOwner"); + + for (contract_id, asset_coloring_info) in coloring_info.asset_info_map.clone() { + let mut asset_transition_builder = self + .wallet + .stock_mut() + .transition_builder(contract_id, asset_coloring_info.iface, None::<&str>) + .unwrap(); + let assignment_id = asset_transition_builder + .assignments_type(&assignment_name) + .unwrap(); + + let mut asset_available_amt = 0; + for (_, opout_state_map) in self + .wallet + .stock_mut() + .contract_assignments_for(contract_id, prev_outputs.iter().copied()) + .unwrap() + { + for (opout, state) in opout_state_map { + if let PersistedState::Amount(amt, _, _) = &state { + asset_available_amt += amt.value(); + } + asset_transition_builder = + asset_transition_builder.add_input(opout, state).unwrap(); + } + } + + let mut beneficiaries = vec![]; + let mut sending_amt = 0; + for (vout, amount) in asset_coloring_info.output_map { + if amount == 0 { + continue; + } + sending_amt += amount; + if vout as usize > psbt.outputs().count() { + panic!("invalid vout in output_map, does not exist in the given PSBT"); + } + let graph_seal = if let Some(blinding) = asset_coloring_info.static_blinding { + GraphSeal::with_blinded_vout(CloseMethod::OpretFirst, vout, blinding) + } else { + GraphSeal::new_random_vout(CloseMethod::OpretFirst, vout) + }; + let seal = BuilderSeal::Revealed(XChain::with(Layer1::Bitcoin, graph_seal)); + beneficiaries.push(seal); + + let blinding_factor = if let Some(blinding) = asset_coloring_info.static_blinding { + let mut blinding_32_bytes: [u8; 32] = [0; 32]; + blinding_32_bytes[0..8].copy_from_slice(&blinding.to_le_bytes()); + BlindingFactor::try_from(blinding_32_bytes).unwrap() + } else { + BlindingFactor::random() + }; + asset_transition_builder = asset_transition_builder + .add_fungible_state_raw(assignment_id, seal, amount, blinding_factor) + .unwrap(); + } + if sending_amt > asset_available_amt { + panic!("total amount in output_map greater than available ({asset_available_amt})"); + } + + if let Some(nonce) = coloring_info.nonce { + asset_transition_builder = asset_transition_builder.set_nonce(nonce); + } + + let transition = asset_transition_builder.complete_transition().unwrap(); + all_transitions.insert(contract_id, transition); + asset_beneficiaries.insert(contract_id, beneficiaries); + } + + let (opreturn_index, _) = psbt + .to_unsigned_tx() + .outputs + .iter() + .enumerate() + .find(|(_, o)| o.script_pubkey.is_op_return()) + .expect("psbt should have an op_return output"); + let (_, opreturn_output) = psbt + .outputs_mut() + .enumerate() + .find(|(i, _)| i == &opreturn_index) + .unwrap(); + opreturn_output.set_opret_host().unwrap(); + if let Some(blinding) = coloring_info.static_blinding { + opreturn_output.set_mpc_entropy(blinding).unwrap(); + } + + let tx_inputs = psbt.clone().to_unsigned_tx().inputs; + for (contract_id, transition) in all_transitions { + for (input, txin) in psbt.inputs_mut().zip(&tx_inputs) { + let prevout = txin.prev_output; + let outpoint = Outpoint::new(prevout.txid.to_byte_array().into(), prevout.vout); + if coloring_info + .asset_info_map + .clone() + .get(&contract_id) + .unwrap() + .input_outpoints + .contains(&outpoint) + { + input + .set_rgb_consumer(contract_id, transition.id()) + .unwrap(); + } + } + psbt.push_rgb_transition(transition, CloseMethod::OpretFirst) + .unwrap(); + } + + psbt.complete_construction(); + let fascia = psbt.rgb_commit().unwrap(); + + (fascia, asset_beneficiaries) + } + + pub fn consume_fascia(&mut self, fascia: Fascia, witness_txid: Txid) { + struct FasciaResolver { + witness_id: XWitnessId, + } + impl ResolveWitness for FasciaResolver { + fn resolve_pub_witness( + &self, + _: XWitnessId, + ) -> Result { + unreachable!() + } + fn resolve_pub_witness_ord( + &self, + witness_id: XWitnessId, + ) -> Result { + assert_eq!(witness_id, self.witness_id); + Ok(WitnessOrd::Tentative) + } + } + + let resolver = FasciaResolver { + witness_id: XChain::Bitcoin(witness_txid), + }; + + self.wallet + .stock_mut() + .consume_fascia(fascia, resolver) + .unwrap(); + } + + pub fn update_witnesses(&mut self, after_height: u32) { + let resolver = self.get_resolver(); + self.wallet + .stock_mut() + .update_witnesses(resolver, after_height) + .unwrap(); + } +} diff --git a/tests/utils/mod.rs b/tests/utils/mod.rs new file mode 100644 index 0000000..e21401f --- /dev/null +++ b/tests/utils/mod.rs @@ -0,0 +1,90 @@ +pub mod chain; +pub mod helpers; + +pub const ELECTRUM_REGTEST_URL: &str = "127.0.0.1:50001"; +pub const ELECTRUM_MAINNET_URL: &str = "ssl://electrum.iriswallet.com:50003"; +pub const ESPLORA_REGTEST_URL: &str = "http://127.0.0.1:8094/regtest/api"; +pub const ESPLORA_MAINNET_URL: &str = "https://blockstream.info/api"; +pub const FAKE_TXID: &str = "e5a3e577309df31bd606f48049049d2e1e02b048206ba232944fcc053a176ccb:0"; +pub const UDA_FIXED_INDEX: u32 = 0; + +pub use std::{ + cell::OnceCell, + collections::{BTreeMap, BTreeSet, HashMap, HashSet}, + env::VarError, + ffi::OsString, + fmt::{self, Display}, + io::Write, + path::{PathBuf, MAIN_SEPARATOR}, + process::{Command, Stdio}, + str::FromStr, + sync::{Mutex, Once, OnceLock, RwLock}, +}; + +pub use amplify::{ + bmap, + confinement::{Confined, U16}, + map, s, ByteArray, Wrapper, +}; +use bitcoin_hashes::{sha256, Hash}; +pub use bp::{ + seals::txout::{BlindSeal, CloseMethod, ExplicitSeal}, + ConsensusDecode, Outpoint, Sats, ScriptPubkey, Tx, Txid, Vout, +}; +pub use bpstd::{ + h, signers::TestnetSigner, Address, DerivationPath, DerivationSeg, DerivedAddr, HardenedIndex, + Keychain, Network, Terminal, XkeyOrigin, Xpriv, XprivAccount, Xpub, XpubAccount, XpubDerivable, + XpubFp, +}; +pub use bpwallet::{ + fs::FsTextStore, indexers::esplora::Client as EsploraClient, AnyIndexer, Indexer as BpIndexer, + Wallet, +}; +pub use descriptors::Wpkh; +pub use electrum::{Client as ElectrumClient, ElectrumApi, Param}; +pub use ifaces::{ + rgb20, rgb21, + rgb21::{EmbeddedMedia, TokenData}, + rgb25, IssuerWrapper, Rgb20, Rgb21, Rgb25, +}; +pub use once_cell::sync::Lazy; +pub use psbt::{ + Beneficiary as PsbtBeneficiary, Payment, Prevout, Psbt, PsbtConstructor, PsbtMeta, PsbtVer, +}; +pub use psrgbt::{RgbExt, RgbInExt, RgbPsbt, TxParams}; +pub use rand::RngCore; +pub use rgb::{ + invoice::Pay2Vout, + persistence::{ContractStateRead, MemContract, MemContractState, Stock}, + resolvers::AnyResolver, + stl::ContractTerms, + validation::{Failure, ResolveWitness, WitnessResolverError}, + vm::{WitnessOrd, XWitnessTx}, + BlindingFactor, DescriptorRgb, GenesisSeal, GraphSeal, Identity, RgbDescr, RgbKeychain, + RgbWallet, TapretKey, TransferParams, Transition, WalletProvider, XOutpoint, XWitnessId, +}; +pub use rgbstd::{ + containers::{BuilderSeal, ConsignmentExt, Fascia, FileContent, Kit, Transfer, ValidKit}, + interface::{ + ContractBuilder, ContractIface, DataAllocation, FilterExclude, FungibleAllocation, Iface, + IfaceClass, IfaceId, IfaceImpl, NamedField, + }, + invoice::{Beneficiary, RgbInvoice, RgbInvoiceBuilder, XChainNet}, + persistence::{fs::FsBinStore, PersistedState, SchemaIfaces, StashReadProvider}, + schema::SchemaId, + stl::{ + AssetSpec, Attachment, Details, MediaType, Name, ProofOfReserves, RicardianContract, Ticker, + }, + validation::{Scripts, Validity}, + Allocation, Amount, ContractId, GlobalStateType, Layer1, Operation, OwnedFraction, Precision, + Schema, TokenIndex, TxoSeal, XChain, +}; +pub use rstest::rstest; +pub use schemata::{CollectibleFungibleAsset, NonInflatableAsset, UniqueDigitalAsset}; +pub use strict_encoding::{fname, tn, FieldName, StrictSerialize, TypeName}; +pub use strict_types::{StrictVal, TypeSystem}; +pub use strum::IntoEnumIterator; +pub use strum_macros::EnumIter; +pub use time::OffsetDateTime; + +pub use crate::utils::{chain::*, helpers::*}; diff --git a/vesper b/vesper new file mode 160000 index 0000000..6e1c889 --- /dev/null +++ b/vesper @@ -0,0 +1 @@ +Subproject commit 6e1c889e9b951ac709d7db0e57d02dc427446527