From 3ee5f97f108fc6c7bbeaf271973663b26e3ff3b9 Mon Sep 17 00:00:00 2001 From: eauxxs Date: Sun, 19 May 2024 14:17:24 +0800 Subject: [PATCH] com --- Cargo.lock | 548 +++++++++++++------------- Cargo.toml | 84 ++-- src/error.rs | 67 ++-- src/lib.rs | 51 +-- src/utils.rs | 333 ++++++++-------- src/wallet/offline.rs | 114 ++++-- src/wallet/online.rs | 249 ++++++------ src/wallet/test/blind_receive.rs | 8 +- src/wallet/test/get_asset_metadata.rs | 6 +- src/wallet/test/mod.rs | 9 +- src/wallet/test/refresh.rs | 8 +- src/wallet/test/save_new_asset.rs | 2 + src/wallet/test/utils/api.rs | 5 +- src/wallet/test/utils/helpers.rs | 2 +- src/wallet/test/witness_receive.rs | 2 +- 15 files changed, 799 insertions(+), 689 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f67f4a8..1763dfc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -64,12 +64,12 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "aluvm" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2032d213fd6b80b26217efb9846b273671acff3f696ada7e0314c6af2b4c3275" +source = "git+https://github.com/AluVM/rust-aluvm?branch=develop#25be42a16519383daaa6ba50e65654ff0a1721aa" dependencies = [ "amplify", "ascii-armor", - "baid58", + "baid64", + "blake3", "getrandom", "half", "paste", @@ -159,47 +159,48 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.13" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" [[package]] name = "anstyle-parse" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -228,12 +229,12 @@ dependencies = [ [[package]] name = "ascii-armor" -version = "0.2.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "743d90b41a39d6e3920eef64a70f6411097cbb47141606a45b2a96533ec7111c" +checksum = "673486110323d50d9f33d99f0f526726b4721b1b596284351e75d3692225abe8" dependencies = [ "amplify", - "baid58", + "baid64", "base85", "sha2", "strict_encoding", @@ -262,13 +263,13 @@ dependencies = [ [[package]] name = "async-channel" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "136d4d23bcc79e27423727b36823d86233aad06dfea531837b038394d11e9928" +checksum = "9f2776ead772134d55b62dd45e59a79e21612d85d0af729b8b7d3967d601a62a" dependencies = [ "concurrent-queue", "event-listener 5.3.0", - "event-listener-strategy 0.5.1", + "event-listener-strategy 0.5.2", "futures-core", "pin-project-lite", ] @@ -281,7 +282,7 @@ checksum = "b10202063978b3351199d68f8b22c4e47e4b1b822f8d43fd862d5ea8c006b29a" dependencies = [ "async-task", "concurrent-queue", - "fastrand 2.0.2", + "fastrand 2.1.0", "futures-lite 2.3.0", "slab", ] @@ -292,7 +293,7 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c" dependencies = [ - "async-channel 2.2.1", + "async-channel 2.3.0", "async-executor", "async-io 2.3.2", "async-lock 3.3.0", @@ -334,8 +335,8 @@ dependencies = [ "futures-io", "futures-lite 2.3.0", "parking", - "polling 3.6.0", - "rustix 0.38.33", + "polling 3.7.0", + "rustix 0.38.34", "slab", "tracing", "windows-sys 0.52.0", @@ -407,14 +408,14 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] name = "async-task" -version = "4.7.0" +version = "4.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbb36e985947064623dbd357f727af08ffd077f93d696782f3c56365fa2e2799" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" @@ -424,7 +425,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -444,9 +445,9 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "autocfg" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" @@ -464,23 +465,17 @@ dependencies = [ ] [[package]] -name = "baid58" -version = "0.4.4" +name = "baid64" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc0585242d87ed976e05db6ae86a0f771f140104a4b6c91b4c3e43b9b2357486" +checksum = "7b8b80494235048845f856b267a4a1d97df59fd14ed7ca92652f834ce93becc6" dependencies = [ - "base58", - "blake3", + "amplify", + "base64 0.22.1", "mnemonic", "sha2", ] -[[package]] -name = "base58" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6107fe1be6682a68940da878d9e9f5e90ca5745b3dec9fd1bb393c8777d4f581" - [[package]] name = "base64" version = "0.13.1" @@ -495,9 +490,9 @@ checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "base64" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "base64ct" @@ -688,25 +683,22 @@ dependencies = [ [[package]] name = "blocking" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" +checksum = "495f7104e962b7356f0aeb34247aca1fe7d2e783b346582db7f2904cb5717e88" dependencies = [ - "async-channel 2.2.1", + "async-channel 2.3.0", "async-lock 3.3.0", "async-task", - "fastrand 2.0.2", "futures-io", "futures-lite 2.3.0", "piper", - "tracing", ] [[package]] name = "bp-consensus" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "966395ea17fa99b33a9093355924b0f79312b410e2c8a85ca8ebb8333098fb9a" +source = "git+https://github.com/BP-WG/bp-core?branch=master#919a0b40b7d2d1e8c74bfca5d2569b65c45741dd" dependencies = [ "amplify", "chrono", @@ -720,8 +712,7 @@ dependencies = [ [[package]] name = "bp-core" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27581dae64d76a00fe4015eb7d710d262192ca6f18c1e798f75c4f5477f52d3c" +source = "git+https://github.com/BP-WG/bp-core?branch=master#919a0b40b7d2d1e8c74bfca5d2569b65c45741dd" dependencies = [ "amplify", "bp-consensus", @@ -739,8 +730,7 @@ dependencies = [ [[package]] name = "bp-dbc" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4d21f5af26b145f7f73c7a338dc7bfe44d2b0f943c3ec6e3447d11d1fc3d6e0" +source = "git+https://github.com/BP-WG/bp-core?branch=master#919a0b40b7d2d1e8c74bfca5d2569b65c45741dd" dependencies = [ "amplify", "base85", @@ -754,8 +744,7 @@ dependencies = [ [[package]] name = "bp-derive" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "259436bf0c49fa1fd0648cdde09d2d9bdc183dd4d2dfb3934902ef27faa9f14d" +source = "git+https://github.com/BP-WG/bp-std?branch=develop#3703d406e76d7ce1f85dd811a416569b4fabd889" dependencies = [ "amplify", "bitcoin_hashes 0.13.0", @@ -777,7 +766,7 @@ dependencies = [ "byteorder", "libc", "log", - "rustls 0.21.11", + "rustls 0.21.12", "serde", "serde_json", "sha2", @@ -804,8 +793,7 @@ dependencies = [ [[package]] name = "bp-invoice" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48ee0387fa924bd002b51713c42daf3cb7c3b669509523607445a99c90491788" +source = "git+https://github.com/BP-WG/bp-std?branch=develop#3703d406e76d7ce1f85dd811a416569b4fabd889" dependencies = [ "amplify", "bech32 0.9.1", @@ -817,11 +805,10 @@ dependencies = [ [[package]] name = "bp-seals" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "131f371c9d605d5ed07cb0f5b07f3f261f6b3f6a146b6e890ecdb37802c51f6a" +source = "git+https://github.com/BP-WG/bp-core?branch=master#919a0b40b7d2d1e8c74bfca5d2569b65c45741dd" dependencies = [ "amplify", - "baid58", + "baid64", "bp-consensus", "bp-dbc", "commit_verify", @@ -834,8 +821,7 @@ dependencies = [ [[package]] name = "bp-std" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84413a3ce10b304ce52c7a1604fccf78634f3a27df47b239be381b76ceb1bdea" +source = "git+https://github.com/BP-WG/bp-std?branch=develop#3703d406e76d7ce1f85dd811a416569b4fabd889" dependencies = [ "amplify", "bp-consensus", @@ -849,20 +835,16 @@ dependencies = [ [[package]] name = "bp-wallet" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4552e90fad2ed01b091b499b891e7a5d9e03f3c74e718e0e4801b01056fc247" +source = "git+https://github.com/BP-WG/bp-wallet?branch=develop#03bb754618f99351d56f5f972a62f0580292a8e8" dependencies = [ "amplify", - "bp-electrum", - "bp-esplora", "bp-std", - "cfg_eval", "descriptors", + "log", "psbt", "serde", - "serde_json", - "serde_with", "serde_yaml", + "strict_encoding", "toml", ] @@ -886,9 +868,9 @@ checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cc" -version = "1.0.95" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b" +checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" dependencies = [ "jobserver", "libc", @@ -907,17 +889,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "cfg_eval" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45565fc9416b9896014f5732ac776f810ee53a66730c17e4020c3ec064a8f88f" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.60", -] - [[package]] name = "chacha20" version = "0.9.1" @@ -999,7 +970,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -1019,15 +990,14 @@ dependencies = [ [[package]] name = "colorchoice" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" [[package]] name = "commit_encoding_derive" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d660fdac917fb67edd1707bc9481e51ed9062ab4ba1c4e56ed7856977fff9f3" +source = "git+https://github.com/LNP-BP/client_side_validation?branch=develop#5e50b251aa5a5c4d83c47dad609a15ef3d50800f" dependencies = [ "amplify", "amplify_syn", @@ -1039,8 +1009,7 @@ dependencies = [ [[package]] name = "commit_verify" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77b78d8453b82136eb9743a8da9a94e265146e5c48668f0e0e71859aa726fa67" +source = "git+https://github.com/LNP-BP/client_side_validation?branch=develop#5e50b251aa5a5c4d83c47dad609a15ef3d50800f" dependencies = [ "amplify", "commit_encoding_derive", @@ -1055,9 +1024,9 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" dependencies = [ "crossbeam-utils", ] @@ -1202,7 +1171,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -1213,7 +1182,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -1251,8 +1220,7 @@ dependencies = [ [[package]] name = "descriptors" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08e46bb50018748f38bad98647589f2bef433faa5d8ed233c1e472c51275bd0d" +source = "git+https://github.com/BP-WG/bp-std?branch=develop#3703d406e76d7ce1f85dd811a416569b4fabd889" dependencies = [ "amplify", "bp-derive", @@ -1331,7 +1299,7 @@ dependencies = [ "byteorder", "libc", "log", - "rustls 0.21.11", + "rustls 0.21.12", "serde", "serde_json", "webpki", @@ -1349,7 +1317,7 @@ dependencies = [ "byteorder", "libc", "log", - "rustls 0.21.11", + "rustls 0.21.12", "serde", "serde_json", "webpki-roots 0.25.4", @@ -1373,9 +1341,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys 0.52.0", @@ -1445,9 +1413,9 @@ dependencies = [ [[package]] name = "event-listener-strategy" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "332f51cb23d20b0de8458b86580878211da09bcd4503cb579c225b3d124cabb3" +checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" dependencies = [ "event-listener 5.3.0", "pin-project-lite", @@ -1464,9 +1432,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "finl_unicode" @@ -1482,9 +1450,9 @@ checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" [[package]] name = "flate2" -version = "1.0.28" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" dependencies = [ "crc32fast", "miniz_oxide", @@ -1599,8 +1567,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" dependencies = [ "futures-core", - "lock_api 0.4.11", - "parking_lot 0.12.1", + "lock_api 0.4.12", + "parking_lot 0.12.2", ] [[package]] @@ -1630,7 +1598,7 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" dependencies = [ - "fastrand 2.0.2", + "fastrand 2.1.0", "futures-core", "futures-io", "parking", @@ -1687,9 +1655,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -1758,9 +1726,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", "allocator-api2", @@ -1772,7 +1740,7 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" dependencies = [ - "hashbrown 0.14.3", + "hashbrown 0.14.5", ] [[package]] @@ -1926,7 +1894,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.5.6", + "socket2 0.5.7", "tokio", "tower-service", "tracing", @@ -1994,7 +1962,7 @@ dependencies = [ "http-body 1.0.0", "hyper 1.3.1", "pin-project-lite", - "socket2 0.5.6", + "socket2 0.5.7", "tokio", "tower", "tower-service", @@ -2058,7 +2026,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "serde", ] @@ -2070,7 +2038,7 @@ checksum = "0122b7114117e64a63ac49f752a5ca4624d534c7b1c7de796ac196381cd2d947" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -2119,6 +2087,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + [[package]] name = "itertools" version = "0.12.1" @@ -2136,9 +2110,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "685a7d121ee3f65ae4fddd72b25a04bb36b6af81bc0828f7d5434c0fe60fa3a2" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" dependencies = [ "libc", ] @@ -2172,9 +2146,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.153" +version = "0.2.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" [[package]] name = "libm" @@ -2226,9 +2200,9 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -2407,9 +2381,9 @@ dependencies = [ [[package]] name = "num-iter" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" dependencies = [ "autocfg", "num-integer", @@ -2418,9 +2392,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", "libm", @@ -2480,7 +2454,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -2531,7 +2505,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -2557,18 +2531,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", - "lock_api 0.4.11", + "lock_api 0.4.12", "parking_lot_core 0.8.6", ] [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" dependencies = [ - "lock_api 0.4.11", - "parking_lot_core 0.9.9", + "lock_api 0.4.12", + "parking_lot_core 0.9.10", ] [[package]] @@ -2601,15 +2575,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall 0.4.1", + "redox_syscall 0.5.1", "smallvec", - "windows-targets 0.48.5", + "windows-targets 0.52.5", ] [[package]] @@ -2625,9 +2599,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pbkdf2" @@ -2681,7 +2655,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -2698,12 +2672,12 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "piper" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "668d31b1c4eba19242f2088b2bf3316b82ca31082a8335764db4e083db7485d4" +checksum = "464db0c665917b13ebb5d453ccdec4add5658ee1adc7affc7677615356a8afaf" dependencies = [ "atomic-waker", - "fastrand 2.0.2", + "fastrand 2.1.0", "futures-io", ] @@ -2752,15 +2726,15 @@ dependencies = [ [[package]] name = "polling" -version = "3.6.0" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0c976a60b2d7e99d6f229e414670a9b85d13ac305cc6d1e9c134de58c5aaaf6" +checksum = "645493cf344456ef24219d02a768cf1fb92ddf8c92161679ae3d91b91a637be3" dependencies = [ "cfg-if 1.0.0", "concurrent-queue", "hermit-abi", "pin-project-lite", - "rustix 0.38.33", + "rustix 0.38.34", "tracing", "windows-sys 0.52.0", ] @@ -2814,9 +2788,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" dependencies = [ "unicode-ident", ] @@ -2824,8 +2798,7 @@ dependencies = [ [[package]] name = "psbt" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a572f23bb63e0826d4540a6b925f152c64a47e0871d63dc06553aa7fcd045e5a" +source = "git+https://github.com/BP-WG/bp-std?branch=develop#3703d406e76d7ce1f85dd811a416569b4fabd889" dependencies = [ "amplify", "base64 0.21.7", @@ -2902,6 +2875,15 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_syscall" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +dependencies = [ + "bitflags 2.5.0", +] + [[package]] name = "redox_users" version = "0.4.5" @@ -3004,7 +2986,7 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" dependencies = [ - "base64 0.22.0", + "base64 0.22.1", "bytes", "futures-channel", "futures-core", @@ -3042,13 +3024,11 @@ dependencies = [ [[package]] name = "rgb-core" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "377bc5d01d9b22fef51da1ab83cfc743bf29827ce11fc4a2616894282a95c6a8" +source = "git+https://github.com/RGB-WG/rgb-core?branch=develop#b34b2c7b96f669fb8bc7145ec7094cb65d8bbdf3" dependencies = [ "aluvm", "amplify", - "ascii-armor", - "baid58", + "baid64", "bp-core", "chrono", "commit_verify", @@ -3062,19 +3042,35 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "rgb-interfaces" +version = "0.11.0-beta.6" +source = "git+https://github.com/RGB-WG/rgb-interfaces?branch=master#b37aac5c511206f58a2ee92ae24467cacc874401" +dependencies = [ + "aluvm", + "amplify", + "bp-core", + "chrono", + "rgb-std", + "serde_json", + "sha2", + "strict_encoding", + "strict_types", +] + [[package]] name = "rgb-invoice" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb83cdef397b7e8d84bd46f3f61620d89436e139cbab1cb929fd1c29aae24376" +source = "git+https://github.com/eauxxs/rgb-std?branch=dev#7ad91ed137630fcfd28e5508aa3ca604396cec77" dependencies = [ "amplify", - "baid58", + "baid64", "bp-core", "bp-invoice", "fluent-uri", "indexmap 2.2.6", "percent-encoding", + "rand", "rgb-core", "serde", "strict_encoding", @@ -3086,7 +3082,7 @@ name = "rgb-lib" version = "0.3.0-alpha.2" dependencies = [ "amplify", - "base64 0.22.0", + "base64 0.22.1", "bdk", "bitcoin 0.30.2", "bp-core", @@ -3106,9 +3102,9 @@ dependencies = [ "regex", "reqwest 0.12.4", "rgb-core", + "rgb-interfaces", "rgb-invoice", "rgb-lib-migration", - "rgb-persist-fs", "rgb-psbt", "rgb-runtime", "rgb-schemata", @@ -3123,7 +3119,7 @@ dependencies = [ "slog-async", "slog-term", "strict_encoding", - "strict_encoding_derive", + "strict_encoding_derive 2.7.0-beta.3 (registry+https://github.com/rust-lang/crates.io-index)", "strict_types", "tempfile", "thiserror", @@ -3142,25 +3138,13 @@ dependencies = [ "sea-orm-migration", ] -[[package]] -name = "rgb-persist-fs" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1395497e320822a11f8db5097060f03c5dcde17d5b5dccb5f31a4a9a304085c3" -dependencies = [ - "amplify", - "rgb-std", - "strict_encoding", -] - [[package]] name = "rgb-psbt" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212024149dfccaa87d4764e845774a00592bbe81397597a65e969e49b0b64c31" +source = "git+https://github.com/eauxxs/rgb?branch=dev#72014cac683d076cab21be029b248dd5cd833092" dependencies = [ "amplify", - "baid58", + "baid64", "bp-core", "bp-std", "commit_verify", @@ -3174,11 +3158,10 @@ dependencies = [ [[package]] name = "rgb-runtime" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bc2dd7c058c9c408eb923e7000243c9301d765f661570252f12ab2189b7a600" +source = "git+https://github.com/eauxxs/rgb?branch=dev#72014cac683d076cab21be029b248dd5cd833092" dependencies = [ "amplify", - "baid58", + "baid64", "bp-core", "bp-electrum", "bp-esplora", @@ -3188,11 +3171,10 @@ dependencies = [ "commit_verify", "descriptors", "indexmap 2.2.6", - "rgb-persist-fs", + "log", "rgb-psbt", "rgb-std", "serde", - "serde_with", "serde_yaml", "strict_types", ] @@ -3200,13 +3182,13 @@ dependencies = [ [[package]] name = "rgb-schemata" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e9bb5205af73bf7cc9f4b471ca3e95817819f86932989a7cd974915d221d71" +source = "git+https://github.com/RGB-WG/rgb-schemata?branch=master#e88a0d48e7500aca6b0fd49856feaf187e75aa76" dependencies = [ "aluvm", "amplify", - "ascii-armor", "bp-core", + "chrono", + "rgb-interfaces", "rgb-std", "serde", "serde_json", @@ -3218,12 +3200,12 @@ dependencies = [ [[package]] name = "rgb-std" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a52e61cff03f205c5f4782bbe714d3a9a065086ec6c896ca39f3618aea5434d2" +source = "git+https://github.com/eauxxs/rgb-std?branch=dev#7ad91ed137630fcfd28e5508aa3ca604396cec77" dependencies = [ + "aluvm", "amplify", "ascii-armor", - "baid58", + "baid64", "base85", "bp-core", "chrono", @@ -3285,9 +3267,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustix" @@ -3305,9 +3287,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.33" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3cc72858054fcff6d7dea32df2aeaee6a7c24227366d7ea429aada2f26b16ad" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ "bitflags 2.5.0", "errno", @@ -3318,9 +3300,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.11" +version = "0.21.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fecbfb7b1444f477b345853b1fce097a2c6fb637b2bfb87e6bc5db0f043fae4" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", "ring", @@ -3357,15 +3339,15 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" dependencies = [ - "base64 0.22.0", + "base64 0.22.1", "rustls-pki-types", ] [[package]] name = "rustls-pki-types" -version = "1.4.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd36cc4259e3e4514335c4a138c6b43171a8d61d8f5c9348f9fc7529416f247" +checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" [[package]] name = "rustls-webpki" @@ -3390,15 +3372,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" +checksum = "092474d1a01ea8278f69e6a358998405fae5b8b963ddaeb2b0b04a128bf1dfb0" [[package]] name = "ryu" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "salsa20" @@ -3420,9 +3402,9 @@ dependencies = [ [[package]] name = "scc" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec96560eea317a9cc4e0bb1f6a2c93c09a19b8c4fc5cb3fcc0ec1c094cd783e2" +checksum = "76ad2bbb0ae5100a07b7a6f2ed7ab5fd0045551a4c507989b7a620046ea3efdc" dependencies = [ "sdd", ] @@ -3480,7 +3462,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -3532,7 +3514,7 @@ dependencies = [ "proc-macro2", "quote", "sea-bae", - "syn 2.0.60", + "syn 2.0.63", "unicode-ident", ] @@ -3584,7 +3566,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", "thiserror", ] @@ -3698,11 +3680,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" +checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.5.0", "core-foundation", "core-foundation-sys", "libc", @@ -3711,9 +3693,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" +checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" dependencies = [ "core-foundation-sys", "libc", @@ -3721,29 +3703,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.198" +version = "1.0.201" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" +checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.198" +version = "1.0.201" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" +checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] name = "serde_json" -version = "1.0.116" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "indexmap 2.2.6", "itoa", @@ -3784,11 +3766,11 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.7.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee80b0e361bbf88fd2f6e242ccd19cfda072cb0faa6ae694ecee08199938569a" +checksum = "0ad483d2ab0149d5a5ebcd9972a3852711e0153d863bf5a5d0391d28883c4a20" dependencies = [ - "base64 0.21.7", + "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", @@ -3802,14 +3784,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.7.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6561dc161a9224638a31d876ccdfefbc1df91d3f3a8342eddb35f055d48c7655" +checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -3827,25 +3809,25 @@ dependencies = [ [[package]] name = "serial_test" -version = "3.1.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb86f9315df5df6a70eae0cc22395a44e544a0d8897586820770a35ede74449" +checksum = "4b4b487fe2acf240a021cf57c6b2b4903b1e78ca0ecd862a71b71d2a51fed77d" dependencies = [ "once_cell", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "scc", "serial_test_derive", ] [[package]] name = "serial_test_derive" -version = "3.1.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9bb72430492e9549b0c4596725c0f82729bff861c45aa8099c0a8e67fc3b721" +checksum = "82fe9db325bcef1fbcde82e078a5cc4efdf787e96b3b9cf45b50b529f2083d67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -3892,8 +3874,7 @@ dependencies = [ [[package]] name = "single_use_seals" version = "0.11.0-beta.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8893da91eab5290895bb7913a786e26b2e170c568542451c12bf00cf1812035a" +source = "git+https://github.com/LNP-BP/client_side_validation?branch=develop#5e50b251aa5a5c4d83c47dad609a15ef3d50800f" dependencies = [ "amplify_derive", ] @@ -3972,9 +3953,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", "windows-sys 0.52.0", @@ -4003,7 +3984,7 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" dependencies = [ - "lock_api 0.4.11", + "lock_api 0.4.12", ] [[package]] @@ -4230,21 +4211,32 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "strict_encoding" -version = "2.7.0-beta.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12eaa6985afa31deacc86cdc4935a36960ae09131a1f4e1db430127ebc4f05d" +version = "2.7.0-beta.3" +source = "git+https://github.com/strict-types/strict-encoding?branch=develop#901e26ee8b01b3bcff4d7ac76acff2fcc633634b" dependencies = [ "amplify", "half", "serde", - "strict_encoding_derive", + "strict_encoding_derive 2.7.0-beta.3 (git+https://github.com/strict-types/strict-encoding?branch=develop)", ] [[package]] name = "strict_encoding_derive" -version = "2.7.0-beta.1" +version = "2.7.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b1b064a62618a785e6d8f4df13d905dc335b56400d48f9b4f8b12dcba82b260" +checksum = "475fa6f1fdde6e0555422b5111ad34bde30a1459af3599f920c3af9829772c0e" +dependencies = [ + "amplify_syn", + "heck 0.4.1", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "strict_encoding_derive" +version = "2.7.0-beta.3" +source = "git+https://github.com/strict-types/strict-encoding?branch=develop#901e26ee8b01b3bcff4d7ac76acff2fcc633634b" dependencies = [ "amplify_syn", "heck 0.4.1", @@ -4255,13 +4247,12 @@ dependencies = [ [[package]] name = "strict_types" -version = "2.7.0-beta.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78c32716de4b99b0e8fb0c114e99b6929613e8d7302999c6b8c77251783923ad" +version = "2.7.0-beta.3" +source = "git+https://github.com/strict-types/strict-types?branch=develop#86486d299bf068c734c406e529d35f0c25805293" dependencies = [ "amplify", "ascii-armor", - "baid58", + "baid64", "half", "indexmap 2.2.6", "serde", @@ -4331,9 +4322,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.60" +version = "2.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +checksum = "bf5be731623ca1a1fb7d8be6f261a3be6d3e2337b8a1f97be944d020c8fcb704" dependencies = [ "proc-macro2", "quote", @@ -4380,8 +4371,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if 1.0.0", - "fastrand 2.0.2", - "rustix 0.38.33", + "fastrand 2.1.0", + "rustix 0.38.34", "windows-sys 0.52.0", ] @@ -4398,22 +4389,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.59" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" +checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.59" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" +checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -4484,7 +4475,7 @@ dependencies = [ "mio", "num_cpus", "pin-project-lite", - "socket2 0.5.6", + "socket2 0.5.7", "tokio-macros", "windows-sys 0.48.0", ] @@ -4497,7 +4488,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -4524,16 +4515,15 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] @@ -4618,7 +4608,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] @@ -4736,11 +4726,11 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "ureq" -version = "2.9.6" +version = "2.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11f214ce18d8b2cbe84ed3aa6486ed3f5b285cf8d8fbdbce9f3f767a724adc35" +checksum = "d11a831e3c0b56e438a28308e7c810799e3c118417f342d30ecec080105395cd" dependencies = [ - "base64 0.21.7", + "base64 0.22.1", "flate2", "log", "once_cell", @@ -4779,9 +4769,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "value-bag" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74797339c3b98616c009c7c3eb53a0ce41e85c8ec66bd3db96ed132d20cfdee8" +checksum = "5a84c137d37ab0142f0f2ddfe332651fdbf252e7b7dbb4e67b6c1f1b2e925101" [[package]] name = "vcpkg" @@ -4807,9 +4797,9 @@ dependencies = [ [[package]] name = "waker-fn" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" +checksum = "317211a0dc0ceedd78fb2ca9a44aed3d7b9b26f81870d485c07122b4350673b7" [[package]] name = "walkdir" @@ -4863,7 +4853,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", "wasm-bindgen-shared", ] @@ -4897,7 +4887,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4980,11 +4970,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -5143,9 +5133,9 @@ checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winnow" -version = "0.6.6" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352" +checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" dependencies = [ "memchr 2.7.2", ] @@ -5172,22 +5162,22 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.63", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index f3d6f50..f14b441 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,9 +17,7 @@ exclude = ["migration"] members = [".", "migration"] [dependencies] -base64 = { version = "0.22.0", default-features = false, features = [ - "std", -] } +base64 = { version = "0.22.0", default-features = false, features = ["std"] } bdk = { version = "0.29", default-features = false, features = [ "key-value-db", "keys-bip39", @@ -34,9 +32,7 @@ electrum-client = { version = "0.19.0", optional = true, default-features = fals "proxy", "use-rustls", ] } -futures = { version = "0.3", default-features = false, features = [ - "executor", -] } +futures = { version = "0.3", default-features = false, features = ["executor"] } hex = { version = "0.4.3", default-features = false } rand = { version = "0.8.5", default-features = false } reqwest = { version = "0.12", default-features = false, features = [ @@ -56,9 +52,7 @@ sea-orm = { version = "=0.12.15", default-features = false, features = [ "sqlx-sqlite", ] } sea-query = { version = "=0.30.7", default-features = false } -serde = { version = "^1.0", default-features = false, features = [ - "derive", -] } +serde = { version = "^1.0", default-features = false, features = ["derive"] } serde_json = { version = "^1.0", default-features = false, features = [ "preserve_order", ] } @@ -71,34 +65,37 @@ time = { version = "0.3.34", default-features = false } tree_magic = { version = "0.2.3", default-features = false } typenum = { version = "1.17.0", default-features = false } walkdir = { version = "2.5.0", default-features = false } -zip = { version = "0.6.6", default-features = false, features = [ - "zstd", -] } +zip = { version = "0.6.6", default-features = false, features = ["zstd"] } # RGB-related deps -amplify = { version = "=4.6.0", default-features = false } -bp-core = { version = "=0.11.0-beta.5", default-features = false } -bp-electrum = { version = "=0.11.0-beta.5", optional = true, default-features = false, features = [ +amplify = { version = "4.6.0", default-features = false } +bp-core = { version = "0.11.0-beta.5", default-features = false } +bp-electrum = { version = "0.11.0-beta.5", optional = true, default-features = false, features = [ "proxy", "use-rustls", ] } -bp-seals = { version = "=0.11.0-beta.5", default-features = false } -bp-std = { version = "=0.11.0-beta.5", default-features = false } -commit_verify = { version = "=0.11.0-beta.5", default-features = false } -rgb-core = { version = "=0.11.0-beta.5", default-features = false, features = [ +bp-seals = { version = "0.11.0-beta.5", default-features = false } +bp-std = { version = "0.11.0-beta.5", default-features = false } +commit_verify = { version = "0.11.0-beta.5", default-features = false } +rgb-core = { version = "0.11.0-beta.5", default-features = false, features = [ "stl", ] } -rgb-invoice = { version = "=0.11.0-beta.5", default-features = false } -rgb-persist-fs = { version = "=0.11.1", default-features = false } -rgb-psbt = { version = "=0.11.0-beta.5", default-features = false } -rgb-runtime = { version = "=0.11.0-beta.5", default-features = false, features = [ - "serde", +rgb-invoice = { version = "0.11.0-beta.5", default-features = false } +rgb-psbt = { git = "https://github.com/eauxxs/rgb", branch = "dev" } +# rgb-persist-fs = { version = "0.11.1", default-features = false } +# rgb-runtime = { version = "0.11.0-beta.5", default-features = false, features = [ +# "serde", +# ] } +rgb-runtime = { git = "https://github.com/eauxxs/rgb", branch = "dev", features = [ + "all", ] } -rgb-schemata = { version = "=0.11.0-beta.5", default-features = false } -rgb-std = { version = "=0.11.0-beta.5", default-features = false } -strict_encoding = { version = "=2.7.0-beta.1", default-features = false } -strict_encoding_derive = { version = "=2.7.0-beta.1", default-features = false } # temporary dependency pin -strict_types = { version = "=2.7.0-beta.2", default-features = false } +# rgb-schemata = { version = "0.11.0-beta.5", default-features = false } +rgb-schemata = { git = "https://github.com/RGB-WG/rgb-schemata", branch = "master" } +rgb-interfaces = { git = "https://github.com/RGB-WG/rgb-interfaces", branch = "master" } +rgb-std = { version = "0.11.0-beta.5", default-features = false } +strict_encoding = { version = "2.7.0-beta.1", default-features = false } +strict_encoding_derive = { version = "2.7.0-beta.1", default-features = false } # temporary dependency pin +strict_types = { version = "2.7.0-beta.2", default-features = false } [dev-dependencies] copy_dir = { version = "0.1.3", default-features = false } @@ -115,9 +112,28 @@ electrum = [ "bdk/electrum", "bp-electrum", "electrum-client", - "rgb-runtime/electrum", -] -esplora = [ - "bdk/use-esplora-blocking", - "rgb-runtime/esplora_blocking", + # "rgb-runtime/electrum_blocking ", ] +esplora = ["bdk/use-esplora-blocking"] + +[patch.crates-io] +strict_encoding = { git = "https://github.com/strict-types/strict-encoding", branch = "develop" } +strict_types = { git = "https://github.com/strict-types/strict-types", branch = "develop" } +commit_verify = { git = "https://github.com/LNP-BP/client_side_validation", branch = "develop" } +single_use_seals = { git = "https://github.com/LNP-BP/client_side_validation", branch = "develop" } +bp-consensus = { git = "https://github.com/BP-WG/bp-core", branch = "master" } +bp-dbc = { git = "https://github.com/BP-WG/bp-core", branch = "master" } +bp-seals = { git = "https://github.com/BP-WG/bp-core", branch = "master" } +bp-core = { git = "https://github.com/BP-WG/bp-core", branch = "master" } +bp-invoice = { git = "https://github.com/BP-WG/bp-std", branch = "develop" } +bp-derive = { git = "https://github.com/BP-WG/bp-std", branch = "develop" } +bp-std = { git = "https://github.com/BP-WG/bp-std", branch = "develop" } +bp-wallet = { git = "https://github.com/BP-WG/bp-wallet", branch = "develop" } +psbt = { git = "https://github.com/BP-WG/bp-std", branch = "develop" } +descriptors = { git = "https://github.com/BP-WG/bp-std", branch = "develop" } +aluvm = { git = "https://github.com/AluVM/rust-aluvm", branch = "develop" } +rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "develop" } +rgb-std = { git = "https://github.com/eauxxs/rgb-std", branch = "dev" } +rgb-invoice = { git = "https://github.com/eauxxs/rgb-std", branch = "dev" } +rgb-schemata = { git = "https://github.com/RGB-WG/rgb-schemata", branch = "master" } +rgb-interfaces = { git = "https://github.com/RGB-WG/rgb-interfaces", branch = "master" } diff --git a/src/error.rs b/src/error.rs index 5be901c..26a92d7 100644 --- a/src/error.rs +++ b/src/error.rs @@ -3,6 +3,11 @@ //! This module defines the [`Error`] enum, containing all error variants returned by functions in //! the library. +use std::fmt::Display; + +use rgb::persistence::{IndexProvider, MemStash, StashProvider, StateProvider, StockError}; +use rgbinvoice::TransportParseError; + use super::*; /// The error variants returned by functions. @@ -449,10 +454,10 @@ pub enum InternalError { RgbLoad(#[from] rgbstd::containers::LoadError), #[error("RGB runtime error: {0}")] - RgbRuntime(#[from] rgb_rt::RuntimeError), + RgbRuntime(#[from] StockError), #[error("RGB stash error: {0}")] - RgbStash(#[from] rgbstd::persistence::StashError), + RgbStash(#[from] rgbstd::persistence::StashError), #[error("Seal parse error: {0}")] SealParse(#[from] bp::seals::txout::explicit::ParseError), @@ -532,30 +537,30 @@ impl From for Error { } } -impl From> - for InternalError -{ - fn from( - e: rgbstd::persistence::ConsignerError, - ) -> Self { - InternalError::RgbConsigner(e.to_string()) - } -} - -impl From> for InternalError { - fn from(e: rgbstd::persistence::InventoryDataError) -> Self { - InternalError::RgbInventoryData(e.to_string()) - } -} - -impl From> for InternalError { - fn from(e: rgbstd::persistence::InventoryError) -> Self { - InternalError::RgbInventory(e.to_string()) - } -} - -impl From for Error { - fn from(e: invoice::TransportParseError) -> Self { +// impl From> +// for InternalError +// { +// fn from( +// e: rgbstd::persistence::ConsignerError, +// ) -> Self { +// InternalError::RgbConsigner(e.to_string()) +// } +// } + +// impl From> for InternalError { +// fn from(e: rgbstd::persistence::InventoryDataError) -> Self { +// InternalError::RgbInventoryData(e.to_string()) +// } +// } + +// impl From> for InternalError { +// fn from(e: rgbstd::persistence::InventoryError) -> Self { +// InternalError::RgbInventory(e.to_string()) +// } +// } + +impl From for Error { + fn from(e: TransportParseError) -> Self { Error::InvalidTransportEndpoint { details: e.to_string(), } @@ -593,3 +598,13 @@ impl From for Error { } } } + +impl + From> for Error +{ + fn from(value: StockError) -> Self { + Error::Internal { + details: value.to_string(), + } + } +} diff --git a/src/lib.rs b/src/lib.rs index 11d46d5..785f702 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -67,7 +67,7 @@ pub mod utils; pub mod wallet; pub use bdk::{BlockTime, SignOptions}; -pub use rgbstd::{containers::Contract, contract::ContractId}; +pub use rgbstd::containers::Contract; pub use crate::{ database::enums::{AssetSchema, TransferStatus, TransportType}, @@ -164,57 +164,46 @@ use commit_verify::Conceal; #[cfg(feature = "electrum")] use electrum_client::{Client as ElectrumClient, ConfigBuilder, ElectrumApi, Param}; use futures::executor::block_on; +use psrgbt::{PropKey, ProprietaryKeyRgb}; #[cfg(any(feature = "electrum", feature = "esplora"))] -use invoice::{Amount, Precision}; -use invoice::{Beneficiary, RgbInvoice, RgbInvoiceBuilder, RgbTransport, XChainNet}; -use psbt::{PropKey, ProprietaryKeyRgb}; -#[cfg(any(feature = "electrum", feature = "esplora"))] -use psbt::{Psbt as RgbPsbt, RgbPsbt as RgbPsbtTrait}; +use psrgbt::{Psbt as RgbPsbt, RgbPsbt as RgbPsbtTrait}; use rand::{distributions::Alphanumeric, Rng}; #[cfg(any(feature = "electrum", feature = "esplora"))] use reqwest::{ blocking::{multipart, Client as RestClient}, header::CONTENT_TYPE, }; +#[cfg(any(feature = "electrum", feature = "esplora"))] +use rgb::invoice::{Amount, Precision}; +use rgb::invoice::{Beneficiary, RgbInvoice, RgbInvoiceBuilder, RgbTransport, XChainNet}; +#[cfg(feature = "electrum")] +use rgb::AnyResolver as ElectrumResolver; +#[cfg(any(feature = "electrum", feature = "esplora"))] +use rgb::AnyResolver; use rgb::{ - validation::Status, Genesis, Layer1, OpId, Opout, SchemaId, SubSchema, Transition, XChain, - XOutpoint, XOutputSeal, + validation::Status, Genesis, Layer1, OpId, Opout, SchemaId, Transition, XChain, XOutpoint, + XOutputSeal, }; #[cfg(any(feature = "electrum", feature = "esplora"))] -use rgb::{validation::Validity, Assign, BlindingFactor, WitnessId}; +use rgb::{validation::Validity, Assign, BlindingFactor}; use rgb_lib_migration::{Migrator, MigratorTrait}; -#[cfg(feature = "electrum")] -use rgb_rt::electrum::Resolver as ElectrumResolver; #[cfg(feature = "esplora")] use rgb_rt::esplora_blocking::Resolver as EsploraResolver; #[cfg(any(feature = "electrum", feature = "esplora"))] -use rgb_rt::AnyResolver; -use rgb_schemata::{cfa_rgb25, cfa_schema, uda_rgb21, uda_schema, NonInflatableAsset}; -use rgbfs::StockFs; use rgbstd::{ - accessors::MergeReveal, + containers::{BuilderSeal, FileContent}, + interface::ContractBuilder, + stl::{AssetSpec, ContractTerms, Details, Name, RicardianContract, Ticker}, +}; +use rgbstd::{ containers::{CloseMethodSet, Fascia, Transfer as RgbTransfer}, - contract::GraphSeal, - interface::{ - ContractIface, Iface, IfaceClass, IfaceId, IfaceImpl, IssuerClass, Rgb20, Rgb21, Rgb25, - TransitionBuilder, - }, + interface::{ContractIface, Iface, IfaceClass, IfaceId, IfaceImpl, TransitionBuilder}, invoice::{ChainNet, InvoiceState}, - persistence::{Inventory, PersistedState, Stash, Stock}, + persistence::{PersistedState, Stock}, resolvers::ResolveHeight, stl::{Attachment, MediaType}, Operation, Txid as RgbTxid, }; -#[cfg(any(feature = "electrum", feature = "esplora"))] -use rgbstd::{ - containers::{BuilderSeal, FileContent}, - contract::GenesisSeal, - interface::{ - rgb21::{Allocation, OwnedFraction, TokenData, TokenIndex}, - ContractBuilder, - }, - stl::{AssetSpec, AssetTerms, Details, Name, RicardianContract, Ticker}, -}; use scrypt::{ password_hash::{PasswordHasher, Salt, SaltString}, Params, Scrypt, diff --git a/src/utils.rs b/src/utils.rs index 05d414c..91bfca2 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -2,6 +2,14 @@ //! //! This module defines some utility methods. +use std::ops::{Deref, DerefMut}; + +use rgb::containers::{ValidContract, ValidTransfer}; +use rgb::interface::IfaceRef; +use rgb::persistence::fs::{LoadFs, StoreFs}; +use rgb::ContractId; +use rgb::MergeReveal; + use super::*; const TIMESTAMP_FORMAT: &[time::format_description::BorrowedFormatItem] = time::macros::format_description!( @@ -289,159 +297,176 @@ pub struct RgbRuntime { pub wallet_dir: PathBuf, } -impl RgbRuntime { - #[cfg_attr(not(any(feature = "electrum", feature = "esplora")), allow(dead_code))] - pub(crate) fn accept_transfer( - &mut self, - transfer: RgbTransfer, - resolver: &mut R, - force: bool, - ) -> Result - where - R::Error: 'static, - { - self.stock - .accept_transfer(transfer, resolver, force) - .map_err(InternalError::from) - } - - #[cfg_attr(not(any(feature = "electrum", feature = "esplora")), allow(dead_code))] - pub(crate) fn blank_builder( - &mut self, - contract_id: ContractId, - iface: impl Into, - ) -> Result { - self.stock - .blank_builder(contract_id, iface) - .map_err(InternalError::from) - } - - #[cfg_attr(not(any(feature = "electrum", feature = "esplora")), allow(dead_code))] - pub(crate) fn consume(&mut self, fascia: Fascia) -> Result<(), InternalError> { - self.stock.consume(fascia).map_err(InternalError::from) - } - - #[cfg_attr(not(any(feature = "electrum", feature = "esplora")), allow(dead_code))] - pub(crate) fn contract_ids(&self) -> Result, InternalError> { - self.stock.contract_ids().map_err(InternalError::from) - } - - pub(crate) fn contract_iface_id( - &mut self, - contract_id: ContractId, - iface_id: IfaceId, - ) -> Result { - self.stock - .contract_iface_id(contract_id, iface_id) - .map_err(InternalError::from) - } - - #[cfg_attr(not(any(feature = "electrum", feature = "esplora")), allow(dead_code))] - pub(crate) fn contracts_by_outputs( - &mut self, - outputs: impl IntoIterator>, - ) -> Result, InternalError> { - self.stock - .contracts_by_outputs(outputs) - .map_err(InternalError::from) - } - - pub(crate) fn export_contract( - &self, - contract_id: ContractId, - ) -> Result { - self.stock - .export_contract(contract_id) - .map_err(InternalError::from) - } - - #[cfg_attr(not(any(feature = "electrum", feature = "esplora")), allow(dead_code))] - pub(crate) fn genesis(&self, contract_id: ContractId) -> Result<&Genesis, InternalError> { - self.stock.genesis(contract_id).map_err(InternalError::from) - } - - pub(crate) fn iface_by_name(&self, name: &TypeName) -> Result<&Iface, InternalError> { - self.stock.iface_by_name(name).map_err(InternalError::from) - } - - #[cfg_attr(not(any(feature = "electrum", feature = "esplora")), allow(dead_code))] - pub(crate) fn import_contract( - &mut self, - contract: Contract, - resolver: &mut R, - ) -> Result - where - R::Error: 'static, - { - self.stock - .import_contract(contract, resolver) - .map_err(InternalError::from) - } - - pub(crate) fn import_iface(&mut self, iface: Iface) -> Result { - self.stock.import_iface(iface).map_err(InternalError::from) - } - - pub(crate) fn import_iface_impl(&mut self, iimpl: IfaceImpl) -> Result { - self.stock - .import_iface_impl(iimpl) - .map_err(InternalError::from) - } - - pub(crate) fn import_schema(&mut self, schema: SubSchema) -> Result { - self.stock - .import_schema(schema) - .map_err(InternalError::from) - } - - pub(crate) fn schema_ids(&self) -> Result, InternalError> { - self.stock.schema_ids().map_err(InternalError::from) - } - - #[cfg_attr(not(any(feature = "electrum", feature = "esplora")), allow(dead_code))] - pub(crate) fn state_for_outpoints( - &mut self, - contract_id: ContractId, - outpoints: impl IntoIterator>, - ) -> Result, InternalError> { - self.stock - .state_for_outpoints(contract_id, outpoints) - .map_err(InternalError::from) - } - - pub(crate) fn store_seal_secret( - &mut self, - seal: XChain, - ) -> Result<(), InternalError> { - self.stock - .store_seal_secret(seal) - .map_err(InternalError::from) - } - - #[cfg_attr(not(any(feature = "electrum", feature = "esplora")), allow(dead_code))] - pub(crate) fn transfer( - &mut self, - contract_id: ContractId, - outputs: impl AsRef<[XOutputSeal]>, - secret_seals: impl AsRef<[XChain]>, - ) -> Result { - self.stock - .transfer(contract_id, outputs, secret_seals) - .map_err(|_| InternalError::Unexpected) - } - - #[cfg_attr(not(any(feature = "electrum", feature = "esplora")), allow(dead_code))] - pub(crate) fn transition_builder( - &mut self, - contract_id: ContractId, - iface: impl Into, - transition_name: Option>, - ) -> Result { - self.stock - .transition_builder(contract_id, iface, transition_name) - .map_err(InternalError::from) - } -} +impl Deref for RgbRuntime { + type Target = Stock; + + fn deref(&self) -> &Self::Target { + &self.stock + } +} + +impl DerefMut for RgbRuntime { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.stock + } +} + +// impl RgbRuntime { +// #[cfg_attr(not(any(feature = "electrum", feature = "esplora")), allow(dead_code))] +// pub(crate) fn accept_transfer( +// &mut self, +// transfer: ValidTransfer, +// resolver: &mut R, +// _force: bool, +// ) -> Result +// // where +// // R::Error: 'static, +// { +// self.stock +// .accept_transfer(transfer, resolver) +// .map_err(InternalError::from) +// } + +// #[cfg_attr(not(any(feature = "electrum", feature = "esplora")), allow(dead_code))] +// pub(crate) fn blank_builder( +// &mut self, +// contract_id: ContractId, +// iface: impl Into, +// ) -> Result { +// self.stock +// .blank_builder(contract_id, iface) +// .map_err(InternalError::from) +// } + +// #[cfg_attr(not(any(feature = "electrum", feature = "esplora")), allow(dead_code))] +// pub(crate) fn consume(&mut self, fascia: Fascia) -> Result<(), InternalError> { +// self.stock +// .consume_fascia(fascia) +// .map_err(InternalError::from) +// } + +// #[cfg_attr(not(any(feature = "electrum", feature = "esplora")), allow(dead_code))] +// pub(crate) fn contract_ids(&self) -> Result, InternalError> { +// self.stock.contracts()?.map(|c| c.id).collect() +// // .map_err(InternalError::from) +// } + +// pub(crate) fn contract_iface_id( +// &mut self, +// contract_id: ContractId, +// iface_id: IfaceRef, +// ) -> Result { +// self.stock +// .contract_iface(contract_id, iface_id) +// .map_err(InternalError::from) +// } + +// #[cfg_attr(not(any(feature = "electrum", feature = "esplora")), allow(dead_code))] +// pub(crate) fn contracts_by_outputs( +// &mut self, +// outputs: impl IntoIterator>, +// ) -> Result, InternalError> { +// self.stock +// .contracts_by_outputs(outputs) +// .map_err(InternalError::from) +// } + +// pub(crate) fn export_contract( +// &self, +// contract_id: ContractId, +// ) -> Result { +// self.stock +// .export_contract(contract_id) +// .map_err(InternalError::from) +// } + +// #[cfg_attr(not(any(feature = "electrum", feature = "esplora")), allow(dead_code))] +// pub(crate) fn genesis(&self, contract_id: ContractId) -> Result<&Genesis, InternalError> { +// self.stock.genesis(contract_id).map_err(InternalError::from) +// } + +// pub(crate) fn iface_by_name(&self, name: &TypeName) -> Result<&Iface, InternalError> { +// self.stock.iface_by_name(name).map_err(InternalError::from) +// } + +// #[cfg_attr(not(any(feature = "electrum", feature = "esplora")), allow(dead_code))] +// pub(crate) fn import_contract( +// &mut self, +// contract: ValidContract, +// resolver: &mut R, +// ) -> Result +// // where +// // R::Error: 'static, +// { +// self.stock +// .import_contract(contract, resolver) +// .map_err(InternalError::from) +// } + +// pub(crate) fn import_iface(&mut self, iface: Iface) -> Result { +// self.stock.import_iface(iface).map_err(InternalError::from) +// } + +// pub(crate) fn import_iface_impl(&mut self, iimpl: IfaceImpl) -> Result { +// self.stock +// .import_iface_impl(iimpl) +// .map_err(InternalError::from) +// } + +// pub(crate) fn import_schema(&mut self, schema: SubSchema) -> Result { +// self.stock +// .import_schema(schema) +// .map_err(InternalError::from) +// } + +// pub(crate) fn schema_ids(&self) -> Result, InternalError> { +// self.stock.schema_ids().map_err(InternalError::from) +// } + +// #[cfg_attr(not(any(feature = "electrum", feature = "esplora")), allow(dead_code))] +// pub(crate) fn state_for_outpoints( +// &mut self, +// contract_id: ContractId, +// outpoints: impl IntoIterator>, +// ) -> Result, InternalError> { +// self.stock +// .state_for_outpoints(contract_id, outpoints) +// .map_err(InternalError::from) +// } + +// pub(crate) fn store_seal_secret( +// &mut self, +// seal: XChain, +// ) -> Result<(), InternalError> { +// self.stock +// .store_secret_seal(seal) +// .map_err(InternalError::from) +// } + +// #[cfg_attr(not(any(feature = "electrum", feature = "esplora")), allow(dead_code))] +// pub(crate) fn transfer( +// &mut self, +// contract_id: ContractId, +// outputs: impl AsRef<[XOutputSeal]>, +// secret_seals: impl AsRef<[XChain]>, +// ) -> Result { +// self.stock +// .transfer(contract_id, outputs, secret_seals) +// .map_err(|_| InternalError::Unexpected) +// } + +// #[cfg_attr(not(any(feature = "electrum", feature = "esplora")), allow(dead_code))] +// pub(crate) fn transition_builder( +// &mut self, +// contract_id: ContractId, +// iface: impl Into, +// transition_name: Option>, +// ) -> Result { +// self.stock +// .transition_builder(contract_id, iface, transition_name) +// .map_err(InternalError::from) +// } +// } impl Drop for RgbRuntime { fn drop(&mut self) { @@ -479,7 +504,7 @@ pub fn load_rgb_runtime(wallet_dir: PathBuf) -> Result { if !rgb_dir.exists() { fs::create_dir_all(&rgb_dir)?; } - let stock_path = rgb_dir.join("stock.dat"); + let stock_path = rgb_dir; let stock = Stock::load(&stock_path).or_else(|err| { if matches!(err, DeserializeError::Decode(DecodeError::Io(ref err)) if err.kind() == ErrorKind::NotFound) { let stock = Stock::default(); diff --git a/src/wallet/offline.rs b/src/wallet/offline.rs index 01aaeff..8070169 100644 --- a/src/wallet/offline.rs +++ b/src/wallet/offline.rs @@ -2,6 +2,10 @@ //! //! This module defines the offline methods of the [`Wallet`] structure and all its related data. +use ifaces::{rgb20, rgb21, rgb25, IssuerWrapper, Rgb20, Rgb21, Rgb25}; +use rgb::{containers::Kit, ContractId, GraphSeal, Identity}; +use schemata::{CollectibleFungibleAsset, NonInflatableAsset, UniqueDigitalAsset}; + use super::*; pub(crate) const RGB_LIB_DB_NAME: &str = "rgb_lib_db"; @@ -25,21 +29,21 @@ pub(crate) const DURATION_RCV_TRANSFER: u32 = 86400; const PROXY_TIMEOUT: u8 = 90; pub(crate) const SCHEMA_ID_NIA: &str = - "urn:lnp-bp:sc:2wFrMq-DQGYEXLx-YN5TgGiv-M7uxbA56-yqCtf7rd-MNTSvC#carol-politic-lima"; + "rgb:sch:KzMZV9bO7gFhox97@klj0FonG2ZKnjuOIg2tFChu$YA#lucas-episode-silicon"; pub(crate) const SCHEMA_ID_UDA: &str = - "urn:lnp-bp:sc:bBaser-EMBDKaHk-o1gnNUrN-JzoYNYWW-PkEqD1t3-VHcvx#vital-papa-time"; + "rgb:sch:zsu4e2XePxL$CV62b5zrHzViasqEfara441L9t@1wVo#jungle-valid-summer"; pub(crate) const SCHEMA_ID_CFA: &str = - "urn:lnp-bp:sc:MCpHX1-1FrUH41Q-7vb9EABB-CaggZc6b-qDiZUZhi-4HvSt#alien-profile-sushi"; + "rgb:sch:WyrI$aUDuVjbYe10jDRYw$R7vQ0r4DSTitf4Wfx$La8#mister-clinic-history"; /// The interface of an RGB asset. #[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)] pub enum AssetIface { /// RGB20 interface - RGB20, + RGB20Fixed, /// RGB21 interface - RGB21, + RGB21Unique, /// RGB25 interface - RGB25, + RGB25Base, } impl AssetIface { @@ -60,7 +64,7 @@ impl AssetIface { medias: Option>, ) -> Result { let media = match &self { - AssetIface::RGB20 | AssetIface::RGB25 => { + AssetIface::RGB20Fixed | AssetIface::RGB25Base => { let medias = if let Some(m) = medias { m } else { @@ -71,7 +75,7 @@ impl AssetIface { .find(|m| Some(m.idx) == asset.media_idx) .map(|m| Media::from_db_media(m, wallet.media_dir())) } - AssetIface::RGB21 => None, + AssetIface::RGB21Unique => None, }; let balance = wallet.database.get_asset_balance( asset.id.clone(), @@ -83,7 +87,7 @@ impl AssetIface { )?; let issued_supply = asset.issued_supply.parse::().unwrap(); Ok(match &self { - AssetIface::RGB20 => AssetType::AssetNIA(AssetNIA { + AssetIface::RGB20Fixed => AssetType::AssetNIA(AssetNIA { asset_id: asset.id.clone(), asset_iface: self.clone(), ticker: asset.ticker.clone().unwrap(), @@ -96,7 +100,7 @@ impl AssetIface { balance, media, }), - AssetIface::RGB21 => AssetType::AssetUDA(AssetUDA { + AssetIface::RGB21Unique => AssetType::AssetUDA(AssetUDA { asset_id: asset.id.clone(), asset_iface: self.clone(), details: asset.details.clone(), @@ -109,7 +113,7 @@ impl AssetIface { balance, token, }), - AssetIface::RGB25 => AssetType::AssetCFA(AssetCFA { + AssetIface::RGB25Base => AssetType::AssetCFA(AssetCFA { asset_id: asset.id.clone(), asset_iface: self.clone(), name: asset.name.clone(), @@ -128,9 +132,9 @@ impl AssetIface { impl From for AssetIface { fn from(x: AssetSchema) -> AssetIface { match x { - AssetSchema::Nia => AssetIface::RGB20, - AssetSchema::Uda => AssetIface::RGB21, - AssetSchema::Cfa => AssetIface::RGB25, + AssetSchema::Nia => AssetIface::RGB20Fixed, + AssetSchema::Uda => AssetIface::RGB21Unique, + AssetSchema::Cfa => AssetIface::RGB25Base, } } } @@ -140,9 +144,9 @@ impl TryFrom for AssetIface { fn try_from(value: TypeName) -> Result { match value.to_string().as_str() { - "RGB20" => Ok(AssetIface::RGB20), - "RGB21" => Ok(AssetIface::RGB21), - "RGB25" => Ok(AssetIface::RGB25), + "RGB20Fixed" => Ok(AssetIface::RGB20Fixed), + "RGB21Unique" => Ok(AssetIface::RGB21Unique), + "RGB25Base" => Ok(AssetIface::RGB25Base), _ => Err(Error::UnknownRgbInterface { interface: value.to_string(), }), @@ -254,7 +258,7 @@ impl AssetNIA { txos: Option>, medias: Option>, ) -> Result { - match AssetIface::RGB20.get_asset_details( + match AssetIface::RGB20Fixed.get_asset_details( wallet, asset, None, @@ -369,7 +373,7 @@ impl AssetUDA { colorings: Option>, txos: Option>, ) -> Result { - match AssetIface::RGB21.get_asset_details( + match AssetIface::RGB21Unique.get_asset_details( wallet, asset, token, @@ -422,7 +426,7 @@ impl AssetCFA { txos: Option>, medias: Option>, ) -> Result { - match AssetIface::RGB25.get_asset_details( + match AssetIface::RGB25Base.get_asset_details( wallet, asset, None, @@ -1031,6 +1035,7 @@ pub struct Wallet { max_allocations_per_utxo: u32, #[cfg(any(feature = "electrum", feature = "esplora"))] pub(crate) online_data: Option, + pub(crate) issuer: Identity, } impl Wallet { @@ -1113,18 +1118,55 @@ impl Wallet { // RGB setup let mut runtime = load_rgb_runtime(wallet_dir.clone())?; - if runtime.schema_ids()?.len() < NUM_KNOWN_SCHEMAS { - runtime.import_iface(Rgb20::iface())?; - runtime.import_schema(NonInflatableAsset::schema())?; - runtime.import_iface_impl(NonInflatableAsset::issue_impl())?; - - runtime.import_iface(Rgb21::iface())?; - runtime.import_schema(uda_schema())?; - runtime.import_iface_impl(uda_rgb21())?; - - runtime.import_iface(Rgb25::iface())?; - runtime.import_schema(cfa_schema())?; - runtime.import_iface_impl(cfa_rgb25())?; + if runtime.schemata()?.count() < NUM_KNOWN_SCHEMAS { + { + let schema = NonInflatableAsset::schema(); + let iimpl = NonInflatableAsset::issue_impl(); + let lib = NonInflatableAsset::scripts(); + let types = NonInflatableAsset::types(); + + let mut kit = Kit::default(); + kit.schemata.push(schema).unwrap(); + kit.ifaces + .push(Rgb20::iface(rgb20::Features::FIXED)) + .unwrap(); + kit.iimpls.push(iimpl).unwrap(); + kit.scripts.extend(lib.into_values()).unwrap(); + kit.types = types; + runtime.import_kit(kit.validate().unwrap()).unwrap(); + } + { + let schema = UniqueDigitalAsset::schema(); + let iimpl = UniqueDigitalAsset::issue_impl(); + let lib = UniqueDigitalAsset::scripts(); + let types = UniqueDigitalAsset::types(); + + let mut kit = Kit::default(); + kit.schemata.push(schema).unwrap(); + kit.ifaces + .push(Rgb21::iface(rgb21::Features::NONE)) + .unwrap(); + kit.iimpls.push(iimpl).unwrap(); + kit.scripts.extend(lib.into_values()).unwrap(); + kit.types = types; + runtime.import_kit(kit.validate().unwrap()).unwrap(); + } + { + let schema = CollectibleFungibleAsset::schema(); + let iimpl = CollectibleFungibleAsset::issue_impl(); + let lib = CollectibleFungibleAsset::scripts(); + let types = CollectibleFungibleAsset::types(); + + let mut kit = Kit::default(); + kit.schemata.push(schema).unwrap(); + kit.ifaces + .push(Rgb25::iface(rgb25::Features::NONE)) + .unwrap(); + kit.iimpls.push(iimpl).unwrap(); + kit.scripts.extend(lib.into_values()).unwrap(); + kit.types = types; + runtime.import_kit(kit.validate().unwrap()).unwrap(); + } } // RGB-LIB setup @@ -1158,6 +1200,7 @@ impl Wallet { max_allocations_per_utxo: wdata.max_allocations_per_utxo, #[cfg(any(feature = "electrum", feature = "esplora"))] online_data: None, + issuer: Identity::from_str("123").unwrap(), }) } @@ -1512,7 +1555,7 @@ impl Wallet { )?; let mut runtime = self.rgb_runtime()?; - runtime.store_seal_secret(seal)?; + runtime.store_secret_seal(seal)?; let db_coloring = DbColoringActMod { txo_idx: ActiveValue::Set(utxo.idx), @@ -1781,9 +1824,10 @@ impl Wallet { contract_id: ContractId, ) -> Result { let iface_name = AssetIface::from(*asset_schema).to_typename(); - let iface = runtime.iface_by_name(&iface_name)?.clone(); + let iface = runtime.stock.iface(iface_name)?.clone(); runtime - .contract_iface_id(contract_id, iface.iface_id()) + .stock + .contract_iface(contract_id, iface.iface_id()) .map_err(|_| Error::AssetIfaceMismatch) } diff --git a/src/wallet/online.rs b/src/wallet/online.rs index f31207d..426cab3 100644 --- a/src/wallet/online.rs +++ b/src/wallet/online.rs @@ -2,6 +2,16 @@ //! //! This module defines the online methods of the [`Wallet`] structure and all its related data. +use ifaces::{ + rgb21::{self, TokenData}, + rgb25, IssuerWrapper, Rgb20, Rgb21, Rgb25, +}; +use rgb::{ + persistence::StashReadProvider, Allocation, ContractId, GenesisSeal, GraphSeal, OwnedFraction, + TokenIndex, +}; +use schemata::{CollectibleFungibleAsset, NonInflatableAsset, UniqueDigitalAsset}; + use super::*; const TRANSFER_DIR: &str = "transfers"; @@ -226,17 +236,11 @@ impl Wallet { let indexer_url = &self.online_data.as_ref().unwrap().indexer_url; Ok(match &self.online_data.as_ref().unwrap().indexer { #[cfg(feature = "electrum")] - Indexer::Electrum(_) => AnyResolver::Electrum(Box::new( - ElectrumResolver::new(indexer_url).map_err(|e| Error::InvalidIndexer { - details: e.to_string(), - })?, - )), + Indexer::Electrum(_) => AnyResolver::electrum_blocking(indexer_url) + .map_err(|e| Error::InvalidIndexer { details: e })?, #[cfg(feature = "esplora")] - Indexer::Esplora(_) => AnyResolver::Esplora(Box::new( - EsploraResolver::new(indexer_url).map_err(|e| Error::InvalidIndexer { - details: e.to_string(), - })?, - )), + Indexer::Electrum(_) => AnyResolver::esplora_blocking(indexer_url) + .map_err(|e| Error::InvalidIndexer { details: e })?, }) } @@ -482,12 +486,15 @@ impl Wallet { contract_id: ContractId, runtime: &RgbRuntime, ) -> Result { - let genesis = runtime.genesis(contract_id)?; + let genesis = runtime + .as_stash_provider() + .genesis(contract_id) + .expect("genesis contractid"); let schema_id = genesis.schema_id.to_string(); Ok(match &schema_id[..] { - SCHEMA_ID_NIA => AssetIface::RGB20, - SCHEMA_ID_UDA => AssetIface::RGB21, - SCHEMA_ID_CFA => AssetIface::RGB25, + SCHEMA_ID_NIA => AssetIface::RGB20Fixed, + SCHEMA_ID_UDA => AssetIface::RGB21Unique, + SCHEMA_ID_CFA => AssetIface::RGB25Base, _ => return Err(Error::UnknownRgbSchema { schema_id }), }) } @@ -1020,11 +1027,7 @@ impl Wallet { }); } - let asset_ids: Vec = runtime - .contract_ids()? - .iter() - .map(|id| id.to_string()) - .collect(); + let asset_ids: Vec = runtime.contracts()?.map(|c| c.id.to_string()).collect(); let db_asset_ids: Vec = self.database.get_asset_ids()?; if !db_asset_ids.iter().all(|i| asset_ids.contains(i)) { return Err(Error::Inconsistency { @@ -1267,7 +1270,7 @@ impl Wallet { Ok(( Attachment { ty: media_type, - digest, + digest: digest.into(), }, Media { mime, file_path }, )) @@ -1286,8 +1289,8 @@ impl Wallet { &self, text: RicardianContract, media: Option, - ) -> AssetTerms { - AssetTerms { text, media } + ) -> ContractTerms { + ContractTerms { text, media } } /// Issue a new RGB NIA asset with the provided `ticker`, `name`, `precision` and `amounts`, @@ -1352,19 +1355,22 @@ impl Wallet { let mut runtime = self.rgb_runtime()?; let mut builder = ContractBuilder::with( - Rgb20::iface(), + self.issuer.clone(), + Rgb20::iface(NonInflatableAsset::FEATURES), NonInflatableAsset::schema(), NonInflatableAsset::issue_impl(), - self.testnet(), + NonInflatableAsset::types(), + NonInflatableAsset::scripts(), ) - .unwrap() .add_global_state("spec", spec.clone()) .expect("invalid spec") .add_global_state("terms", terms) .expect("invalid terms") .add_global_state("issuedSupply", Amount::from(settled)) .expect("invalid issuedSupply"); - + if !self.testnet() { + builder = builder.set_mainnet(); + } let mut issue_utxos: HashMap = HashMap::new(); for amount in &amounts { let exclude_outpoints: Vec = @@ -1383,11 +1389,8 @@ impl Wallet { } debug!(self.logger, "Issuing on UTXOs: {issue_utxos:?}"); - let contract = builder.issue_contract().expect("failure issuing contract"); - let asset_id = contract.contract_id().to_string(); - let validated_contract = contract - .validate(&mut self.blockchain_resolver()?, self.testnet()) - .expect("internal error: failed validating self-issued contract"); + let validated_contract = builder.issue_contract().expect("failure issuing contract"); + let asset_id = validated_contract.contract_id().to_string(); runtime .import_contract(validated_contract, &mut self.blockchain_resolver()?) .expect("failure importing issued contract"); @@ -1513,7 +1516,7 @@ impl Wallet { let created_at = now().unix_timestamp(); let text = RicardianContract::default(); - let terms = AssetTerms { text, media: None }; + let terms = ContractTerms { text, media: None }; let details_obj = if let Some(details) = &details { Some(self.check_details(details.clone())?) @@ -1570,24 +1573,27 @@ impl Wallet { }; let mut runtime = self.rgb_runtime()?; - let builder = - ContractBuilder::with(Rgb21::iface(), uda_schema(), uda_rgb21(), self.testnet()) - .unwrap() - .add_global_state("spec", spec) - .expect("invalid spec") - .add_global_state("terms", terms) - .expect("invalid terms") - .add_data("assetOwner", BuilderSeal::from(seal), allocation) - .expect("invalid global state data") - .add_global_state("tokens", token_data) - .expect("invalid tokens"); - - let contract = builder.issue_contract().expect("failure issuing contract"); - let asset_id = contract.contract_id().to_string(); - let validated_contract = contract - .clone() - .validate(&mut self.blockchain_resolver()?, self.testnet()) - .expect("internal error: failed validating self-issued contract"); + let mut builder = ContractBuilder::with( + self.issuer.clone(), + Rgb21::iface(UniqueDigitalAsset::FEATURES), + UniqueDigitalAsset::schema(), + UniqueDigitalAsset::issue_impl(), + UniqueDigitalAsset::types(), + UniqueDigitalAsset::scripts(), + ) + .add_global_state("spec", spec) + .expect("invalid spec") + .add_global_state("terms", terms) + .expect("invalid terms") + .add_data("assetOwner", BuilderSeal::from(seal), allocation) + .expect("invalid global state data") + .add_global_state("tokens", token_data) + .expect("invalid tokens"); + if !self.testnet() { + builder = builder.set_mainnet(); + } + let validated_contract = builder.issue_contract().expect("failure issuing contract"); + let asset_id = validated_contract.contract_id().to_string(); runtime .import_contract(validated_contract, &mut self.blockchain_resolver()?) .expect("failure importing issued contract"); @@ -1724,7 +1730,7 @@ impl Wallet { } else { None }; - let terms = AssetTerms { + let terms = ContractTerms { text, media: media_data .as_ref() @@ -1734,18 +1740,26 @@ impl Wallet { let name_state = self._check_name(name.clone())?; let mut runtime = self.rgb_runtime()?; - let mut builder = - ContractBuilder::with(Rgb25::iface(), cfa_schema(), cfa_rgb25(), self.testnet()) - .unwrap() - .add_global_state("name", name_state) - .expect("invalid name") - .add_global_state("precision", precision_state) - .expect("invalid precision") - .add_global_state("terms", terms) - .expect("invalid terms") - .add_global_state("issuedSupply", Amount::from(settled)) - .expect("invalid issuedSupply"); + let mut builder = ContractBuilder::with( + self.issuer.clone(), + Rgb25::iface(CollectibleFungibleAsset::FEATURES), + CollectibleFungibleAsset::schema(), + CollectibleFungibleAsset::issue_impl(), + CollectibleFungibleAsset::types(), + CollectibleFungibleAsset::scripts(), + ) + .add_global_state("name", name_state) + .expect("invalid name") + .add_global_state("precision", precision_state) + .expect("invalid precision") + .add_global_state("terms", terms) + .expect("invalid terms") + .add_global_state("issuedSupply", Amount::from(settled)) + .expect("invalid issuedSupply"); + if !self.testnet() { + builder = builder.set_mainnet(); + } if let Some(details) = &details { builder = builder .add_global_state("details", self.check_details(details.clone())?) @@ -1770,11 +1784,8 @@ impl Wallet { } debug!(self.logger, "Issuing on UTXOs: {issue_utxos:?}"); - let contract = builder.issue_contract().expect("failure issuing contract"); - let asset_id = contract.contract_id().to_string(); - let validated_contract = contract - .validate(&mut self.blockchain_resolver()?, self.testnet()) - .expect("internal error: failed validating self-issued contract"); + let validated_contract = builder.issue_contract().expect("failure issuing contract"); + let asset_id = validated_contract.contract_id().to_string(); runtime .import_contract(validated_contract, &mut self.blockchain_resolver()?) .expect("failure importing issued contract"); @@ -2047,23 +2058,16 @@ impl Wallet { .validate(&mut self.blockchain_resolver()?, self.testnet()) { Ok(consignment) => consignment, - Err(consignment) => consignment, + Err((_statue, _consignment)) => { + let validity = _statue.validity(); + error!(self.logger, "Consignment has an invalid status: {validity}"); + return self._refuse_consignment( + proxy_url, + recipient_id, + &mut updated_batch_transfer, + ); + } }; - let validation_status = validated_consignment.into_validation_status().unwrap(); - let validity = validation_status.validity(); - debug!(self.logger, "Consignment validity: {:?}", validity); - - if ![ - Validity::Valid, - Validity::UnminedTerminals, - Validity::UnresolvedTransactions, - ] - .contains(&validity) - { - error!(self.logger, "Consignment has an invalid status: {validity}"); - return self._refuse_consignment(proxy_url, recipient_id, &mut updated_batch_transfer); - } - let schema_id = consignment.schema_id().to_string(); let asset_schema = AssetSchema::from_schema_id(schema_id)?; @@ -2082,7 +2086,15 @@ impl Wallet { .validate(&mut self.blockchain_resolver()?, self.testnet()) { Ok(consignment) => consignment, - Err(consignment) => consignment, + Err((_statue, _consignment)) => { + let validity = _statue.validity(); + error!(self.logger, "Consignment has an invalid status: {validity}"); + return self._refuse_consignment( + proxy_url, + recipient_id, + &mut updated_batch_transfer, + ); + } }; runtime .import_contract(minimal_contract_validated, &mut self.blockchain_resolver()?) @@ -2184,9 +2196,12 @@ impl Wallet { if let Some(anchored_bundle) = consignment .bundles .into_iter() - .find(|ab| ab.anchor.witness_id_unchecked().to_string() == format!("bc:{txid}")) + .find(|ab| ab.witness_id().to_string() == format!("bc:{txid}")) { - 'outer: for transition in anchored_bundle.bundle.known_transitions.values() { + 'outer: for transition in anchored_bundle + .bundles() + .flat_map(|x| x.known_transitions.values()) + { for assignment in transition.assignments.values() { for fungible_assignment in assignment.as_fungible() { if let Assign::ConfidentialSeal { seal, state, .. } = fungible_assignment { @@ -2416,13 +2431,18 @@ impl Wallet { } // accept consignment - let consignment = consignment - .validate(&mut self.blockchain_resolver()?, self.testnet()) - .unwrap_or_else(|c| c); + let consignment = + consignment.validate(&mut self.blockchain_resolver()?, self.testnet()); + let consignment = match consignment { + Ok(c) => c, + Err((e, _c)) => { + assert!(!matches!(e.validity(), Validity::Valid)); + return Err(InternalError::Unexpected)?; + } + }; let mut runtime = self.rgb_runtime()?; - let force = false; let validation_status = - runtime.accept_transfer(consignment, &mut self.blockchain_resolver()?, force)?; + runtime.accept_transfer(consignment, &mut self.blockchain_resolver()?)?; let validity = validation_status.validity(); if !matches!(validity, Validity::Valid) { return Err(InternalError::Unexpected)?; @@ -2774,8 +2794,10 @@ impl Wallet { .ok_or(InternalError::Unexpected)?; let mut uda_state = None; - for ((opout, _), state) in - runtime.state_for_outpoints(contract_id, prev_outputs.iter().copied())? + for (opout, state) in runtime + .contract_assignments_for(contract_id, prev_outputs.iter().copied())? + .into_iter() + .flat_map(|(_k, v)| v) { // there can be only a single state when contract is UDA uda_state = Some(state.clone()); @@ -2820,7 +2842,7 @@ impl Wallet { beneficiaries.push(seal); match transfer_info.asset_iface { - AssetIface::RGB20 | AssetIface::RGB25 => { + AssetIface::RGB20Fixed | AssetIface::RGB25Base => { asset_transition_builder = asset_transition_builder .add_fungible_state_raw( assignment_id, @@ -2829,7 +2851,7 @@ impl Wallet { BlindingFactor::random(), )?; } - AssetIface::RGB21 => { + AssetIface::RGB21Unique => { asset_transition_builder = asset_transition_builder .add_owned_state_raw(assignment_id, seal, uda_state.clone().unwrap()) .map_err(Error::from)?; @@ -2858,16 +2880,19 @@ impl Wallet { let mut blank_state = HashMap::>::new(); for output in prev_outputs { - for id in runtime.contracts_by_outputs([output])? { + for id in runtime.contracts_assigning([output])? { contract_inputs.entry(id).or_default().push(output); let cid_str = id.to_string(); if transfer_info_map.contains_key(&cid_str) { continue; } - blank_state - .entry(id) - .or_default() - .extend(runtime.state_for_outpoints(id, [output])?); + blank_state.entry(id).or_default().extend( + runtime + //HashMap>; + .contract_assignments_for(id, [output])? + .into_iter() + .flat_map(|(k, v)| v.into_iter().map(move |(x, y)| ((x, k), y))), + ); } } @@ -2937,7 +2962,7 @@ impl Wallet { let witness_txid = rgb_psbt.txid(); - runtime.consume(fascia)?; + runtime.consume_fascia(fascia)?; for (asset_id, _transfer_info) in transfer_info_map { let asset_transfer_dir = transfer_dir.join(&asset_id); @@ -2960,22 +2985,22 @@ impl Wallet { BuilderSeal::Concealed(seal) => beneficiaries_secret_seals.push(seal), }; } - let mut transfer = runtime.transfer( + let transfer = runtime.transfer( contract_id, beneficiaries_outputs, beneficiaries_secret_seals, )?; - let mut terminals = transfer.terminals.to_inner(); - for (bundle_id, terminal) in terminals.iter_mut() { - let Some(ab) = transfer.anchored_bundle(*bundle_id) else { - continue; - }; - if ab.anchor.witness_id_unchecked() == WitnessId::Bitcoin(witness_txid) { - terminal.witness_tx = Some(XChain::Bitcoin(rgb_psbt.to_unsigned_tx().into())); - } - } - transfer.terminals = Confined::from_collection_unsafe(terminals); + // let mut terminals = transfer.terminals.to_inner(); + // for (bundle_id, terminal) in terminals.iter_mut() { + // let Some(ab) = transfer.bundles.b(*bundle_id) else { + // continue; + // }; + // if ab.anchor.witness_id_unchecked() == WitnessId::Bitcoin(witness_txid) { + // terminal.witness_tx = Some(XChain::Bitcoin(rgb_psbt.to_unsigned_tx().into())); + // } + // } + // transfer.terminals = Confined::from_collection_unsafe(terminals); transfer.save_file(&consignment_path)?; } diff --git a/src/wallet/test/blind_receive.rs b/src/wallet/test/blind_receive.rs index 8f45c1f..4597d5d 100644 --- a/src/wallet/test/blind_receive.rs +++ b/src/wallet/test/blind_receive.rs @@ -84,7 +84,7 @@ fn success() { let receive_data = result.unwrap(); let invoice = Invoice::new(receive_data.invoice).unwrap(); let invoice_data = invoice.invoice_data(); - assert_eq!(invoice_data.asset_iface, Some(AssetIface::RGB20)); + assert_eq!(invoice_data.asset_iface, Some(AssetIface::RGB20Fixed)); // asset id is set (UDA) let asset = test_issue_asset_uda(&wallet, &online, None, None, vec![]); @@ -100,7 +100,7 @@ fn success() { let receive_data = result.unwrap(); let invoice = Invoice::new(receive_data.invoice).unwrap(); let invoice_data = invoice.invoice_data(); - assert_eq!(invoice_data.asset_iface, Some(AssetIface::RGB21)); + assert_eq!(invoice_data.asset_iface, Some(AssetIface::RGB21Unique)); // asset id is set (CFA) let asset = test_issue_asset_cfa(&wallet, &online, None, None); @@ -116,7 +116,7 @@ fn success() { let receive_data = result.unwrap(); let invoice = Invoice::new(receive_data.invoice).unwrap(); let invoice_data = invoice.invoice_data(); - assert_eq!(invoice_data.asset_iface, Some(AssetIface::RGB25)); + assert_eq!(invoice_data.asset_iface, Some(AssetIface::RGB25Base)); // all set let now_timestamp = now().unix_timestamp(); @@ -137,7 +137,7 @@ fn success() { let approx_expiry = now_timestamp + expiration as i64; assert_eq!(invoice.invoice_string(), invoice_from_data.invoice_string()); assert_eq!(invoice_data.recipient_id, receive_data.recipient_id); - assert_eq!(invoice_data.asset_iface, Some(AssetIface::RGB25)); + assert_eq!(invoice_data.asset_iface, Some(AssetIface::RGB25Base)); assert_eq!(invoice_data.asset_id, Some(asset_id)); assert_eq!(invoice_data.amount, Some(amount)); assert_eq!(invoice_data.network, BitcoinNetwork::Regtest); diff --git a/src/wallet/test/get_asset_metadata.rs b/src/wallet/test/get_asset_metadata.rs index 4612a2d..7b39e9f 100644 --- a/src/wallet/test/get_asset_metadata.rs +++ b/src/wallet/test/get_asset_metadata.rs @@ -34,7 +34,7 @@ fn success() { bak_info_before.last_operation_timestamp ); - assert_eq!(nia_metadata.asset_iface, AssetIface::RGB20); + assert_eq!(nia_metadata.asset_iface, AssetIface::RGB20Fixed); assert_eq!(nia_metadata.asset_schema, AssetSchema::Nia); assert_eq!(nia_metadata.issued_supply, AMOUNT * 2); assert_eq!(nia_metadata.name, NAME.to_string()); @@ -58,7 +58,7 @@ fn success() { let timestamp = issuance.created_at; let uda_metadata = test_get_asset_metadata(&wallet, &asset_uda.asset_id); - assert_eq!(uda_metadata.asset_iface, AssetIface::RGB21); + assert_eq!(uda_metadata.asset_iface, AssetIface::RGB21Unique); assert_eq!(uda_metadata.asset_schema, AssetSchema::Uda); assert_eq!(uda_metadata.issued_supply, 1); assert_eq!(uda_metadata.name, NAME.to_string()); @@ -94,7 +94,7 @@ fn success() { let timestamp = issuance.created_at; let cfa_metadata = test_get_asset_metadata(&wallet, &asset_cfa.asset_id); - assert_eq!(cfa_metadata.asset_iface, AssetIface::RGB25); + assert_eq!(cfa_metadata.asset_iface, AssetIface::RGB25Base); assert_eq!(cfa_metadata.asset_schema, AssetSchema::Cfa); assert_eq!(cfa_metadata.issued_supply, AMOUNT * 2); assert_eq!(cfa_metadata.name, NAME.to_string()); diff --git a/src/wallet/test/mod.rs b/src/wallet/test/mod.rs index d793510..b62b936 100644 --- a/src/wallet/test/mod.rs +++ b/src/wallet/test/mod.rs @@ -6,12 +6,12 @@ use std::{ }; use bdk::descriptor::Descriptor; +use ifaces::rgb21::TokenData; use lazy_static::lazy_static; use once_cell::sync::Lazy; use regex::RegexSet; -use rgbstd::{ - interface::rgb21::EmbeddedMedia as RgbEmbeddedMedia, stl::ProofOfReserves as RgbProofOfReserves, -}; +use rgbstd::stl::ProofOfReserves as RgbProofOfReserves; +//interface::rgb21::EmbeddedMedia as RgbEmbeddedMedia, use serial_test::{parallel, serial}; use time::OffsetDateTime; @@ -150,7 +150,7 @@ pub fn mock_asset_terms( wallet: &Wallet, text: RicardianContract, media: Option, -) -> AssetTerms { +) -> ContractTerms { let mut mock_reqs = MOCK_CONTRACT_DATA.lock().unwrap(); if mock_reqs.is_empty() { wallet.new_asset_terms(text, media) @@ -165,6 +165,7 @@ lazy_static! { static ref MOCK_TOKEN_DATA: Mutex> = Mutex::new(vec![]); } +use rgb::TokenIndex; #[cfg(any(feature = "electrum", feature = "esplora"))] pub fn mock_token_data( wallet: &Wallet, diff --git a/src/wallet/test/refresh.rs b/src/wallet/test/refresh.rs index 5ef55eb..2bd7c34 100644 --- a/src/wallet/test/refresh.rs +++ b/src/wallet/test/refresh.rs @@ -326,7 +326,7 @@ fn nia_with_media() { let media_type = MediaType::with(media_ty); let attachment = Attachment { ty: media_type, - digest, + digest: digest.into(), }; MOCK_CONTRACT_DATA.lock().unwrap().push(attachment.clone()); let asset = test_issue_asset_nia(&wallet_1, &online_1, None); @@ -482,6 +482,8 @@ fn nia_with_details() { #[test] #[serial] fn uda_with_preview_and_reserves() { + use ifaces::rgb21::EmbeddedMedia; + initialize(); let amount: u64 = 1; @@ -492,7 +494,7 @@ fn uda_with_preview_and_reserves() { let data = vec![1u8, 3u8, 9u8]; let preview_ty = "text/plain"; - let preview = RgbEmbeddedMedia { + let preview = EmbeddedMedia { ty: MediaType::with(preview_ty), data: Confined::try_from(data.clone()).unwrap(), }; @@ -577,7 +579,7 @@ fn uda_with_preview_and_reserves() { assert_eq!(transfer_data.status, TransferStatus::Settled); let uda_metadata = test_get_asset_metadata(&wallet_3, &asset.asset_id); - assert_eq!(uda_metadata.asset_iface, AssetIface::RGB21); + assert_eq!(uda_metadata.asset_iface, AssetIface::RGB21Unique); assert_eq!(uda_metadata.asset_schema, AssetSchema::Uda); assert_eq!(uda_metadata.issued_supply, 1); assert_eq!(uda_metadata.name, NAME.to_string()); diff --git a/src/wallet/test/save_new_asset.rs b/src/wallet/test/save_new_asset.rs index 6151625..0564b03 100644 --- a/src/wallet/test/save_new_asset.rs +++ b/src/wallet/test/save_new_asset.rs @@ -101,6 +101,8 @@ fn success() { #[test] #[parallel] fn fail() { + use rgb::ContractId; + initialize(); let (wallet, online) = get_funded_wallet!(); diff --git a/src/wallet/test/utils/api.rs b/src/wallet/test/utils/api.rs index 1d6706b..b05a515 100644 --- a/src/wallet/test/utils/api.rs +++ b/src/wallet/test/utils/api.rs @@ -425,7 +425,7 @@ pub(crate) fn test_save_new_asset( rcv_wallet.testnet(), ) { Ok(consignment) => consignment, - Err(consignment) => consignment, + Err(_consignment) => unreachable!(), }; let mut runtime = rcv_wallet.rgb_runtime().unwrap(); @@ -437,12 +437,13 @@ pub(crate) fn test_save_new_asset( .unwrap(); let schema_id = minimal_contract_validated.schema_id().to_string(); let asset_schema = AssetSchema::from_schema_id(schema_id).unwrap(); + rcv_wallet .save_new_asset( &mut runtime, &asset_schema, minimal_contract_validated.contract_id(), - Some(minimal_contract_validated), + Some(minimal_contract_validated.into_consignment()), ) .unwrap(); } diff --git a/src/wallet/test/utils/helpers.rs b/src/wallet/test/utils/helpers.rs index 4c4bc9c..789563b 100644 --- a/src/wallet/test/utils/helpers.rs +++ b/src/wallet/test/utils/helpers.rs @@ -201,7 +201,7 @@ pub(crate) fn check_test_wallet_data( ); // asset metadata let metadata = test_get_asset_metadata(wallet, &asset.asset_id); - assert_eq!(metadata.asset_iface, AssetIface::RGB20); + assert_eq!(metadata.asset_iface, AssetIface::RGB20Fixed); assert_eq!(metadata.issued_supply, issued_supply); assert_eq!(metadata.name, asset.name); assert_eq!(metadata.precision, asset.precision); diff --git a/src/wallet/test/witness_receive.rs b/src/wallet/test/witness_receive.rs index 396e7f2..9650ccd 100644 --- a/src/wallet/test/witness_receive.rs +++ b/src/wallet/test/witness_receive.rs @@ -101,7 +101,7 @@ fn success() { let approx_expiry = now_timestamp + expiration as i64; assert_eq!(invoice.invoice_string(), invoice_from_data.invoice_string()); assert_eq!(invoice_data.recipient_id, receive_data.recipient_id); - assert_eq!(invoice_data.asset_iface, Some(AssetIface::RGB25)); + assert_eq!(invoice_data.asset_iface, Some(AssetIface::RGB25Base)); assert_eq!(invoice_data.asset_id, Some(asset_id)); assert_eq!(invoice_data.amount, Some(amount)); assert_eq!(invoice_data.network, BitcoinNetwork::Regtest);