diff --git a/.gitignore b/.gitignore index 55993b2..653cfce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Generated by Cargo # will have compiled files and executables /target +/debug # These are backup files generated by rustfmt **/*.rs.bk diff --git a/Cargo.lock b/Cargo.lock index 2ecc34b..25deeda 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -29,12 +29,12 @@ dependencies = [ [[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=v0.11#d18ea84836a8a96f3dfe61c99b94f2eab1417819" dependencies = [ "amplify", "ascii-armor", "baid58", + "blake3", "getrandom", "half", "paste", @@ -70,7 +70,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72e23f5ede99065fa6957a633498d2728d51016d61dae23b69c866112b7c61ee" dependencies = [ "amplify_num", - "bitflags 2.4.2", + "bitflags 2.5.0", "wasm-bindgen", ] @@ -206,15 +206,15 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" dependencies = [ "addr2line", "cc", @@ -294,15 +294,15 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "blake3" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0231f06152bf547e9c2b5194f247cd97aacf6dcd8b15d8e5ec0663f64580da87" +checksum = "30cca6d3674597c30ddf2c587bf8d9d65c9a84d2326d941cc79c9842dfe0ef52" dependencies = [ "arrayref", "arrayvec", @@ -323,13 +323,12 @@ dependencies = [ [[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=v0.11#27a4b711613f88276b5b7da0c2a3b27164b431e8" dependencies = [ "amplify", "chrono", "commit_verify", - "secp256k1", + "secp256k1 0.29.0", "serde", "strict_encoding", "strict_types", @@ -338,8 +337,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=v0.11#27a4b711613f88276b5b7da0c2a3b27164b431e8" dependencies = [ "amplify", "bp-consensus", @@ -357,14 +355,13 @@ 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=v0.11#27a4b711613f88276b5b7da0c2a3b27164b431e8" dependencies = [ "amplify", "base85", "bp-consensus", "commit_verify", - "secp256k1", + "secp256k1 0.29.0", "serde", "strict_encoding", ] @@ -372,15 +369,14 @@ 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=v0.11#7dd16a84edc8c308856155d990d9df4311c35bfc" dependencies = [ "amplify", "bitcoin_hashes", "bp-consensus", "bp-invoice", "commit_verify", - "indexmap 2.2.5", + "indexmap 2.2.6", "serde", ] @@ -422,8 +418,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=v0.11#7dd16a84edc8c308856155d990d9df4311c35bfc" dependencies = [ "amplify", "bech32", @@ -435,8 +430,7 @@ 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=v0.11#27a4b711613f88276b5b7da0c2a3b27164b431e8" dependencies = [ "amplify", "baid58", @@ -452,8 +446,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=v0.11#7dd16a84edc8c308856155d990d9df4311c35bfc" dependencies = [ "amplify", "bp-consensus", @@ -491,8 +484,7 @@ 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=v0.11#5d07f271605395a0d7e4d10c87283fbcb4203e1b" dependencies = [ "amplify", "bp-electrum", @@ -510,9 +502,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.4" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "byteorder" @@ -522,15 +514,15 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "cc" -version = "1.0.90" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" [[package]] name = "cfg-if" @@ -546,14 +538,14 @@ checksum = "45565fc9416b9896014f5732ac776f810ee53a66730c17e4020c3ec064a8f88f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.60", ] [[package]] name = "chrono" -version = "0.4.35" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", @@ -561,14 +553,14 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] name = "clap" -version = "4.5.2" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b230ab84b0ffdf890d5a10abdbc8b83ae1c4918275daea1ab8801f71536b2651" +checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" dependencies = [ "clap_builder", "clap_derive", @@ -583,19 +575,19 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.0", + "strsim 0.11.1", ] [[package]] name = "clap_derive" -version = "4.5.0" +version = "4.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" +checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.60", ] [[package]] @@ -613,8 +605,7 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[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=v0.11#d32e1af11a599643b235706efd51d0097347f082" dependencies = [ "amplify", "amplify_syn", @@ -626,8 +617,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=v0.11#d32e1af11a599643b235706efd51d0097347f082" dependencies = [ "amplify", "commit_encoding_derive", @@ -727,7 +717,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.52", + "syn 2.0.60", ] [[package]] @@ -738,7 +728,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core", "quote", - "syn 2.0.52", + "syn 2.0.60", ] [[package]] @@ -754,12 +744,11 @@ 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=v0.11#7dd16a84edc8c308856155d990d9df4311c35bfc" dependencies = [ "amplify", "bp-derive", - "indexmap 2.2.5", + "indexmap 2.2.6", "serde", ] @@ -796,15 +785,15 @@ dependencies = [ [[package]] name = "either" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" [[package]] name = "encoding_rs" -version = "0.8.33" +version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" dependencies = [ "cfg-if", ] @@ -840,9 +829,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" [[package]] name = "flate2" @@ -944,9 +933,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" dependencies = [ "cfg-if", "js-sys", @@ -963,9 +952,9 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "h2" -version = "0.3.24" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", @@ -973,7 +962,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 2.2.5", + "indexmap 2.2.6", "slab", "tokio", "tokio-util", @@ -1007,6 +996,12 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" version = "0.3.9" @@ -1154,9 +1149,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.5" +version = "2.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -1182,9 +1177,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" @@ -1209,13 +1204,12 @@ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libredox" -version = "0.0.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "libc", - "redox_syscall", ] [[package]] @@ -1232,9 +1226,9 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" -version = "2.7.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "mime" @@ -1264,13 +1258,9 @@ dependencies = [ [[package]] name = "mnemonic" -version = "1.0.1" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29fae0e4c0b155d3b019a7cbc27abe4a90e15c06814d27889ce9f5f44e2faf77" -dependencies = [ - "byteorder", - "lazy_static", -] +checksum = "f2b8f3a258db515d5e91a904ce4ae3f73e091149b90cadbdb93d210bee07f63b" [[package]] name = "native-tls" @@ -1326,7 +1316,7 @@ version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "cfg-if", "foreign-types", "libc", @@ -1343,7 +1333,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.60", ] [[package]] @@ -1354,9 +1344,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.101" +version = "0.9.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" dependencies = [ "cc", "libc", @@ -1384,9 +1374,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -1414,9 +1404,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" dependencies = [ "unicode-ident", ] @@ -1424,8 +1414,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=v0.11#7dd16a84edc8c308856155d990d9df4311c35bfc" dependencies = [ "amplify", "base64", @@ -1434,16 +1423,16 @@ dependencies = [ "chrono", "commit_verify", "descriptors", - "indexmap 2.2.5", + "indexmap 2.2.6", "serde", "strict_encoding", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -1478,20 +1467,11 @@ dependencies = [ "getrandom", ] -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_users" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" dependencies = [ "getrandom", "libredox", @@ -1500,9 +1480,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.3" +version = "1.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" dependencies = [ "aho-corasick", "memchr", @@ -1523,15 +1503,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "reqwest" -version = "0.11.25" +version = "0.11.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eea5a9eb898d3783f17c6407670e3592fd174cb81a10e51d4c37f49450b9946" +checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" dependencies = [ "base64", "bytes", @@ -1571,8 +1551,7 @@ 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=v0.11#551d6d6fc3c7bf10119b20145ddae852fba6446d" dependencies = [ "aluvm", "amplify", @@ -1594,15 +1573,14 @@ dependencies = [ [[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/RGB-WG/rgb-std?branch=v0.11#58fbbc417835a829f5f9325bfed35e5a18310d13" dependencies = [ "amplify", "baid58", "bp-core", "bp-invoice", "fluent-uri", - "indexmap 2.2.5", + "indexmap 2.2.6", "percent-encoding", "rgb-core", "serde", @@ -1610,15 +1588,6 @@ dependencies = [ "strict_types", ] -[[package]] -name = "rgb-persist-fs" -version = "0.11.1" -dependencies = [ - "amplify", - "rgb-std", - "strict_encoding", -] - [[package]] name = "rgb-psbt" version = "0.11.0-beta.5" @@ -1651,9 +1620,8 @@ dependencies = [ "chrono", "commit_verify", "descriptors", - "indexmap 2.2.5", + "indexmap 2.2.6", "log", - "rgb-persist-fs", "rgb-psbt", "rgb-std", "serde", @@ -1665,9 +1633,9 @@ 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/RGB-WG/rgb-std?branch=v0.11#58fbbc417835a829f5f9325bfed35e5a18310d13" dependencies = [ + "aluvm", "amplify", "ascii-armor", "baid58", @@ -1676,7 +1644,7 @@ dependencies = [ "chrono", "commit_verify", "getrandom", - "indexmap 2.2.5", + "indexmap 2.2.6", "rand", "rgb-core", "rgb-invoice", @@ -1743,11 +1711,11 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustix" -version = "0.38.31" +version = "0.38.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" +checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys", @@ -1768,9 +1736,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e87c9956bd9807afa1f77e0f7594af32566e830e088a5576d27c5b6f30f49d41" +checksum = "99008d7ad0bbbea527ec27bddbc0e432c5b87d8175178cee68d2eec9c4a1813c" dependencies = [ "log", "ring", @@ -1791,9 +1759,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.3.1" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ede67b28608b4c60685c7d54122d4400d90f62b40caee7700e700380a390fa8" +checksum = "ecd36cc4259e3e4514335c4a138c6b43171a8d61d8f5c9348f9fc7529416f247" [[package]] name = "rustls-webpki" @@ -1854,7 +1822,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10" dependencies = [ "rand", - "secp256k1-sys", + "secp256k1-sys 0.9.2", + "serde", +] + +[[package]] +name = "secp256k1" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e0cc0f1cf93f4969faf3ea1c7d8a9faed25918d96affa959720823dfe86d4f3" +dependencies = [ + "rand", + "secp256k1-sys 0.10.0", "serde", ] @@ -1867,6 +1846,15 @@ dependencies = [ "cc", ] +[[package]] +name = "secp256k1-sys" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1433bd67156263443f14d603720b082dd3121779323fce20cba2aa07b874bc1b" +dependencies = [ + "cc", +] + [[package]] name = "secp256k1-zkp" version = "0.10.1" @@ -1875,7 +1863,7 @@ checksum = "c4e48ef9c98bfbcb98bd15693ffa19676cb3e29426b75eda8b73c05cdd7959f8" dependencies = [ "bitcoin-private", "rand", - "secp256k1", + "secp256k1 0.28.2", "secp256k1-zkp-sys", "serde", ] @@ -1887,14 +1875,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4ead52f43074bae2ddbd1e0e66e6b170135e76117f5ea9916f33d7bd0b36e29" dependencies = [ "cc", - "secp256k1-sys", + "secp256k1-sys 0.9.2", ] [[package]] name = "security-framework" -version = "2.9.2" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" dependencies = [ "bitflags 1.3.2", "core-foundation", @@ -1905,9 +1893,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "41f3cc463c0ef97e11c3461a9d3787412d30e8e7eb907c79180c4a57bf7c04ef" dependencies = [ "core-foundation-sys", "libc", @@ -1915,29 +1903,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.197" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.60", ] [[package]] name = "serde_json" -version = "1.0.114" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" dependencies = [ "itoa", "ryu", @@ -1977,15 +1965,15 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.6.1" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15d167997bd841ec232f5b2b8e0e26606df2e7caa4c31b95ea9ca52b200bd270" +checksum = "ee80b0e361bbf88fd2f6e242ccd19cfda072cb0faa6ae694ecee08199938569a" dependencies = [ "base64", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.2.5", + "indexmap 2.2.6", "serde", "serde_derive", "serde_json", @@ -1995,23 +1983,23 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.6.1" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "865f9743393e638991566a8b7a479043c2c8da94a33e0a31f18214c9cae0a64d" +checksum = "6561dc161a9224638a31d876ccdfefbc1df91d3f3a8342eddb35f055d48c7655" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.60", ] [[package]] name = "serde_yaml" -version = "0.9.32" +version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd075d994154d4a774f95b51fb96bdc2832b0ea48425c92546073816cda1f2f" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.2.6", "itoa", "ryu", "serde", @@ -2041,8 +2029,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=v0.11#d32e1af11a599643b235706efd51d0097347f082" dependencies = [ "amplify_derive", ] @@ -2085,9 +2072,9 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "strict_encoding" -version = "2.7.0-beta.1" +version = "2.7.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12eaa6985afa31deacc86cdc4935a36960ae09131a1f4e1db430127ebc4f05d" +checksum = "9c463f8ea993e323740d78544473e791adb91ac659f5bf2c1a59db64a34f99fc" dependencies = [ "amplify", "half", @@ -2097,12 +2084,12 @@ dependencies = [ [[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", + "heck 0.4.1", "proc-macro2", "quote", "syn 1.0.109", @@ -2110,15 +2097,15 @@ dependencies = [ [[package]] name = "strict_types" -version = "2.7.0-beta.2" +version = "2.7.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78c32716de4b99b0e8fb0c114e99b6929613e8d7302999c6b8c77251783923ad" +checksum = "152bd04284e9093f23a911d0d89b7dd950a461af1ed5e243f6215fbcd45e9445" dependencies = [ "amplify", "ascii-armor", "baid58", "half", - "indexmap 2.2.5", + "indexmap 2.2.6", "serde", "serde_json", "serde_yaml", @@ -2146,9 +2133,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "strsim" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "subtle" @@ -2169,9 +2156,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.52" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", @@ -2186,20 +2173,20 @@ checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" [[package]] name = "system-configuration" -version = "0.6.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bc6ee10a9b4fcf576e9b0819d95ec16f4d2c02d39fd83ac1c8789785c4a42" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ - "bitflags 2.4.2", + "bitflags 1.3.2", "core-foundation", "system-configuration-sys", ] [[package]] name = "system-configuration-sys" -version = "0.6.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" dependencies = [ "core-foundation-sys", "libc", @@ -2228,29 +2215,29 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.57" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.60", ] [[package]] name = "time" -version = "0.3.34" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", @@ -2269,9 +2256,9 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ "num-conv", "time-core", @@ -2294,9 +2281,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.36.0" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" dependencies = [ "backtrace", "bytes", @@ -2345,9 +2332,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.11" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af06656561d28735e9c1cd63dfd57132c8155426aa6af24f36a00a351f88c48e" +checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" dependencies = [ "serde", "serde_spanned", @@ -2366,11 +2353,11 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.7" +version = "0.22.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18769cd1cec395d70860ceb4d932812a0b4d06b1a4bb336745a4d21b9496e992" +checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4" dependencies = [ - "indexmap 2.2.5", + "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", @@ -2437,9 +2424,9 @@ dependencies = [ [[package]] name = "unsafe-libyaml" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab4c90930b95a82d00dc9e9ac071b4991924390d46cbd0dfe566148667605e4b" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" [[package]] name = "untrusted" @@ -2457,7 +2444,7 @@ dependencies = [ "flate2", "log", "once_cell", - "rustls 0.22.2", + "rustls 0.22.3", "rustls-pki-types", "rustls-webpki 0.102.2", "serde", @@ -2542,7 +2529,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.60", "wasm-bindgen-shared", ] @@ -2576,7 +2563,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.60", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2609,7 +2596,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.60", ] [[package]] @@ -2674,7 +2661,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -2692,7 +2679,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.4", + "windows-targets 0.52.5", ] [[package]] @@ -2712,17 +2699,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.4", - "windows_aarch64_msvc 0.52.4", - "windows_i686_gnu 0.52.4", - "windows_i686_msvc 0.52.4", - "windows_x86_64_gnu 0.52.4", - "windows_x86_64_gnullvm 0.52.4", - "windows_x86_64_msvc 0.52.4", + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", ] [[package]] @@ -2733,9 +2721,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" @@ -2745,9 +2733,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" @@ -2757,9 +2745,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" @@ -2769,9 +2763,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" @@ -2781,9 +2775,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" @@ -2793,9 +2787,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" @@ -2805,15 +2799,15 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.4" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winnow" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8" +checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index f7bc07d..ccf6c2d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,12 +2,10 @@ members = [ "psbt", "cli", - "fs", "." ] default-members = [ "psbt", - "fs", "." ] @@ -26,8 +24,8 @@ license = "Apache-2.0" amplify = "4.6.0" baid58 = "0.4.4" commit_verify = "0.11.0-beta.5" -strict_encoding = "2.7.0-beta.1" -strict_types = "2.7.0-beta.2" +strict_encoding = "2.7.0-beta.3" +strict_types = "2.7.0-beta.3" bp-core = "0.11.0-beta.5" bp-seals = "0.11.0-beta.5" bp-std = "0.11.0-beta.5" @@ -77,7 +75,6 @@ bp-esplora = { workspace = true, optional = true } descriptors = { workspace = true } rgb-std = { workspace = true } rgb-psbt = { workspace = true } -rgb-persist-fs = { version = "0.11.1", path = "fs" } indexmap = { workspace = true } chrono = { workspace = true } serde_crate = { workspace = true, optional = true } @@ -94,3 +91,20 @@ serde = ["serde_crate", "serde_with", "serde_yaml", "bp-std/serde", "bp-wallet/s [package.metadata.docs.rs] features = ["all"] + +[patch.crates-io] +commit_verify = { git = "https://github.com/LNP-BP/client_side_validation", branch = "v0.11" } +single_use_seals = { git = "https://github.com/LNP-BP/client_side_validation", branch = "v0.11" } +bp-consensus = { git = "https://github.com/BP-WG/bp-core", branch = "v0.11" } +bp-dbc = { git = "https://github.com/BP-WG/bp-core", branch = "v0.11" } +bp-seals = { git = "https://github.com/BP-WG/bp-core", branch = "v0.11" } +bp-core = { git = "https://github.com/BP-WG/bp-core", branch = "v0.11" } +bp-invoice = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" } +bp-std = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" } +bp-wallet = { git = "https://github.com/BP-WG/bp-wallet", branch = "v0.11" } +psbt = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" } +descriptors = { git = "https://github.com/BP-WG/bp-std", branch = "v0.11" } +aluvm = { git = "https://github.com/AluVM/rust-aluvm", branch = "v0.11" } +rgb-core = { git = "https://github.com/RGB-WG/rgb-core", branch = "v0.11" } +rgb-std = { git = "https://github.com/RGB-WG/rgb-std", branch = "v0.11" } +rgb-invoice = { git = "https://github.com/RGB-WG/rgb-std", branch = "v0.11" } diff --git a/cli/src/args.rs b/cli/src/args.rs index eccdc16..edc6a83 100644 --- a/cli/src/args.rs +++ b/cli/src/args.rs @@ -27,6 +27,7 @@ use rgb_rt::{ electrum, esplora_blocking, AnyResolver, AnyResolverError, RgbDescr, Runtime, RuntimeError, TapretKey, }; +use rgbstd::persistence::Stock; use crate::Command; @@ -72,6 +73,14 @@ impl Default for RgbArgs { } impl RgbArgs { + pub fn rgb_stock(&self) -> Result { + eprint!("Loading stock ... "); + let runtime = Runtime::::load_walletless(&self.general.base_dir())?; + eprintln!("success"); + + Ok(runtime) + } + pub fn rgb_runtime(&self, config: &Config) -> Result { let bprt = self.inner.bp_runtime::(config)?; eprint!("Loading stock ... "); diff --git a/cli/src/command.rs b/cli/src/command.rs index 2978a31..7a176c2 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -35,15 +35,14 @@ use rgbstd::containers::{ UniversalFile, }; use rgbstd::contract::{ContractId, GenesisSeal, GraphSeal, StateType}; -use rgbstd::interface::{ - AmountChange, ContractBuilder, ContractSuppl, FilterExclude, IfaceId, SchemaIfaces, -}; +use rgbstd::interface::{AmountChange, ContractSuppl, FilterExclude, IfaceId}; use rgbstd::invoice::{Beneficiary, RgbInvoice, RgbInvoiceBuilder, XChainNet}; -use rgbstd::persistence::{Inventory, Stash}; +use rgbstd::persistence::fs::StoreFs; +use rgbstd::persistence::{SchemaIfaces, StashReadProvider}; use rgbstd::schema::SchemaId; use rgbstd::validation::Validity; use rgbstd::vm::RgbIsa; -use rgbstd::{AssetTag, AssignmentType, BundleId, OutputSeal, XChain, XOutputSeal}; +use rgbstd::{BundleId, OutputSeal, XChain, XOutputSeal}; use seals::txout::CloseMethod; use serde_crate::{Deserialize, Serialize}; use strict_types::encoding::{FieldName, TypeName}; @@ -302,24 +301,24 @@ impl Exec for RgbArgs { const CONF_FILE_NAME: &'static str = "rgb.toml"; fn exec(self, config: Config, _name: &'static str) -> Result<(), RuntimeError> { - if let Some(mut runtime) = match &self.command { + if let Some(stock) = match &self.command { Command::General(cmd) => { self.inner.translate(cmd).exec(config, "rgb")?; None } Command::Debug(DebugCommand::Taprets) => { - let runtime = self.rgb_runtime(&config)?; - for (witness_id, tapret) in runtime.taprets()? { + let stock = self.rgb_stock()?; + for (witness_id, tapret) in stock.as_stash_provider().taprets()? { println!("{witness_id}\t{tapret}"); } None } Command::Schemata => { - let runtime = self.rgb_runtime(&config)?; - for id in runtime.schema_ids()? { - print!("{id} "); - for iimpl in runtime.schema(id)?.iimpls.values() { - let iface = runtime.iface_by_id(iimpl.iface_id)?; + let stock = self.rgb_stock()?; + for schema_iface in stock.schemata()? { + print!("{} ", schema_iface.schema.schema_id()); + for iimpl in schema_iface.iimpls.values() { + let iface = stock.iface(iimpl.iface_id)?; print!("{} ", iface.name); } println!(); @@ -327,15 +326,15 @@ impl Exec for RgbArgs { None } Command::Interfaces => { - let runtime = self.rgb_runtime(&config)?; - for (id, name) in runtime.ifaces()? { + let stock = self.rgb_stock()?; + for (id, name) in stock.ifaces()? { println!("{} {id}", name); } None } Command::Contracts => { - let runtime = self.rgb_runtime(&config)?; - for id in runtime.contract_ids()? { + let stock = self.rgb_stock()?; + for id in stock.contract_ids()? { println!("{id}"); } None @@ -380,71 +379,77 @@ impl Exec for RgbArgs { } Command::Import { armored, file } => { - let mut runtime = self.rgb_runtime(&config)?; - if *armored { - todo!() - } else { - let content = UniversalFile::load_file(file)?; - match content { - UniversalFile::Iface(iface) => { - let id = iface.iface_id(); - let name = iface.name.clone(); - runtime.import_iface(iface)?; - eprintln!("Interface {id} with name {name} imported to the stash"); - } - UniversalFile::Schema(schema) => { - let id = schema.schema_id(); - runtime.import_schema(schema)?; - eprintln!("Schema {id} imported to the stash"); - } - UniversalFile::Impl(iimpl) => { - let iface_id = iimpl.iface_id; - let schema_id = iimpl.schema_id; - let id = iimpl.impl_id(); - runtime.import_iface_impl(iimpl)?; - eprintln!( - "Implementation {id} of interface {iface_id} for schema \ - {schema_id} imported to the stash" - ); + let mut stock = self.rgb_stock()?; + assert!(!armored, "importing armored files is not yet supported"); + // TODO: Support armored files + let content = UniversalFile::load_file(file)?; + match content { + UniversalFile::Kit(kit) => { + let id = kit.kit_id(); + eprintln!("Importing kit {id}"); + let mut iface_names = map![]; + let mut schema_names = map![]; + for iface in &kit.ifaces { + let iface_id = iface.iface_id(); + iface_names.insert(iface_id, &iface.name); + eprintln!("- Interface {} {}", iface.name, iface_id); } - UniversalFile::Contract(contract) => { - let mut resolver = self.resolver()?; - let id = contract.consignment_id(); - let contract = contract - .validate(&mut resolver, self.general.network.is_testnet()) - .map_err(|c| { - c.validation_status().expect("just validated").to_string() - })?; - runtime.import_contract(contract, &mut resolver)?; - eprintln!("Contract {id} imported to the stash"); + for schema in &kit.schemata { + let schema_id = schema.schema_id(); + schema_names.insert(schema_id, &schema.name); + eprintln!("- Schema {} {}", schema.name, schema_id); } - UniversalFile::Transfer(_) => { - return Err(s!("use `validate` and `accept` commands to work with \ - transfer consignments") - .into()); + for iimpl in &kit.iimpls { + let iface = iface_names + .get(&iimpl.iface_id) + .map(|name| name.to_string()) + .unwrap_or_else(|| iimpl.iface_id.to_string()); + let schema = schema_names + .get(&iimpl.schema_id) + .map(|name| name.to_string()) + .unwrap_or_else(|| iimpl.schema_id.to_string()); + eprintln!("- Implementation of {iface} for {schema}",); } - UniversalFile::Suppl(_suppl) => { - todo!() + for lib in &kit.scripts { + eprintln!("- AluVM library {}", lib.id()); } - }; + eprintln!("- Strict types: {} definitions", kit.types.len()); + let kit = kit.validate().map_err(|(status, _)| status.to_string())?; + stock.import_kit(kit)?; + eprintln!("Kit is imported"); + } + UniversalFile::Contract(contract) => { + let mut resolver = self.resolver()?; + let id = contract.consignment_id(); + let contract = contract + .validate(&mut resolver, self.general.network.is_testnet()) + .map_err(|(status, _)| status.to_string())?; + stock.import_contract(contract, &mut resolver)?; + eprintln!("Contract {id} is imported"); + } + UniversalFile::Transfer(_) => { + return Err(s!("use `validate` and `accept` commands to work with \ + transfer consignments") + .into()); + } } - Some(runtime) + Some(stock) } Command::Export { armored: _, contract, file, } => { - let runtime = self.rgb_runtime(&config)?; - let bindle = runtime + let stock = self.rgb_stock()?; + let contract = stock .export_contract(*contract) .map_err(|err| err.to_string())?; if let Some(file) = file { // TODO: handle armored flag - bindle.save_file(file)?; + contract.save_file(file)?; eprintln!("Contract {contract} exported to '{}'", file.display()); } else { - println!("{bindle}"); + println!("{contract}"); } None } @@ -462,8 +467,8 @@ impl Exec for RgbArgs { } => { let runtime = self.rgb_runtime(&config)?; - let iface = runtime.iface_by_name(&tn!(iface.to_owned()))?.clone(); - let contract = runtime.contract_iface_id(*contract_id, iface.iface_id())?; + let iface = runtime.iface(tn!(iface.to_owned()))?.clone(); + let contract = runtime.contract_iface(*contract_id, iface.iface_id())?; println!("Global:"); for global in &contract.iface.global_state { @@ -501,8 +506,11 @@ impl Exec for RgbArgs { } None } - Command::Issue { schema, contract } => { - let mut runtime = self.rgb_runtime(&config)?; + Command::Issue { + schema: schema_id, + contract, + } => { + let mut stock = self.rgb_stock()?; let file = fs::File::open(contract)?; @@ -520,13 +528,13 @@ impl Exec for RgbArgs { let SchemaIfaces { ref schema, ref iimpls, - } = runtime.schema(*schema)?; + } = stock.schema(*schema_id)?; let iface_name = tn!(iface_name.to_owned()); - let iface = runtime - .iface_by_name(&iface_name) + let iface = stock + .iface(iface_name.clone()) .or_else(|_| { let id = IfaceId::from_str(iface_name.as_str())?; - runtime.iface_by_id(id).map_err(RuntimeError::from) + stock.iface(id).map_err(RuntimeError::from) })? .clone(); let iface_id = iface.iface_id(); @@ -535,14 +543,9 @@ impl Exec for RgbArgs { "no known interface implementation for {iface_name}" )) })?; - let types = &schema.types; - let mut builder = ContractBuilder::with( - iface.clone(), - schema.clone(), - iface_impl.clone(), - self.general.network.is_testnet(), - )?; + let mut builder = stock.contract_builder(*schema_id, iface_id)?; + let types = builder.type_system().clone(); if let Some(globals) = code.get("globals") { for (name, val) in globals @@ -630,26 +633,15 @@ impl Exec for RgbArgs { } } - let contract = builder.issue_contract().expect("failure issuing contract"); + let contract = builder.issue_contract()?; let id = contract.contract_id(); let mut resolver = self.resolver()?; - let validated_contract = contract - .validate(&mut resolver, self.general.network.is_testnet()) - .map_err(|consignment| { - RuntimeError::IncompleteContract( - consignment - .into_validation_status() - .expect("just validated"), - ) - })?; - runtime - .import_contract(validated_contract, &mut resolver) - .expect("failure importing issued contract"); + stock.import_contract(contract, &mut resolver)?; eprintln!( "A new contract {id} is issued and added to the stash.\nUse `export` command \ to export the contract." ); - Some(runtime) + Some(stock) } Command::Invoice { address_based, @@ -688,7 +680,7 @@ impl Exec for RgbArgs { outpoint.txid, outpoint.vout, )); - runtime.store_seal_secret(seal)?; + runtime.store_secret_seal(seal)?; Beneficiary::BlindedSeal(*seal.to_secret_seal().as_reduced_unsafe()) } }; @@ -698,7 +690,7 @@ impl Exec for RgbArgs { .set_amount_raw(*value) .finish(); println!("{invoice}"); - Some(runtime) + Some(runtime.into_stock()) } Command::Prepare { v2, @@ -727,7 +719,7 @@ impl Exec for RgbArgs { PsbtVer::V2 => println!("{psbt:#}"), }, } - Some(runtime) + Some(runtime.into_stock()) } Command::Consign { invoice, @@ -743,7 +735,7 @@ impl Exec for RgbArgs { let mut psbt_file = File::create(psbt_name)?; psbt.encode(psbt.version, &mut psbt_file)?; transfer.save_file(out_file)?; - Some(runtime) + Some(runtime.into_stock()) } Command::Transfer { v2, @@ -775,7 +767,7 @@ impl Exec for RgbArgs { PsbtVer::V2 => println!("{psbt:#}"), }, } - Some(runtime) + Some(runtime.into_stock()) } Command::Inspect { file, dir, path } => { #[derive(Clone, Debug)] @@ -784,14 +776,13 @@ impl Exec for RgbArgs { pub struct ConsignmentInspection { version: ContainerVer, transfer: bool, - asset_tags: TinyOrdMap, terminals: SmallOrdMap, supplements: TinyOrdSet, signatures: TinyOrdMap, } let content = UniversalFile::load_file(file)?; - let contract = match content { + let consignment = match content { UniversalFile::Contract(contract) if *dir => Some(contract), UniversalFile::Transfer(transfer) if *dir => Some(transfer.into_contract()), content => { @@ -803,45 +794,37 @@ impl Exec for RgbArgs { None } }; - if let Some(contract) = contract { + if let Some(consignment) = consignment { let mut map = map![ - s!("genesis.yaml") => serde_yaml::to_string(&contract.genesis)?, - s!("schema.yaml") => serde_yaml::to_string(&contract.schema)?, - s!("bundles.yaml") => serde_yaml::to_string(&contract.bundles)?, - s!("extensions.yaml") => serde_yaml::to_string(&contract.extensions)?, - s!("schema-types.sty") => contract.schema.types.to_string(), + s!("genesis.yaml") => serde_yaml::to_string(&consignment.genesis)?, + s!("schema.yaml") => serde_yaml::to_string(&consignment.schema)?, + s!("bundles.yaml") => serde_yaml::to_string(&consignment.bundles)?, + s!("extensions.yaml") => serde_yaml::to_string(&consignment.extensions)?, + s!("types.sty") => consignment.types.to_string(), ]; - for (id, lib) in &contract.schema.script.as_alu_script().libs { + for lib in consignment.scripts { let mut buf = Vec::new(); lib.print_disassemble::(&mut buf)?; - map.insert(format!("{}.aluasm", id.to_baid58().mnemonic()), unsafe { + map.insert(format!("{}.aluasm", lib.id().to_baid58().mnemonic()), unsafe { String::from_utf8_unchecked(buf) }); } - for (_, pair) in contract.ifaces { + for (iface, iimpl) in consignment.ifaces { map.insert( - format!("iface-{}.yaml", pair.iface.name), - serde_yaml::to_string(&pair)?, + format!("iface-{}.yaml", iface.name), + serde_yaml::to_string(&iface)?, ); map.insert( - format!("iface-{}.sty", pair.iface.name), - pair.iface.types.to_string(), + format!("impl-{}.yaml", iface.name), + serde_yaml::to_string(&iimpl)?, ); - for (id, lib) in &pair.iimpl.script.as_alu_script().libs { - let mut buf = Vec::new(); - lib.print_disassemble::(&mut buf)?; - map.insert(format!("{}.aluasm", id.to_baid58().mnemonic()), unsafe { - String::from_utf8_unchecked(buf) - }); - } } let contract = ConsignmentInspection { - version: contract.version, - transfer: contract.transfer, - asset_tags: contract.asset_tags, - terminals: contract.terminals, - supplements: contract.supplements, - signatures: contract.signatures, + version: consignment.version, + transfer: consignment.transfer, + terminals: consignment.terminals, + supplements: consignment.supplements, + signatures: consignment.signatures, }; map.insert(s!("consignment-meta.yaml"), serde_yaml::to_string(&contract)?); let path = path.as_ref().expect("required by clap"); @@ -883,75 +866,77 @@ impl Exec for RgbArgs { None } Command::Dump { root_dir } => { - let runtime = self.rgb_runtime(&config)?; + let stock = self.rgb_stock()?; fs::remove_dir_all(root_dir).ok(); fs::create_dir_all(format!("{root_dir}/stash/schemata"))?; fs::create_dir_all(format!("{root_dir}/stash/ifaces"))?; fs::create_dir_all(format!("{root_dir}/stash/geneses"))?; fs::create_dir_all(format!("{root_dir}/stash/bundles"))?; - fs::create_dir_all(format!("{root_dir}/stash/anchors"))?; + fs::create_dir_all(format!("{root_dir}/stash/witnesses"))?; fs::create_dir_all(format!("{root_dir}/stash/extensions"))?; fs::create_dir_all(format!("{root_dir}/state"))?; fs::create_dir_all(format!("{root_dir}/index"))?; // Stash - for id in runtime.schema_ids()? { + for schema_ifaces in stock.schemata()? { fs::write( - format!("{root_dir}/stash/schemata/{id}.yaml"), - serde_yaml::to_string(runtime.schema(id)?)?, + format!( + "{root_dir}/stash/schemata/{}.yaml", + schema_ifaces.schema.schema_id() + ), + serde_yaml::to_string(&schema_ifaces)?, )?; } - for (id, name) in runtime.ifaces()? { + for (id, name) in stock.ifaces()? { fs::write( format!("{root_dir}/stash/ifaces/{id}.{name}.yaml"), - serde_yaml::to_string(runtime.iface_by_id(id)?)?, + serde_yaml::to_string(stock.iface(id)?)?, )?; } - for id in runtime.contract_ids()? { + for (id, genesis) in stock.as_stash_provider().debug_geneses() { fs::write( format!("{root_dir}/stash/geneses/{id}.yaml"), - serde_yaml::to_string(runtime.genesis(id)?)?, + serde_yaml::to_string(genesis)?, )?; - for (no, suppl) in runtime - .contract_suppl_all(id) - .into_iter() - .flatten() - .enumerate() - { + } + for (id, list) in stock.as_stash_provider().debug_suppl() { + for suppl in list { fs::write( - format!("{root_dir}/stash/geneses/{id}.suppl.{no:03}.yaml"), + format!( + "{root_dir}/stash/geneses/{id}.suppl.{}.yaml", + suppl.suppl_id() + ), serde_yaml::to_string(suppl)?, )?; } - let tags = runtime.contract_asset_tags(id)?; - fs::write( - format!("{root_dir}/stash/geneses/{id}.tags.yaml"), - serde_yaml::to_string(tags)?, - )?; } - for id in runtime.bundle_ids()? { + for (id, bundle) in stock.as_stash_provider().debug_bundles() { fs::write( format!("{root_dir}/stash/bundles/{id}.yaml"), - serde_yaml::to_string(runtime.bundle(id)?)?, + serde_yaml::to_string(bundle)?, )?; } - for id in runtime.witness_ids()? { + for (id, witness) in stock.as_stash_provider().debug_witnesses() { fs::write( - format!("{root_dir}/stash/anchors/{id}.yaml"), - serde_yaml::to_string(runtime.anchor(id)?)?, + format!("{root_dir}/stash/witnesses/{id}.yaml"), + serde_yaml::to_string(witness)?, )?; } - for id in runtime.extension_ids()? { + for (id, extension) in stock.as_stash_provider().debug_extensions() { fs::write( format!("{root_dir}/stash/extensions/{id}.yaml"), - serde_yaml::to_string(runtime.extension(id)?)?, + serde_yaml::to_string(extension)?, )?; } + fs::write( + format!("{root_dir}/seal-secret.yaml"), + serde_yaml::to_string(stock.as_stash_provider().debug_secret_seals())?, + )?; // TODO: Add sigs debugging // State - for (id, history) in runtime.debug_history() { + for (id, history) in stock.as_state_provider().debug_history() { fs::write( format!("{root_dir}/state/{id}.yaml"), serde_yaml::to_string(history)?, @@ -961,23 +946,23 @@ impl Exec for RgbArgs { // Index fs::write( format!("{root_dir}/index/op-to-bundle.yaml"), - serde_yaml::to_string(runtime.debug_bundle_op_index())?, + serde_yaml::to_string(stock.as_index_provider().debug_op_bundle_index())?, )?; fs::write( - format!("{root_dir}/index/bundle-to-anchor.yaml"), - serde_yaml::to_string(runtime.debug_anchor_bundle_index())?, + format!("{root_dir}/index/bundle-to-contract.yaml"), + serde_yaml::to_string(stock.as_index_provider().debug_bundle_contract_index())?, )?; fs::write( - format!("{root_dir}/index/contracts.yaml"), - serde_yaml::to_string(runtime.debug_contract_index())?, + format!("{root_dir}/index/bundle-to-witness.yaml"), + serde_yaml::to_string(stock.as_index_provider().debug_bundle_witness_index())?, )?; fs::write( - format!("{root_dir}/index/terminals.yaml"), - serde_yaml::to_string(runtime.debug_terminal_index())?, + format!("{root_dir}/index/contracts.yaml"), + serde_yaml::to_string(stock.as_index_provider().debug_contract_index())?, )?; fs::write( - format!("{root_dir}/seal-secret.yaml"), - serde_yaml::to_string(runtime.debug_seal_secrets())?, + format!("{root_dir}/index/terminals.yaml"), + serde_yaml::to_string(stock.as_index_provider().debug_terminal_index())?, )?; eprintln!("Dump is successfully generated and saved to '{root_dir}'"); None @@ -989,9 +974,8 @@ impl Exec for RgbArgs { let status = match consignment.validate(&mut resolver, self.general.network.is_testnet()) { Ok(consignment) => consignment.into_validation_status(), - Err(consignment) => consignment.into_validation_status(), - } - .expect("just validated"); + Err((status, _)) => status, + }; if status.validity() == Validity::Valid { eprintln!("The provided consignment is valid") } else { @@ -999,21 +983,23 @@ impl Exec for RgbArgs { } None } - Command::Accept { force, file } => { - let mut runtime = self.rgb_runtime(&config)?; + Command::Accept { force: _, file } => { + // TODO: Ensure we properly handle unmined terminal transactions + let mut stock = self.rgb_stock()?; let mut resolver = self.resolver()?; - let consignment = Transfer::load_file(file)?; - resolver.add_terminals(&consignment); - let transfer = consignment + let transfer = Transfer::load_file(file)?; + resolver.add_terminals(&transfer); + let valid = transfer .validate(&mut resolver, self.general.network.is_testnet()) - .unwrap_or_else(|c| c); - eprintln!("{}", transfer.validation_status().expect("just validated")); - runtime.accept_transfer(transfer, &mut resolver, *force)?; + .map_err(|(status, _)| status)?; + stock.accept_transfer(valid, &mut resolver)?; eprintln!("Transfer accepted into the stash"); - Some(runtime) + Some(stock) } } { - runtime.store() + stock + .store(self.general.base_dir()) + .expect("unable to save stock"); } println!(); diff --git a/fs/Cargo.toml b/fs/Cargo.toml deleted file mode 100644 index c438a96..0000000 --- a/fs/Cargo.toml +++ /dev/null @@ -1,27 +0,0 @@ -[package] -name = "rgb-persist-fs" -version = "0.11.1" -description = "RGB persistence drivers for file storage" -keywords = ["bitcoin", "lightning", "rgb", "smart-contracts", "lnp-bp"] -categories = ["cryptography::cryptocurrencies"] -authors = { workspace = true } -repository = { workspace = true } -homepage = { workspace = true } -edition = { workspace = true } -license = { workspace = true } -rust-version = { workspace = true } -readme = "../README.md" - -[lib] -name = "rgbfs" - -[dependencies] -amplify = { workspace = true } -strict_encoding = { workspace = true } -rgb-std = { workspace = true } - -[features] -default = [] - -[package.metadata.docs.rs] -features = ["all"] diff --git a/fs/src/lib.rs b/fs/src/lib.rs deleted file mode 100644 index 35014c4..0000000 --- a/fs/src/lib.rs +++ /dev/null @@ -1,24 +0,0 @@ -// RGB smart contracts for Bitcoin & Lightning -// -// SPDX-License-Identifier: Apache-2.0 -// -// Written in 2019-2023 by -// Dr Maxim Orlovsky -// -// Copyright (C) 2019-2023 LNP/BP Standards Association. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -mod stock; - -pub use stock::StockFs; diff --git a/fs/src/stock.rs b/fs/src/stock.rs deleted file mode 100644 index 46416e1..0000000 --- a/fs/src/stock.rs +++ /dev/null @@ -1,41 +0,0 @@ -// RGB smart contracts for Bitcoin & Lightning -// -// SPDX-License-Identifier: Apache-2.0 -// -// Written in 2019-2023 by -// Dr Maxim Orlovsky -// -// Copyright (C) 2019-2023 LNP/BP Standards Association. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use std::path::Path; - -use amplify::confinement::U32; -use rgbstd::persistence::Stock; -use strict_encoding::{DeserializeError, SerializeError, StrictDeserialize, StrictSerialize}; - -pub trait StockFs: Sized { - fn load(path: impl AsRef) -> Result; - fn store(&self, path: impl AsRef) -> Result<(), SerializeError>; -} - -impl StockFs for Stock { - fn load(file: impl AsRef) -> Result { - Stock::strict_deserialize_from_file::(file) - } - - fn store(&self, file: impl AsRef) -> Result<(), SerializeError> { - self.strict_serialize_to_file::(file) - } -} diff --git a/psbt/src/lib.rs b/psbt/src/lib.rs index 33547d4..9806976 100644 --- a/psbt/src/lib.rs +++ b/psbt/src/lib.rs @@ -28,8 +28,8 @@ use bp::dbc::opret::OpretProof; use bp::dbc::tapret::TapretProof; pub use psbt::*; pub use rgb::*; -use rgbstd::containers::{Batch, Fascia}; -use rgbstd::{AnchorSet, XAnchor, XChain}; +use rgbstd::containers::{AnchorSet, Batch, CloseMethodSet, Fascia}; +use rgbstd::{XChain, XWitnessId}; pub use self::rgb::{ ProprietaryKeyRgb, RgbExt, RgbInExt, RgbOutExt, RgbPsbtError, PSBT_GLOBAL_RGB_TRANSITION, @@ -85,7 +85,7 @@ impl RgbPsbt for Psbt { if !inputs.is_empty() { return Err(EmbedError::AbsentInputs); } - self.push_rgb_transition(info.transition, info.methods) + self.push_rgb_transition(info.transition, info.method) .expect("transitions are unique since they are in BTreeMap indexed by opid"); } Ok(()) @@ -94,8 +94,14 @@ impl RgbPsbt for Psbt { fn rgb_commit(&mut self) -> Result { // Convert RGB data to MPCs? Or should we do it at the moment we add them... No, // since we may require more DBC methods with each additional state transition - let (bundles, methods) = self.rgb_bundles_to_mpc()?; + let bundles = self.rgb_bundles_to_mpc()?; // DBC commitment for the required methods + let methods = bundles + .values() + .flat_map(|b| b.iter()) + .map(|b| CloseMethodSet::from(b.close_method)) + .reduce(|methods, method| methods | method) + .ok_or(RgbPsbtError::NoContracts)?; let (mut tapret_anchor, mut opret_anchor) = (None, None); if methods.has_tapret_first() { tapret_anchor = Some(self.dbc_commit::()?); @@ -103,10 +109,15 @@ impl RgbPsbt for Psbt { if methods.has_opret_first() { opret_anchor = Some(self.dbc_commit::()?); } - let anchor = AnchorSet::from_split(tapret_anchor, opret_anchor) - .expect("at least one of DBC are present due to CloseMethodSet type guarantees"); + let anchor = match (tapret_anchor, opret_anchor) { + (None, None) => return Err(RgbPsbtError::NoContracts.into()), + (Some(tapret), None) => AnchorSet::Tapret(tapret), + (None, Some(opret)) => AnchorSet::Opret(opret), + (Some(tapret), Some(opret)) => AnchorSet::Double { tapret, opret }, + }; Ok(Fascia { - anchor: XAnchor::Bitcoin(anchor), + witness_id: XWitnessId::Bitcoin(self.txid()), + anchor, bundles, }) } diff --git a/psbt/src/rgb.rs b/psbt/src/rgb.rs index 0f056eb..49ef4d2 100644 --- a/psbt/src/rgb.rs +++ b/psbt/src/rgb.rs @@ -19,15 +19,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::collections::{BTreeMap, BTreeSet}; +use std::collections::{BTreeMap, BTreeSet, HashMap}; -use amplify::confinement::{Confined, MediumOrdMap, SmallOrdMap, U24}; +use amplify::confinement::{Confined, SmallOrdMap, U24}; use amplify::{confinement, FromSliceError}; use bp::dbc::Method; +use bp::seals::txout::CloseMethod; use commit_verify::mpc; use psbt::{KeyAlreadyPresent, KeyMap, MpcPsbtError, PropKey, Psbt}; use rgbstd::accessors::{MergeReveal, MergeRevealError}; -use rgbstd::containers::CloseMethodSet; +use rgbstd::containers::BundleDichotomy; use rgbstd::interface::VelocityHint; use rgbstd::{ContractId, InputMap, OpId, Operation, Transition, TransitionBundle, Vin}; use strict_encoding::{DeserializeError, StrictDeserialize, StrictSerialize}; @@ -157,50 +158,58 @@ pub trait RgbExt { fn rgb_transition(&self, opid: OpId) -> Result, RgbPsbtError>; - fn rgb_close_methods(&self, opid: OpId) -> Result, RgbPsbtError>; + fn rgb_close_method(&self, opid: OpId) -> Result, RgbPsbtError>; fn push_rgb_transition( &mut self, transition: Transition, - methods: CloseMethodSet, + method: CloseMethod, ) -> Result; - fn rgb_bundles( - &self, - ) -> Result, RgbPsbtError> { + fn rgb_bundles(&self) -> Result, RgbPsbtError> { let mut map = BTreeMap::new(); for contract_id in self.rgb_contract_ids()? { - let mut input_map = SmallOrdMap::::new(); - let mut known_transitions = SmallOrdMap::::new(); - let mut method_set = None::; + let mut input_map = HashMap::>::new(); + let mut known_transitions = + HashMap::>::new(); for (opid, vin) in self.rgb_contract_consumers(contract_id)? { - let (transition, methods) = ( + let (transition, method) = ( self.rgb_transition(opid)?, - self.rgb_close_methods(opid)? + self.rgb_close_method(opid)? .ok_or(RgbPsbtError::NoCloseMethod(opid))?, ); - method_set |= methods; - input_map.insert(vin, opid)?; + input_map.entry(method).or_default().insert(vin, opid)?; if let Some(transition) = transition { - known_transitions.insert(opid, transition)?; + known_transitions + .entry(method) + .or_default() + .insert(opid, transition)?; } } - let bundle = TransitionBundle { - input_map: InputMap::from(Confined::from_collection_unsafe(input_map.into_inner())), - known_transitions: Confined::try_from(known_transitions.into_inner()) - .map_err(|_| RgbPsbtError::NoTransitions(contract_id))?, - }; - map.insert(contract_id, (bundle, method_set.expect("type guarantees"))); + let mut bundles = vec![]; + for (method, input_map) in input_map { + let known_transitions = known_transitions.remove(&method).unwrap_or_default(); + bundles.push(TransitionBundle { + close_method: method, + input_map: InputMap::from(Confined::from_collection_unsafe( + input_map.into_inner(), + )), + known_transitions: Confined::try_from(known_transitions.into_inner()) + .map_err(|_| RgbPsbtError::NoTransitions(contract_id))?, + }); + } + let mut bundles = bundles.into_iter(); + let first = bundles + .next() + .ok_or(RgbPsbtError::NoTransitions(contract_id))?; + map.insert(contract_id, BundleDichotomy::with(first, bundles.next())); } Ok(map) } fn rgb_bundles_to_mpc( &mut self, - ) -> Result< - (Confined, 1, U24>, CloseMethodSet), - RgbPsbtError, - >; + ) -> Result, 1, U24>, RgbPsbtError>; } impl RgbExt for Psbt { @@ -248,12 +257,12 @@ impl RgbExt for Psbt { Ok(Some(transition)) } - fn rgb_close_methods(&self, opid: OpId) -> Result, RgbPsbtError> { + fn rgb_close_method(&self, opid: OpId) -> Result, RgbPsbtError> { let Some(m) = self.proprietary(&PropKey::rgb_closing_methods(opid)) else { return Ok(None); }; if m.len() == 1 { - if let Ok(method) = CloseMethodSet::try_from(m[0]) { + if let Ok(method) = CloseMethod::try_from(m[0]) { return Ok(Some(method)); } } @@ -263,10 +272,15 @@ impl RgbExt for Psbt { fn push_rgb_transition( &mut self, mut transition: Transition, - mut methods: CloseMethodSet, + method: CloseMethod, ) -> Result { let opid = transition.id(); - let prev_methods = self.rgb_close_methods(opid)?; + + let prev_method = self.rgb_close_method(opid)?; + if matches!(prev_method, Some(prev_method) if prev_method != method) { + return Err(RgbPsbtError::InvalidCloseMethod(opid)); + } + let prev_transition = self.rgb_transition(opid)?; if let Some(ref prev_transition) = prev_transition { transition = transition @@ -278,37 +292,34 @@ impl RgbExt for Psbt { let serialized_transition = transition .to_strict_serialized::() .map_err(|_| RgbPsbtError::TransitionTooBig(opid))?; + // Since we update transition it's ok to ignore the fact that it previously // existed let _ = self .push_proprietary(PropKey::rgb_transition(opid), serialized_transition.into_inner()); - methods |= prev_methods; - let _ = self.push_proprietary(PropKey::rgb_closing_methods(opid), vec![methods as u8]); + let _ = self.push_proprietary(PropKey::rgb_closing_methods(opid), vec![method as u8]); Ok(prev_transition.is_none()) } fn rgb_bundles_to_mpc( &mut self, - ) -> Result< - (Confined, 1, U24>, CloseMethodSet), - RgbPsbtError, - > { + ) -> Result, 1, U24>, RgbPsbtError> { let bundles = self.rgb_bundles()?; - let mut map = MediumOrdMap::new(); - let mut close_methods = None::; - for (contract_id, (bundle, methods)) in bundles { - let protocol_id = mpc::ProtocolId::from(contract_id); + for (contract_id, bundle) in bundles + .iter() + .flat_map(|(id, b)| b.iter().map(move |b| (id, b))) + { + let protocol_id = mpc::ProtocolId::from(*contract_id); let message = mpc::Message::from(bundle.bundle_id()); - if methods.has_tapret_first() { + if bundle.close_method == CloseMethod::TapretFirst { // We need to do it each time due to Rust borrow checker let tapret_host = self .outputs_mut() .find(|output| output.is_tapret_host()) .ok_or(RgbPsbtError::NoHostOutput(Method::TapretFirst))?; tapret_host.set_mpc_message(protocol_id, message)?; - } - if methods.has_opret_first() { + } else if bundle.close_method == CloseMethod::OpretFirst { // We need to do it each time due to Rust borrow checker let opret_host = self .outputs_mut() @@ -316,18 +327,11 @@ impl RgbExt for Psbt { .ok_or(RgbPsbtError::NoHostOutput(Method::OpretFirst))?; opret_host.set_mpc_message(protocol_id, message)?; } - map.insert(contract_id, bundle) - .map_err(|_| RgbPsbtError::TooManyContracts)?; - close_methods |= methods; } - let Some(close_methods) = close_methods else { - return Err(RgbPsbtError::NoContracts); - }; + let map = Confined::try_from(bundles).map_err(|_| RgbPsbtError::NoContracts)?; - let map = Confined::try_from(map.into_inner()).map_err(|_| RgbPsbtError::NoContracts)?; - - Ok((map, close_methods)) + Ok(map) } } diff --git a/src/descriptor.rs b/src/descriptor.rs index 75107e2..2c1c02f 100644 --- a/src/descriptor.rs +++ b/src/descriptor.rs @@ -50,8 +50,11 @@ pub trait DescriptorRgb: Descriptor { } #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug, Display)] -#[derive(Serialize, Deserialize)] -#[serde(crate = "serde_crate", rename_all = "camelCase")] +#[cfg_attr( + feature = "serde", + derive(Serialize, Deserialize), + serde(crate = "serde_crate", rename_all = "camelCase") +)] #[repr(u8)] pub enum RgbKeychain { #[display("0", alt = "0")] @@ -106,15 +109,21 @@ impl From for Keychain { fn from(keychain: RgbKeychain) -> Self { Keychain::from(keychain as u8) } } -#[serde_as] +#[cfg_attr(feature = "serde", serde_as)] #[derive(Clone, Eq, PartialEq, Debug)] -#[derive(Serialize, Deserialize)] -#[serde(crate = "serde_crate", rename_all = "camelCase")] +#[cfg_attr( + feature = "serde", + derive(Serialize, Deserialize), + serde(crate = "serde_crate", rename_all = "camelCase") +)] pub struct TapretKey { pub internal_key: K, // TODO: Allow multiple tweaks per index by introducing derivation using new Terminal trait // TODO: Change serde implementation for both Terminal and TapretCommitment - #[serde_as(as = "HashMap")] + #[cfg_attr( + feature = "serde", + serde_as(as = "HashMap") + )] pub tweaks: HashMap, } @@ -224,13 +233,16 @@ impl DescriptorRgb for TapretKey { } #[derive(Clone, Eq, PartialEq, Debug, From)] -#[derive(Serialize, Deserialize)] -#[serde( - crate = "serde_crate", - rename_all = "camelCase", - bound( - serialize = "S::Compr: serde::Serialize, S::XOnly: serde::Serialize", - deserialize = "S::Compr: serde::Deserialize<'de>, S::XOnly: serde::Deserialize<'de>" +#[cfg_attr( + feature = "serde", + derive(Serialize, Deserialize), + serde( + crate = "serde_crate", + rename_all = "camelCase", + bound( + serialize = "S::Compr: serde::Serialize, S::XOnly: serde::Serialize", + deserialize = "S::Compr: serde::Deserialize<'de>, S::XOnly: serde::Deserialize<'de>" + ) ) )] #[non_exhaustive] diff --git a/src/pay.rs b/src/pay.rs index c6f8af0..4d955b6 100644 --- a/src/pay.rs +++ b/src/pay.rs @@ -20,9 +20,7 @@ // limitations under the License. use std::collections::{BTreeMap, BTreeSet}; -use std::convert::Infallible; -use amplify::confinement::Confined; use bp::dbc::tapret::TapretProof; use bp::seals::txout::{CloseMethod, ExplicitSeal}; use bp::{Outpoint, Sats, ScriptPubkey, Vout}; @@ -33,9 +31,10 @@ use rgbstd::containers::Transfer; use rgbstd::interface::ContractError; use rgbstd::invoice::{Amount, Beneficiary, InvoiceState, RgbInvoice}; use rgbstd::persistence::{ - ComposeError, ConsignerError, Inventory, InventoryError, Stash, StashError, + ComposeError, ConsignError, ContractIfaceError, FasciaError, StockError, StockErrorAll, + StockErrorMem, }; -use rgbstd::{WitnessId, XChain}; +use rgbstd::XChain; use crate::{ ContractOutpointsFilter, DescriptorRgb, RgbKeychain, Runtime, TapTweakAlreadyAssigned, @@ -93,19 +92,14 @@ pub enum CompositionError { #[from] #[display(inner)] - Inventory(InventoryError), - - #[from] - #[display(inner)] - Stash(StashError), - - #[from] - #[display(inner)] - Compose(ComposeError), + Embed(EmbedError), #[from] + #[from(StockError)] + #[from(StockErrorMem)] + #[from(StockErrorMem)] #[display(inner)] - Embed(EmbedError), + Stock(StockErrorAll), } #[derive(Debug, Display, Error, From)] @@ -130,15 +124,12 @@ pub enum CompletionError { #[from] #[display(inner)] - Inventory(InventoryError), - - #[from] - #[display(inner)] - Consigner(ConsignerError), + Commit(CommitError), - #[from] + #[from(StockErrorMem)] + #[from(StockErrorMem)] #[display(inner)] - Commit(CommitError), + Stock(StockErrorAll), } #[derive(Clone, PartialEq, Debug)] @@ -180,8 +171,8 @@ impl Runtime { let contract_id = invoice.contract.ok_or(CompositionError::NoContract)?; let iface_name = invoice.iface.clone().ok_or(CompositionError::NoIface)?; - let iface = self.stock().iface_by_name(&iface_name)?; - let contract = self.contract_iface_named(contract_id, iface_name)?; + let iface = self.stock().iface(iface_name.clone())?; + let contract = self.contract_iface(contract_id, iface_name)?; let operation = invoice .operation .as_ref() @@ -341,21 +332,10 @@ impl Runtime { Beneficiary::BlindedSeal(seal) => (vec![XChain::Bitcoin(seal)], vec![]), }; - self.stock_mut().consume(fascia)?; - let mut transfer = self + self.stock_mut().consume_fascia(fascia)?; + let transfer = self .stock() .transfer(contract_id, beneficiary2, beneficiary1)?; - 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) { - // TODO: Use unsigned tx - terminal.witness_tx = Some(XChain::Bitcoin(psbt.to_unsigned_tx().into())); - } - } - transfer.terminals = Confined::from_collection_unsafe(terminals); Ok(transfer) } diff --git a/src/resolvers/any.rs b/src/resolvers/any.rs index 08f69d2..e3da7a8 100644 --- a/src/resolvers/any.rs +++ b/src/resolvers/any.rs @@ -22,7 +22,7 @@ use rgbstd::containers::Consignment; use rgbstd::resolvers::ResolveHeight; use rgbstd::validation::{ResolveWitness, WitnessResolverError}; -use rgbstd::{WitnessAnchor, WitnessId, XAnchor, XPubWitness}; +use rgbstd::{WitnessAnchor, XWitnessId, XWitnessTx}; #[cfg(feature = "electrum")] use crate::electrum; @@ -73,9 +73,9 @@ impl AnyResolver { pub fn add_terminals(&mut self, consignment: &Consignment) { match self { #[cfg(feature = "electrum")] - AnyResolver::Electrum(inner) => inner.add_terminals(consignment), + AnyResolver::Electrum(inner) => inner.add_witnesses(consignment), #[cfg(feature = "esplora_blocking")] - AnyResolver::Esplora(inner) => inner.add_terminals(consignment), + AnyResolver::Esplora(inner) => inner.add_witnesses(consignment), } } } @@ -83,12 +83,12 @@ impl AnyResolver { impl ResolveHeight for AnyResolver { type Error = AnyAnchorResolverError; - fn resolve_anchor(&mut self, anchor: &XAnchor) -> Result { + fn resolve_height(&mut self, witness_id: XWitnessId) -> Result { match self { #[cfg(feature = "electrum")] - AnyResolver::Electrum(inner) => inner.resolve_anchor(anchor).map_err(|e| e.into()), + AnyResolver::Electrum(inner) => inner.resolve_height(witness_id).map_err(|e| e.into()), #[cfg(feature = "esplora_blocking")] - AnyResolver::Esplora(inner) => inner.resolve_anchor(anchor).map_err(|e| e.into()), + AnyResolver::Esplora(inner) => inner.resolve_height(witness_id).map_err(|e| e.into()), } } } @@ -96,8 +96,8 @@ impl ResolveHeight for AnyResolver { impl ResolveWitness for AnyResolver { fn resolve_pub_witness( &self, - witness_id: WitnessId, - ) -> Result { + witness_id: XWitnessId, + ) -> Result { match self { #[cfg(feature = "electrum")] AnyResolver::Electrum(inner) => inner.resolve_pub_witness(witness_id), diff --git a/src/resolvers/electrum.rs b/src/resolvers/electrum.rs index f67a45e..af72748 100644 --- a/src/resolvers/electrum.rs +++ b/src/resolvers/electrum.rs @@ -27,7 +27,7 @@ use electrum::{Client, ElectrumApi, Error, Param}; use rgbstd::containers::Consignment; use rgbstd::resolvers::ResolveHeight; use rgbstd::validation::{ResolveWitness, WitnessResolverError}; -use rgbstd::{Layer1, WitnessAnchor, WitnessId, WitnessOrd, WitnessPos, XAnchor, XPubWitness}; +use rgbstd::{Layer1, WitnessAnchor, WitnessOrd, WitnessPos, XChain, XWitnessId, XWitnessTx}; pub struct Resolver { electrum_client: Client, @@ -45,9 +45,6 @@ pub enum AnchorResolverError { /// impossible conversion ImpossibleConversion, - /// invalid anchor {0} - InvalidAnchor(String), - /// unsupported layer 1 {0} UnsupportedLayer1(Layer1), } @@ -62,13 +59,17 @@ impl Resolver { }) } - pub fn add_terminals(&mut self, consignment: &Consignment) { + pub fn add_witnesses(&mut self, consignment: &Consignment) { self.terminal_txes.extend( consignment - .terminals - .values() - .filter_map(|t| t.witness_tx.as_ref().map(XPubWitness::as_reduced_unsafe)) - .map(|tx| (tx.txid(), tx.clone())), + .bundles + .iter() + .filter_map(|bw| bw.pub_witness.maybe_map_ref(|w| w.tx.clone())) + .filter_map(|tx| match tx { + XChain::Bitcoin(tx) => Some(tx), + XChain::Liquid(_) | XChain::Other(_) => None, + }) + .map(|tx| (tx.txid(), tx)), ); } } @@ -76,18 +77,15 @@ impl Resolver { impl ResolveHeight for Resolver { type Error = AnchorResolverError; - fn resolve_anchor(&mut self, anchor: &XAnchor) -> Result { - let XAnchor::Bitcoin(anchor) = anchor else { - return Err(AnchorResolverError::UnsupportedLayer1(anchor.layer1())); + fn resolve_height(&mut self, witness_id: XWitnessId) -> Result { + let XWitnessId::Bitcoin(txid) = witness_id else { + return Err(AnchorResolverError::UnsupportedLayer1(witness_id.layer1())); }; - let txid = anchor - .txid() - .ok_or(AnchorResolverError::InvalidAnchor(format!("{:#?}", anchor)))?; if self.terminal_txes.contains_key(&txid) { return Ok(WitnessAnchor { witness_ord: WitnessOrd::OffChain, - witness_id: WitnessId::Bitcoin(txid), + witness_id, }); } @@ -154,7 +152,7 @@ impl ResolveHeight for Resolver { Ok(WitnessAnchor { witness_ord, - witness_id: WitnessId::Bitcoin(txid), + witness_id, }) } } @@ -162,9 +160,9 @@ impl ResolveHeight for Resolver { impl ResolveWitness for Resolver { fn resolve_pub_witness( &self, - witness_id: WitnessId, - ) -> Result { - let WitnessId::Bitcoin(txid) = witness_id else { + witness_id: XWitnessId, + ) -> Result { + let XWitnessId::Bitcoin(txid) = witness_id else { return Err(WitnessResolverError::Other( witness_id, AnchorResolverError::UnsupportedLayer1(witness_id.layer1()).to_string(), @@ -172,7 +170,7 @@ impl ResolveWitness for Resolver { }; if let Some(tx) = self.terminal_txes.get(&txid) { - return Ok(XPubWitness::Bitcoin(tx.clone())); + return Ok(XWitnessTx::Bitcoin(tx.clone())); } match self.electrum_client.transaction_get_raw(&txid) { @@ -180,7 +178,7 @@ impl ResolveWitness for Resolver { let tx = Tx::consensus_deserialize(raw_tx).map_err(|_| { WitnessResolverError::Other(witness_id, s!("cannot deserialize raw TX")) })?; - Ok(XPubWitness::Bitcoin(tx)) + Ok(XWitnessTx::Bitcoin(tx)) } Err(e) if e.to_string() diff --git a/src/resolvers/esplora_blocking.rs b/src/resolvers/esplora_blocking.rs index 944a673..b167751 100644 --- a/src/resolvers/esplora_blocking.rs +++ b/src/resolvers/esplora_blocking.rs @@ -26,9 +26,7 @@ pub use esplora::Error as ResolverError; use rgbstd::containers::Consignment; use rgbstd::resolvers::ResolveHeight; use rgbstd::validation::{ResolveWitness, WitnessResolverError}; -use rgbstd::{ - Layer1, WitnessAnchor, WitnessId, WitnessOrd, WitnessPos, XAnchor, XChain, XPubWitness, -}; +use rgbstd::{Layer1, WitnessAnchor, WitnessOrd, WitnessPos, XChain, XWitnessId, XWitnessTx}; pub struct Resolver { esplora_client: esplora::BlockingClient, @@ -43,9 +41,6 @@ pub enum AnchorResolverError { #[display(inner)] Error(esplora::Error), - /// invalid anchor {0} - InvalidAnchor(String), - /// unsupported layer 1 {0} UnsupportedLayer1(Layer1), } @@ -60,13 +55,17 @@ impl Resolver { }) } - pub fn add_terminals(&mut self, consignment: &Consignment) { + pub fn add_witnesses(&mut self, consignment: &Consignment) { self.terminal_txes.extend( consignment - .terminals - .values() - .filter_map(|t| t.witness_tx.as_ref().map(XPubWitness::as_reduced_unsafe)) - .map(|tx| (tx.txid(), tx.clone())), + .bundles + .iter() + .filter_map(|bw| bw.pub_witness.maybe_map_ref(|w| w.tx.clone())) + .filter_map(|tx| match tx { + XChain::Bitcoin(tx) => Some(tx), + XChain::Liquid(_) | XChain::Other(_) => None, + }) + .map(|tx| (tx.txid(), tx)), ); } } @@ -74,18 +73,15 @@ impl Resolver { impl ResolveHeight for Resolver { type Error = AnchorResolverError; - fn resolve_anchor(&mut self, anchor: &XAnchor) -> Result { - let XAnchor::Bitcoin(anchor) = anchor else { - return Err(AnchorResolverError::UnsupportedLayer1(anchor.layer1())); + fn resolve_height(&mut self, witness_id: XWitnessId) -> Result { + let XWitnessId::Bitcoin(txid) = witness_id else { + return Err(AnchorResolverError::UnsupportedLayer1(witness_id.layer1())); }; - let txid = anchor - .txid() - .ok_or(AnchorResolverError::InvalidAnchor(format!("{:#?}", anchor)))?; if self.terminal_txes.contains_key(&txid) { return Ok(WitnessAnchor { witness_ord: WitnessOrd::OffChain, - witness_id: WitnessId::Bitcoin(txid), + witness_id, }); } @@ -101,7 +97,7 @@ impl ResolveHeight for Resolver { }; Ok(WitnessAnchor { witness_ord: ord, - witness_id: WitnessId::Bitcoin(txid), + witness_id, }) } } @@ -109,9 +105,9 @@ impl ResolveHeight for Resolver { impl ResolveWitness for Resolver { fn resolve_pub_witness( &self, - witness_id: WitnessId, - ) -> Result { - let WitnessId::Bitcoin(txid) = witness_id else { + witness_id: XWitnessId, + ) -> Result { + let XWitnessId::Bitcoin(txid) = witness_id else { return Err(WitnessResolverError::Other( witness_id, AnchorResolverError::UnsupportedLayer1(witness_id.layer1()).to_string(), @@ -119,7 +115,7 @@ impl ResolveWitness for Resolver { }; if let Some(tx) = self.terminal_txes.get(&txid) { - return Ok(XPubWitness::Bitcoin(tx.clone())); + return Ok(XWitnessTx::Bitcoin(tx.clone())); } self.esplora_client diff --git a/src/runtime.rs b/src/runtime.rs index ef4040e..c4b3092 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -24,26 +24,21 @@ use std::collections::HashMap; use std::convert::Infallible; use std::io; -use std::io::ErrorKind; use std::ops::{Deref, DerefMut}; use std::path::PathBuf; use amplify::IoError; use bpstd::{Network, XpubDerivable}; use bpwallet::Wallet; -use rgbfs::StockFs; -use rgbstd::containers::{Contract, LoadError, Transfer}; +use rgbstd::containers::LoadError; use rgbstd::interface::{ - AmountChange, BuilderError, ContractError, IfaceOp, OutpointFilter, WitnessFilter, - WrongImplementation, + AmountChange, BuilderError, ContractError, IfaceOp, IfaceRef, OutpointFilter, WitnessFilter, }; -use rgbstd::persistence::{ - Inventory, InventoryDataError, InventoryError, Stash, StashError, Stock, -}; -use rgbstd::resolvers::ResolveHeight; -use rgbstd::validation::{self, ResolveWitness}; -use rgbstd::{AssignmentWitness, ContractId, WitnessId, XChain, XOutpoint}; -use strict_types::encoding::{DecodeError, DeserializeError, Ident, SerializeError, TypeName}; +use rgbstd::persistence::fs::{LoadFs, StoreFs}; +use rgbstd::persistence::{ContractIfaceError, Stock, StockError, StockErrorAll, StockErrorMem}; +use rgbstd::validation::{self}; +use rgbstd::{AssignmentWitness, ContractId, XChain, XOutpoint, XWitnessId}; +use strict_types::encoding::{DeserializeError, Ident, SerializeError}; use crate::{DescriptorRgb, RgbDescr}; @@ -64,14 +59,6 @@ pub enum RuntimeError { Load(LoadError), #[from] - Stash(StashError), - - #[from] - #[from(InventoryDataError)] - Inventory(InventoryError), - - #[from] - #[from(WrongImplementation)] Builder(BuilderError), #[from] @@ -111,6 +98,13 @@ pub enum RuntimeError { #[display(doc_comments)] ResolverError(crate::AnyResolverError), + #[from] + #[from(StockError)] + #[from(StockErrorMem)] + #[display(inner)] + Stock(StockErrorAll), + + #[cfg(feature = "serde_yaml")] #[from] Yaml(serde_yaml::Error), @@ -156,7 +150,7 @@ impl, K> WitnessFilter for Runtime { self.wallet() .transactions() .keys() - .any(|txid| AssignmentWitness::Present(WitnessId::Bitcoin(*txid)) == witness) + .any(|txid| AssignmentWitness::Present(XWitnessId::Bitcoin(*txid)) == witness) } } @@ -171,7 +165,7 @@ impl<'runtime, D: DescriptorRgb, K> OutpointFilter for ContractOutpointsFilte if !self.filter.include_outpoint(output) { return false; } - matches!(self.filter.stock.state_for_outpoints(self.contract_id, [output]), Ok(list) if !list.is_empty()) + matches!(self.filter.stock.contract_assignments_for(self.contract_id, [output]), Ok(list) if !list.is_empty()) } } @@ -181,23 +175,30 @@ where for<'de> D: serde::Serialize + serde::Deserialize<'de>, for<'de> bpwallet::WalletDescr: serde::Serialize + serde::Deserialize<'de>, { - pub fn load_attach( - mut stock_path: PathBuf, - bprt: bpwallet::Runtime, - ) -> Result { - stock_path.push("stock.dat"); + pub fn load_walletless(stock_path: &PathBuf) -> Result { + use std::io::ErrorKind; - let stock = Stock::load(&stock_path).or_else(|err| { - if matches!(err, DeserializeError::Decode(DecodeError::Io(ref err)) if err.kind() == ErrorKind::NotFound) { + use strict_types::encoding::DecodeError; + + Stock::load(stock_path).map_err(RuntimeError::from).or_else(|err| { + if matches!(err, RuntimeError::Deserialize(DeserializeError::Decode(DecodeError::Io(ref err))) if err.kind() == ErrorKind::NotFound) { #[cfg(feature = "log")] eprint!("stock file is absent, creating a new one ... "); let stock = Stock::default(); + std::fs::create_dir_all(stock_path)?; + stock.store(stock_path)?; return Ok(stock) } eprintln!("stock file is damaged"); Err(err) - })?; + }) + } + pub fn load_attach( + stock_path: PathBuf, + bprt: bpwallet::Runtime, + ) -> Result { + let stock = Self::load_walletless(&stock_path)?; Ok(Self { stock_path, stock, @@ -211,6 +212,8 @@ where .expect("unable to save stock"); self.bprt.try_store().expect("unable to save wallet data"); } + + pub fn into_stock(self) -> Stock { self.stock } } impl, K> Runtime { @@ -220,56 +223,16 @@ impl, K> Runtime { pub fn attach(&mut self, bprt: bpwallet::Runtime) { self.bprt = bprt } - pub fn unload(self) {} - pub fn network(&self) -> Network { self.bprt.network() } - pub fn import_contract( - &mut self, - contract: Contract, - resolver: &mut R, - ) -> Result - where - R::Error: 'static, - { - self.stock - .import_contract(contract, resolver) - .map_err(RuntimeError::from) - } - - pub fn validate_transfer( - &mut self, - transfer: Transfer, - resolver: &mut impl ResolveWitness, - ) -> Result { - transfer - .validate(resolver, self.network().is_testnet()) - .map_err(|invalid| invalid.validation_status().expect("just validated").clone()) - .map_err(RuntimeError::from) - } - - pub fn accept_transfer( - &mut self, - transfer: Transfer, - resolver: &mut R, - force: bool, - ) -> Result - where - R::Error: 'static, - { - self.stock - .accept_transfer(transfer, resolver, force) - .map_err(RuntimeError::from) - } - // TODO: Integrate into BP Wallet `TxRow` as L2 and provide transactional info pub fn fungible_history( &self, contract_id: ContractId, - iface_name: impl Into, - ) -> Result>, RuntimeError> { - let iface_name = iface_name.into(); - let iface = self.stock.iface_by_name(&iface_name)?; + iface: impl Into, + ) -> Result>, RuntimeError> { + let iref = iface.into(); + let iface = self.stock.iface(iref.clone())?; let default_op = iface .default_operation .as_ref() @@ -282,7 +245,7 @@ impl, K> Runtime { .as_ref() .ok_or(HistoryError::NoDefaultAssignment)? .clone(); - let contract = self.stock.contract_iface_named(contract_id, iface_name)?; + let contract = self.stock.contract_iface(contract_id, iref)?; contract .fungible_ops::(state_name, self, self) .map_err(RuntimeError::from)