diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4c80fd5..8d7628a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: override: true profile: minimal - name: Build on Rust ${{ matrix.toolchain }} - run: cargo build --color always --all-targets + run: cargo build --color always --all-targets --features enable-danger-local-https - name: Check formatting (nightly only) if: matrix.rust == 'nightly' run: rustup component add rustfmt && cargo fmt --all -- --check diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..4a8a95a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,54 @@ +## [0.20.0] +#### APIs added +- Make backwards-compatible `v2` to `v1` sends possible. +#### APIs changed +- Removed `contribute_non_nitness_input` from `v1` & `v2`. +- Allow receivers to make `payjoins` out of sweep transactions ([#259](https://github.com/payjoin/rust-payjoin/pull/259)). +- Encode &ohttp= and &exp= parameters in the &pj= URL as a fragment instead of as URI params ([#298](https://github.com/payjoin/rust-payjoin/pull/298)) + +## [0.18.0] +This release updates the bindings libraries to `payjoin` version `0.18.0`. +#### APIs changed +- Upgrade `receive/v2` type state machine to resume multiple `payjoins` simultaneously ([#283](https://github.com/payjoin/rust-payjoin/pull/283)) +- Refactor output substitution with new fallable `try_substitute_outputs` ([#277](https://github.com/payjoin/rust-payjoin/pull/277)) +- Replaced `Enroller` with `SessionInitializer`. +- Replaced `Enrolled` with `ActiveSession`. +- Replaced `fallback_target()` with `pj_url`. +#### APIs added +- Exposed `PjUriBuilder` and `PjUri`. +- Exposed `pjUrl_builder()` in `ActiveSession`. +- Exposed `check_pj_supported()` in `PjUri`. +- Exposed `fetch_ohttp_keys()` to fetch the `ohttp` keys from the specified `payjoin` directory. + +## [0.13.0] +### Features & Modules +#### Send module +- ##### V1 + - `RequestBuilder` exposes `from_psbt_and_uri`, `build_with_additional_fee`, `build_recommended`, `build_non_incentivizing`, `always_disable_output_substitution`. + - `RequestContext` exposes `extract_contextV1` & `extract_contextV2`. + - `ContextV1` exposes `process_response`. +- ##### V2 + - `ContextV2` exposes `process_response`. +#### Receive module +- ##### V1 + - `UncheckedProposal` exposes `from_request`, `extract_tx_to_schedule_broadcast`, `check_broadcast_suitability`, `build_non_incentivizing`, + `assume_interactive_receiver` &`always_disable_output_substitution`. + - `MaybeInputsOwned` exposes `check_inputs_not_owned`. + - `MaybeMixedInputScripts` exposes `check_no_mixed_input_scripts`. + - `MaybeInputsSeen` exposes `check_no_inputs_seen_before`. + - `OutputsUnknown` exposes `identify_receiver_outputs`. + - `ProvisionalProposal` exposes `substitute_output_address`, `contribute_non_witness_input`, `contribute_witness_input`, `try_preserving_privacy` & + `finalize_proposal`. + - `PayjoinProposal` exposes `is_output_substitution_disabled`, `owned_vouts`, `psbt` & `utxos_to_be_locked`. +- ##### V2 + - `Enroller` exposes `from_directory_config`, `process_response` & `extract_request`. + - `Enrolled` exposes `extract_request`, `process_response` & `fall_back_target`. + - `V2UncheckedProposal` exposes `extract_tx_to_schedule_broadcast`, `check_broadcast_suitability` & `assume_interactive_receiver`. + - `V2MaybeInputsOwned` exposes `check_inputs_not_owned`. + - `V2MaybeMixedInputScripts` exposes `check_no_mixed_input_scripts`. + - `V2MaybeInputsSeen` exposes `check_no_inputs_seen_before`. + - `V2OutputsUnknown` exposes `identify_receiver_outputs`. + - `V2ProvisionalProposal` exposes `substitute_output_address`, `contribute_non_witness_input`, `contribute_witness_input`, `try_preserving_privacy` & + `finalize_proposal`. + - `V2PayjoinProposal` exposes `deserialize_res`, `extract_v1_req`, `extract_v2_req`, `is_output_substitution_disabled`, `owned_vouts`, `psbt` & + `utxos_to_be_locked`. \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index b1940ee..3226e48 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -88,6 +88,15 @@ dependencies = [ "subtle", ] +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + [[package]] name = "anstream" version = "0.5.0" @@ -302,6 +311,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ef06386f8f092c3419e153a657396e53cafbb901de445a5c54d96ab2ff8c7b2" dependencies = [ "thiserror", + "url", ] [[package]] @@ -315,11 +325,11 @@ dependencies = [ [[package]] name = "bip21" -version = "0.3.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b9532c632b068e45a478f5e309126b6e2ec1dbf0bbd327b73836f33d9a43ede" +checksum = "ebe7a7f5928d264879d5b65eb18a72ea1890c57f22d62ee2eba93f207a6a020b" dependencies = [ - "bitcoin 0.30.1", + "bitcoin 0.32.2", "percent-encoding-rfc3986", ] @@ -356,6 +366,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea507acc1cd80fc084ace38544bbcf7ced7c2aa65b653b102de0ce718df668f6" dependencies = [ "base58ck", + "base64 0.21.7", "bech32 0.11.0", "bitcoin-internals 0.3.0", "bitcoin-io", @@ -461,6 +472,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + [[package]] name = "block-buffer" version = "0.9.0" @@ -479,6 +496,16 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bollard-stubs" +version = "1.42.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed59b5c00048f48d7af971b71f800fdf23e858844a6f9e4d32ca72e9399e7864" +dependencies = [ + "serde", + "serde_with", +] + [[package]] name = "bumpalo" version = "3.14.0" @@ -661,6 +688,36 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +[[package]] +name = "combine" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" +dependencies = [ + "bytes", + "futures-core", + "memchr", + "pin-project-lite", + "tokio", + "tokio-util", +] + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + [[package]] name = "cpufeatures" version = "0.1.5" @@ -755,6 +812,56 @@ dependencies = [ "zeroize", ] +[[package]] +name = "darling" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 1.0.109", +] + +[[package]] +name = "darling_macro" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" +dependencies = [ + "darling_core", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "data-encoding" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" + +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + [[package]] name = "digest" version = "0.9.0" @@ -794,6 +901,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "esplora-client" version = "0.6.0" @@ -848,6 +961,21 @@ dependencies = [ "winapi", ] +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.30" @@ -855,6 +983,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -863,6 +992,40 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +[[package]] +name = "futures-executor" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + [[package]] name = "futures-task" version = "0.3.30" @@ -875,10 +1038,16 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ + "futures-channel", "futures-core", + "futures-io", + "futures-macro", + "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", + "slab", ] [[package]] @@ -954,6 +1123,31 @@ dependencies = [ "scroll", ] +[[package]] +name = "h2" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 0.2.12", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + [[package]] name = "heck" version = "0.4.1" @@ -966,6 +1160,12 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + [[package]] name = "hex" version = "0.4.3" @@ -1046,6 +1246,17 @@ dependencies = [ "zeroize", ] +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http" version = "1.1.0" @@ -1057,6 +1268,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http 0.2.12", + "pin-project-lite", +] + [[package]] name = "http-body" version = "1.0.1" @@ -1064,7 +1286,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http", + "http 1.1.0", ] [[package]] @@ -1075,8 +1297,8 @@ checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", "futures-util", - "http", - "http-body", + "http 1.1.0", + "http-body 1.0.1", "pin-project-lite", ] @@ -1086,6 +1308,36 @@ version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http 0.2.12", + "http-body 0.4.6", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2 0.5.7", + "tokio", + "tower-service", + "tracing", + "want", +] + [[package]] name = "hyper" version = "1.4.1" @@ -1095,9 +1347,10 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "http", - "http-body", + "http 1.1.0", + "http-body 1.0.1", "httparse", + "httpdate", "itoa", "pin-project-lite", "smallvec", @@ -1105,6 +1358,22 @@ dependencies = [ "want", ] +[[package]] +name = "hyper-rustls" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +dependencies = [ + "futures-util", + "http 0.2.12", + "hyper 0.14.30", + "log", + "rustls 0.21.7", + "rustls-native-certs 0.6.3", + "tokio", + "tokio-rustls 0.24.1", +] + [[package]] name = "hyper-rustls" version = "0.26.0" @@ -1112,14 +1381,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" dependencies = [ "futures-util", - "http", - "hyper", + "http 1.1.0", + "hyper 1.4.1", "hyper-util", + "log", "rustls 0.22.4", + "rustls-native-certs 0.7.1", "rustls-pki-types", "tokio", - "tokio-rustls", + "tokio-rustls 0.25.0", "tower-service", + "webpki-roots 0.26.3", +] + +[[package]] +name = "hyper-tungstenite" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a343d17fe7885302ed7252767dc7bb83609a874b6ff581142241ec4b73957ad" +dependencies = [ + "http-body-util", + "hyper 1.4.1", + "hyper-util", + "pin-project-lite", + "tokio", + "tokio-tungstenite", + "tungstenite", ] [[package]] @@ -1131,17 +1418,23 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "http", - "http-body", - "hyper", + "http 1.1.0", + "http-body 1.0.1", + "hyper 1.4.1", "pin-project-lite", - "socket2", + "socket2 0.5.7", "tokio", "tower", "tower-service", "tracing", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.5.0" @@ -1152,6 +1445,16 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown", +] + [[package]] name = "inout" version = "0.1.3" @@ -1231,6 +1534,15 @@ version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + [[package]] name = "memchr" version = "2.6.1" @@ -1311,6 +1623,32 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + [[package]] name = "object" version = "0.32.2" @@ -1343,6 +1681,28 @@ dependencies = [ "toml", ] +[[package]] +name = "ohttp-relay" +version = "0.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7850c40a0aebcba289d3252c0a45f93cba6ad4b0c46b88a5fc51dba6ddce8632" +dependencies = [ + "futures", + "http 1.1.0", + "http-body-util", + "hyper 1.4.1", + "hyper-rustls 0.26.0", + "hyper-tungstenite", + "hyper-util", + "once_cell", + "rustls 0.22.4", + "tokio", + "tokio-tungstenite", + "tokio-util", + "tracing", + "tracing-subscriber", +] + [[package]] name = "once_cell" version = "1.18.0" @@ -1355,6 +1715,18 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "parking_lot" version = "0.11.2" @@ -1363,7 +1735,17 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", - "parking_lot_core", + "parking_lot_core 0.8.6", +] + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core 0.9.10", ] [[package]] @@ -1375,27 +1757,41 @@ dependencies = [ "cfg-if", "instant", "libc", - "redox_syscall", + "redox_syscall 0.2.16", "smallvec", "winapi", ] [[package]] -name = "paste" -version = "1.0.14" +name = "parking_lot_core" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" - -[[package]] -name = "payjoin" -version = "0.19.0" -source = "git+https://github.com/payjoin/rust-payjoin?rev=941a6798f52f60d72061fc0a02b5b42146321453#941a6798f52f60d72061fc0a02b5b42146321453" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.5.3", + "smallvec", + "windows-targets 0.52.6", +] + +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + +[[package]] +name = "payjoin" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf485245549b366884e295426755ce649d924762f676c1cc00e12e21501884a3" dependencies = [ "bhttp", "bip21", - "bitcoin 0.30.1", + "bitcoin 0.32.2", "chacha20poly1305 0.10.1", - "http", + "http 1.1.0", "log", "ohttp", "reqwest", @@ -1405,21 +1801,59 @@ dependencies = [ "url", ] +[[package]] +name = "payjoin-directory" +version = "0.0.1" +source = "git+https://github.com/payjoin/rust-payjoin#12e08ce3476562e5d22512e17c13281e156bc4b2" +dependencies = [ + "anyhow", + "bhttp", + "bitcoin 0.30.1", + "futures", + "hyper 0.14.30", + "hyper-rustls 0.24.2", + "ohttp", + "redis", + "rustls 0.21.7", + "tokio", + "tracing", + "tracing-subscriber", +] + [[package]] name = "payjoin_ffi" -version = "0.18.0" +version = "0.20.0" dependencies = [ "base64 0.22.1", "bdk", "bitcoincore-rpc", "hex", + "http 1.1.0", "ohttp", + "ohttp-relay", "payjoin", + "payjoin-directory", + "rcgen", + "reqwest", + "rustls 0.22.4", + "testcontainers", + "testcontainers-modules", "thiserror", + "tokio", "uniffi", "url", ] +[[package]] +name = "pem" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" +dependencies = [ + "base64 0.22.1", + "serde", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -1516,6 +1950,12 @@ dependencies = [ "universal-hash 0.5.1", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -1576,15 +2016,101 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rcgen" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52c4f3084aa3bc7dfbba4eff4fab2a54db4324965d8872ab933565e6fbd83bc6" +dependencies = [ + "pem", + "ring 0.16.20", + "time", + "yasna", +] + +[[package]] +name = "redis" +version = "0.23.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f49cdc0bb3f412bf8e7d1bd90fe1d9eb10bc5c399ba90973c14662a27b3f8ba" +dependencies = [ + "async-trait", + "bytes", + "combine", + "futures-util", + "itoa", + "percent-encoding", + "pin-project-lite", + "ryu", + "sha1_smol", + "socket2 0.4.10", + "tokio", + "tokio-util", + "url", +] + [[package]] name = "redox_syscall" version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +dependencies = [ + "bitflags 2.6.0", ] +[[package]] +name = "regex" +version = "1.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata 0.4.7", + "regex-syntax 0.8.4", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.4", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "regex-syntax" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + [[package]] name = "reqwest" version = "0.12.4" @@ -1595,11 +2121,11 @@ dependencies = [ "bytes", "futures-core", "futures-util", - "http", - "http-body", + "http 1.1.0", + "http-body 1.0.1", "http-body-util", - "hyper", - "hyper-rustls", + "hyper 1.4.1", + "hyper-rustls 0.26.0", "hyper-util", "ipnet", "js-sys", @@ -1609,14 +2135,14 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rustls 0.22.4", - "rustls-pemfile", + "rustls-pemfile 2.1.2", "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", "sync_wrapper", "tokio", - "tokio-rustls", + "tokio-rustls 0.25.0", "tower-service", "url", "wasm-bindgen", @@ -1687,6 +2213,40 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rustls-native-certs" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" +dependencies = [ + "openssl-probe", + "rustls-pemfile 1.0.4", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-native-certs" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a88d6d420651b496bdd98684116959239430022a115c1240e6c3993be0b15fba" +dependencies = [ + "openssl-probe", + "rustls-pemfile 2.1.2", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64 0.21.7", +] + [[package]] name = "rustls-pemfile" version = "2.1.2" @@ -1730,6 +2290,15 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +[[package]] +name = "schannel" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -1808,6 +2377,29 @@ dependencies = [ "cc", ] +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "1.0.18" @@ -1860,6 +2452,45 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_with" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678b5a069e50bf00ecd22d0cd8ddf7c236f68581b03db652061ed5eb13a312ff" +dependencies = [ + "serde", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.9", + "digest 0.10.7", +] + +[[package]] +name = "sha1_smol" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d" + [[package]] name = "sha2" version = "0.9.9" @@ -1884,12 +2515,39 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + [[package]] name = "siphasher" version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + [[package]] name = "sled" version = "0.34.7" @@ -1903,7 +2561,7 @@ dependencies = [ "fxhash", "libc", "log", - "parking_lot", + "parking_lot 0.11.2", ] [[package]] @@ -1918,6 +2576,16 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" +[[package]] +name = "socket2" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "socket2" version = "0.5.7" @@ -1997,6 +2665,32 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "testcontainers" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83d2931d7f521af5bae989f716c3fa43a6af9af7ec7a5e21b59ae40878cec00" +dependencies = [ + "bollard-stubs", + "futures", + "hex", + "hmac 0.12.1", + "log", + "rand", + "serde", + "serde_json", + "sha2 0.10.8", +] + +[[package]] +name = "testcontainers-modules" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47c405c3757803e54818eaaf6b5b2af485dff4ab89a7130b72f62fd19b8bb6cd" +dependencies = [ + "testcontainers", +] + [[package]] name = "textwrap" version = "0.16.0" @@ -2026,6 +2720,35 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "time" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +dependencies = [ + "deranged", + "num-conv", + "powerfmt", + "serde", + "time-core", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + [[package]] name = "tinyvec" version = "1.6.0" @@ -2051,8 +2774,11 @@ dependencies = [ "bytes", "libc", "mio", + "num_cpus", + "parking_lot 0.12.3", "pin-project-lite", - "socket2", + "signal-hook-registry", + "socket2 0.5.7", "tokio-macros", "windows-sys 0.48.0", ] @@ -2068,6 +2794,16 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "tokio-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +dependencies = [ + "rustls 0.21.7", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.25.0" @@ -2079,6 +2815,31 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-tungstenite" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite", +] + +[[package]] +name = "tokio-util" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + [[package]] name = "toml" version = "0.5.11" @@ -2122,9 +2883,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "tracing-core" version = "0.1.32" @@ -2132,6 +2905,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", ] [[package]] @@ -2140,6 +2943,25 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "tungstenite" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http 1.1.0", + "httparse", + "log", + "rand", + "sha1", + "thiserror", + "url", + "utf-8", +] + [[package]] name = "typenum" version = "1.17.0" @@ -2370,12 +3192,24 @@ dependencies = [ "serde", ] +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + [[package]] name = "utf8parse" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "version_check" version = "0.9.4" @@ -2698,6 +3532,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "yasna" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" +dependencies = [ + "time", +] + [[package]] name = "zeroize" version = "1.7.0" diff --git a/Cargo.toml b/Cargo.toml index af0b496..15c6fcf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "payjoin_ffi" -version = "0.18.0" +version = "0.20.0" license = "MIT OR Apache-2.0" edition = "2021" exclude = ["tests"] @@ -14,22 +14,20 @@ uniffi = { version = "0.28.0", features = ["build"] } [dev-dependencies] uniffi = { version = "0.28.0", features = ["bindgen-tests"] } -bdk = { version = "0.29.0", features = [ - "all-keys", - "use-esplora-ureq", - "keys-bip39", -] } +bdk = { version = "0.29.0", features = ["all-keys", "use-esplora-ureq", "keys-bip39"] } bitcoincore-rpc = "0.19.0" +http = "1" +payjoin-directory = { git = "https://github.com/payjoin/rust-payjoin", features = ["danger-local-https"] } +ohttp-relay = "0.0.8" +rcgen = { version = "0.11" } +reqwest = { version = "0.12", default-features = false, features = ["rustls-tls"] } +rustls = "0.22.2" +testcontainers = "0.15.0" +testcontainers-modules = { version = "0.1.3", features = ["redis"] } +tokio = { version = "1.12.0", features = ["full"] } [dependencies] -#payjoin = {version = "=0.18.0", features = ["send", "receive", "base64", "v2", "io"] } -payjoin = { git = "https://github.com/payjoin/rust-payjoin", rev = "941a6798f52f60d72061fc0a02b5b42146321453", features = [ - "send", - "receive", - "base64", - "v2", - "io", -] } +payjoin = {version = "=0.20.0", features = ["send", "receive", "base64", "v2", "io"] } uniffi = { version = "0.28.0" } thiserror = "1.0.47" ohttp = { version = "0.5.1" } diff --git a/README.md b/README.md index 59729fe..d3c062e 100644 --- a/README.md +++ b/README.md @@ -63,16 +63,19 @@ The integration tests illustrates and verify integration using bitcoin core and ```shell # Run the integration test -cargo test --package payjoin_ffi --test bitcoin_core_integration v1_to_v1_full_cycle -cargo test --package payjoin_ffi --test bdk_integration v1_to_v1_full_cycle +cargo test --package payjoin_ffi --test bitcoin_core_integration_test v1_to_v1_full_cycle +cargo test --package payjoin_ffi --test bdk_integration_test v1_to_v1_full_cycle +cargo test --package payjoin_ffi --test bdk_integration_test v2_to_v2_full_cycle --features enable-danger-local-https -``` +``` +## References -## 🚨 Warning 🚨 +[Payjoin Dev Kit](https://payjoindevkit.org/) -The main branch of this repository is still under development and is incomplete. +[mozilla/uniffi-rs](https://github.com/mozilla/uniffi-rs) -[Payjoin Dev Kit]: https://payjoindevkit.org/ +## Release Status and Disclaimer -[mozilla/uniffi-rs]: https://github.com/mozilla/uniffi-rs +This project is in active development and currently in its Alpha stage. **Please proceed with caution**, particularly when using real funds. +We encourage thorough review, testing, and contributions to help improve its stability and security before considering production use. diff --git a/python/CHANGELOG.md b/python/CHANGELOG.md new file mode 100644 index 0000000..03e2ba2 --- /dev/null +++ b/python/CHANGELOG.md @@ -0,0 +1,44 @@ +## [0.20.0] +#### APIs added +- Make backwards-compatible `v2` to `v1` sends possible. +#### APIs changed +- Removed `contribute_non_nitness_input` from `v1` & `v2`. +- Allow receivers to make `payjoins` out of sweep transactions ([#259](https://github.com/payjoin/rust-payjoin/pull/259)). +- Encode &ohttp= and &exp= parameters in the &pj= URL as a fragment instead of as URI params ([#298](https://github.com/payjoin/rust-payjoin/pull/298)) + +## [0.18.0] +This release updates the python library to `payjoin` version `0.18.0`. +### Features & Modules +#### Send module +- ##### V1 + - `RequestBuilder` exposes `from_psbt_and_uri`, `build_with_additional_fee`, `build_recommended`, `build_non_incentivizing`, + `always_disable_output_substitution`. + - `RequestContext` exposes `extract_contextV1` & `extract_contextV2`. + - `ContextV1` exposes `process_response`. +- ##### V2 + - `ContextV2` exposes `process_response`. +#### Receive module +- ##### V1 + - `UncheckedProposal` exposes `from_request`, `extract_tx_to_schedule_broadcast`, `check_broadcast_suitability`, `build_non_incentivizing`, + `assume_interactive_receiver` & `always_disable_output_substitution`. + - `MaybeInputsOwned` exposes `check_inputs_not_owned`. + - `MaybeMixedInputScripts` exposes `check_no_mixed_input_scripts`. + - `MaybeInputsSeen` exposes `check_no_inputs_seen_before`. + - `OutputsUnknown` exposes `identify_receiver_outputs`. + - `ProvisionalProposal` exposes `try_substitute_receiver_output`, `contribute_non_witness_input`, `contribute_witness_input`, `try_preserving_privacy` & + `finalize_proposal`. + - `PayjoinProposal` exposes `is_output_substitution_disabled`, `owned_vouts`, `psbt` & `utxos_to_be_locked`. +- ##### V2 + - `SessionInitializer` exposes `from_directory_config`, `process_res` & `extract_request`. + - `ActiveSession` exposes `extract_request`, `process_res`, `pj_uri_builder` & `pj_url`. + - `V2UncheckedProposal` exposes `extract_tx_to_schedule_broadcast`, `check_broadcast_suitability` & `assume_interactive_receiver`. + - `V2MaybeInputsOwned` exposes `check_inputs_not_owned`. + - `V2MaybeMixedInputScripts` exposes `check_no_mixed_input_scripts`. + - `V2MaybeInputsSeen` exposes `check_no_inputs_seen_before`. + - `V2OutputsUnknown` exposes `identify_receiver_outputs`. + - `V2ProvisionalProposal` exposes `try_substitute_receiver_output`, `contribute_non_witness_input`, `contribute_witness_input`, `try_preserving_privacy` & + `finalize_proposal`. + - `V2PayjoinProposal` exposes `process_res`, `extract_v1_req`, `extract_v2_req`, `is_output_substitution_disabled`, `owned_vouts`, `psbt` & + `utxos_to_be_locked`. +#### io module +- Exposed `fetch_ohttp_keys()` to fetch the `ohttp` keys from the specified `payjoin` directory. \ No newline at end of file diff --git a/python/README.md b/python/README.md index 1a9ae83..05b70d3 100644 --- a/python/README.md +++ b/python/README.md @@ -37,23 +37,6 @@ python -m unittest --verbose test/payjoin_unit_test.py Before diving into the integration test, you'll need to set up Bitcoin Core on the regtest network. If you don't have Bitcoin Core installed locally, check out [this installation guide](https://learn.saylor.org/mod/page/view.php?id=36347). Alternatively, you can use `Nigiri Bitcoin`, a tool designed to streamline the process of running local instances of Bitcoin and Liquid networks for development and testing. Follow the instructions [here](https://github.com/vulpemventures/nigiri) to install it on your machine. -Once Nigiri Bitcoin is up and running, replace the following snippet in `payjoin_integration_test.py` with your `Nigiri Bitcoin` Core credentials: - -``` -rpc_user = "bitcoin" -rpc_password = "bitcoin" - -``` - -By default, these credentials are: - -``` -rpc_user = "admin1" -rpc_password = "123" -rpc_host = "localhost" -rpc_port = "18443" - -``` Now, proceed with the integration test: ```shell diff --git a/python/scripts/generate_linux.sh b/python/scripts/generate_linux.sh index bfb6d9d..5c627f8 100644 --- a/python/scripts/generate_linux.sh +++ b/python/scripts/generate_linux.sh @@ -1,11 +1,9 @@ #!/usr/bin/env bash - set -euo pipefail python3 --version pip install --user -r requirements.txt - LIBNAME=libpayjoin_ffi.so - +LINUX_TARGET=x86_64-unknown-linux-gnu echo "Generating payjoin_ffi.py..." cd ../ @@ -13,8 +11,8 @@ cargo run --bin uniffi-bindgen generate src/payjoin_ffi.udl --language python -- echo "Generating native binaries..." -rustup target add x86_64-unknown-linux-gnu -cargo build --profile release-smaller --target x86_64-unknown-linux-gnu --features uniffi +rustup target add $LINUX_TARGET +cargo build --profile release-smaller --target $LINUX_TARGET --features uniffi echo "Copying linux payjoin_ffi.so" cp target/$LINUX_TARGET/release-smaller/$LIBNAME python/src/payjoin/$LIBNAME diff --git a/python/scripts/generate_windows.sh b/python/scripts/generate_windows.sh index 0dab44e..57ffa26 100644 --- a/python/scripts/generate_windows.sh +++ b/python/scripts/generate_windows.sh @@ -1,19 +1,17 @@ #!/usr/bin/env bash - set -euo pipefail python3 --version pip install --user -r requirements.txt - LIBNAME=payjoin_ffi.dll - +WINDOWS_TARGET=x86_64-pc-windows-gnu echo "Generating payjoin_ffi.py..." cd ../ cargo run --bin uniffi-bindgen generate src/payjoin_ffi.udl --language python --out-dir python/src/payjoin/ echo "Generating native binaries..." -rustup target add x86_64-pc-windows-gnu -cargo build --profile release-smaller --target x86_64-pc-windows-gnu --features uniffi +rustup target add $WINDOWS_TARGET +cargo build --profile release-smaller --target $WINDOWS_TARGET --features uniffi echo "Copying windows payjoin_ffi.dll" cp target/$WINDOWS_TARGET/release-smaller/$LIBNAME python/src/payjoin/$LIBNAME diff --git a/python/setup.py b/python/setup.py index ea43193..1da861a 100644 --- a/python/setup.py +++ b/python/setup.py @@ -17,7 +17,7 @@ """ setup( - name='payjoin', + name="payjoin", description="The Python language bindings for the Payjoin Dev Kit", long_description=LONG_DESCRIPTION, long_description_content_type="text/markdown", @@ -25,7 +25,7 @@ zip_safe=False, packages=["payjoin"], package_dir={"payjoin": "./src/payjoin"}, - version='0.13.dev.0', + version="0.20.0", license="MIT or Apache 2.0", has_ext_modules=lambda: True, ) diff --git a/python/src/payjoin/libpayjoin_ffi.dylib b/python/src/payjoin/libpayjoin_ffi.dylib index 278dac8..2f33a7f 100755 Binary files a/python/src/payjoin/libpayjoin_ffi.dylib and b/python/src/payjoin/libpayjoin_ffi.dylib differ diff --git a/python/src/payjoin/libpayjoin_ffi.so b/python/src/payjoin/libpayjoin_ffi.so index 94e2ed8..bb3cc44 100755 Binary files a/python/src/payjoin/libpayjoin_ffi.so and b/python/src/payjoin/libpayjoin_ffi.so differ diff --git a/python/src/payjoin/payjoin_ffi.dll b/python/src/payjoin/payjoin_ffi.dll index 7135d7e..f38176b 100755 Binary files a/python/src/payjoin/payjoin_ffi.dll and b/python/src/payjoin/payjoin_ffi.dll differ diff --git a/python/src/payjoin/payjoin_ffi.py b/python/src/payjoin/payjoin_ffi.py index 88a69a3..09075af 100644 --- a/python/src/payjoin/payjoin_ffi.py +++ b/python/src/payjoin/payjoin_ffi.py @@ -30,7 +30,7 @@ import platform # Used for default argument values -_DEFAULT = object() +_DEFAULT = object() # type: typing.Any class _UniffiRustBuffer(ctypes.Structure): @@ -46,14 +46,14 @@ def default(): @staticmethod def alloc(size): - return _rust_call(_UniffiLib.ffi_payjoin_ffi_rustbuffer_alloc, size) + return _uniffi_rust_call(_UniffiLib.ffi_payjoin_ffi_rustbuffer_alloc, size) @staticmethod def reserve(rbuf, additional): - return _rust_call(_UniffiLib.ffi_payjoin_ffi_rustbuffer_reserve, rbuf, additional) + return _uniffi_rust_call(_UniffiLib.ffi_payjoin_ffi_rustbuffer_reserve, rbuf, additional) def free(self): - return _rust_call(_UniffiLib.ffi_payjoin_ffi_rustbuffer_free, self) + return _uniffi_rust_call(_UniffiLib.ffi_payjoin_ffi_rustbuffer_free, self) def __str__(self): return "_UniffiRustBuffer(capacity={}, len={}, data={})".format( @@ -278,11 +278,11 @@ def __str__(self): else: return "_UniffiRustCallStatus()" -def _rust_call(fn, *args): +def _uniffi_rust_call(fn, *args): # Call a rust function - return _rust_call_with_error(None, fn, *args) + return _uniffi_rust_call_with_error(None, fn, *args) -def _rust_call_with_error(error_ffi_converter, fn, *args): +def _uniffi_rust_call_with_error(error_ffi_converter, fn, *args): # Call a rust function and handle any errors # # This function is used for rust calls that return Result<> and therefore can set the CALL_ERROR status code. @@ -300,7 +300,7 @@ def _uniffi_check_call_status(error_ffi_converter, call_status): elif call_status.code == _UniffiRustCallStatus.CALL_ERROR: if error_ffi_converter is None: call_status.error_buf.free() - raise InternalError("_rust_call_with_error: CALL_ERROR, but error_ffi_converter is None") + raise InternalError("_uniffi_rust_call_with_error: CALL_ERROR, but error_ffi_converter is None") else: raise error_ffi_converter.lift(call_status.error_buf) elif call_status.code == _UniffiRustCallStatus.CALL_UNEXPECTED_ERROR: @@ -355,14 +355,14 @@ def get(self, handle): with self._lock: return self._map[handle] except KeyError: - raise InternalError("UniffiHandleMap.get: Invalid handle") + raise InternalError("_UniffiHandleMap.get: Invalid handle") def remove(self, handle): try: with self._lock: return self._map.pop(handle) except KeyError: - raise InternalError("UniffiHandleMap.remove: Invalid handle") + raise InternalError("_UniffiHandleMap.remove: Invalid handle") def __len__(self): return len(self._map) @@ -460,19 +460,19 @@ def _uniffi_check_contract_api_version(lib): raise InternalError("UniFFI contract version mismatch: try cleaning and rebuilding your project") def _uniffi_check_api_checksums(lib): - if lib.uniffi_payjoin_ffi_checksum_method_contextv1_process_response() != 62276: + if lib.uniffi_payjoin_ffi_checksum_method_activesession_extract_req() != 42189: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_payjoin_ffi_checksum_method_contextv2_process_response() != 16327: + if lib.uniffi_payjoin_ffi_checksum_method_activesession_pj_uri_builder() != 6882: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_payjoin_ffi_checksum_method_enrolled_extract_req() != 58529: + if lib.uniffi_payjoin_ffi_checksum_method_activesession_pj_url() != 41021: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_payjoin_ffi_checksum_method_enrolled_fallback_target() != 1788: + if lib.uniffi_payjoin_ffi_checksum_method_activesession_process_res() != 52549: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_payjoin_ffi_checksum_method_enrolled_process_res() != 61918: + if lib.uniffi_payjoin_ffi_checksum_method_activesession_public_key() != 56528: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_payjoin_ffi_checksum_method_enroller_extract_req() != 17758: + if lib.uniffi_payjoin_ffi_checksum_method_contextv1_process_response() != 62276: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_payjoin_ffi_checksum_method_enroller_process_res() != 22088: + if lib.uniffi_payjoin_ffi_checksum_method_contextv2_process_response() != 16327: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_headers_get_map() != 7889: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") @@ -492,19 +492,33 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_payjoinproposal_utxos_to_be_locked() != 62799: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_payjoin_ffi_checksum_method_provisionalproposal_contribute_non_witness_input() != 9161: + if lib.uniffi_payjoin_ffi_checksum_method_pjuri_address() != 42104: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_payjoin_ffi_checksum_method_pjuri_amount() != 7807: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_payjoin_ffi_checksum_method_pjuri_as_string() != 55733: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_payjoin_ffi_checksum_method_pjuribuilder_amount() != 47662: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_payjoin_ffi_checksum_method_pjuribuilder_build() != 16591: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_payjoin_ffi_checksum_method_pjuribuilder_label() != 52425: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_payjoin_ffi_checksum_method_pjuribuilder_message() != 7896: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_payjoin_ffi_checksum_method_pjuribuilder_pjos() != 46879: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_provisionalproposal_contribute_witness_input() != 57615: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_provisionalproposal_finalize_proposal() != 32297: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_payjoin_ffi_checksum_method_provisionalproposal_substitute_output_address() != 56103: - raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_provisionalproposal_try_preserving_privacy() != 3109: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_payjoin_ffi_checksum_method_provisionalproposal_try_substitute_receiver_output() != 34999: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_requestbuilder_always_disable_output_substitution() != 46341: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_payjoin_ffi_checksum_method_requestbuilder_build_non_incentivizing() != 38078: + if lib.uniffi_payjoin_ffi_checksum_method_requestbuilder_build_non_incentivizing() != 23473: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_requestbuilder_build_recommended() != 37649: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") @@ -514,6 +528,10 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_requestcontext_extract_v2() != 35928: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_payjoin_ffi_checksum_method_sessioninitializer_extract_req() != 41164: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_payjoin_ffi_checksum_method_sessioninitializer_process_res() != 28070: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_uncheckedproposal_assume_interactive_receiver() != 30907: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_uncheckedproposal_check_broadcast_suitability() != 26022: @@ -524,6 +542,10 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_uri_amount() != 26669: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_payjoin_ffi_checksum_method_uri_as_string() != 45476: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_payjoin_ffi_checksum_method_uri_check_pj_supported() != 58582: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_url_as_string() != 36665: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_url_query() != 37864: @@ -536,39 +558,43 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_v2outputsunknown_identify_receiver_outputs() != 31941: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_deserialize_res() != 21303: + if lib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_extract_v1_req() != 7185: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_extract_v2_req() != 3688: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_is_output_substitution_disabled() != 13037: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_owned_vouts() != 58943: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_process_res() != 12177: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_psbt() != 17219: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_utxos_to_be_locked() != 8312: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_payjoin_ffi_checksum_method_v2provisionalproposal_contribute_non_witness_input() != 8344: - raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_v2provisionalproposal_contribute_witness_input() != 9262: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_v2provisionalproposal_finalize_proposal() != 16888: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_payjoin_ffi_checksum_method_v2provisionalproposal_substitute_output_address() != 20437: - raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_v2provisionalproposal_try_preserving_privacy() != 3228: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_payjoin_ffi_checksum_method_v2provisionalproposal_try_substitute_receiver_output() != 37622: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_v2uncheckedproposal_assume_interactive_receiver() != 23782: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_v2uncheckedproposal_check_broadcast_suitability() != 59984: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_v2uncheckedproposal_extract_tx_to_schedule_broadcast() != 12585: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_payjoin_ffi_checksum_constructor_enroller_from_directory_config() != 24309: - raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_constructor_headers_from_vec() != 55332: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_constructor_ohttpkeys_decode() != 43383: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - if lib.uniffi_payjoin_ffi_checksum_constructor_requestbuilder_from_psbt_and_uri() != 10227: + if lib.uniffi_payjoin_ffi_checksum_constructor_pjuribuilder_new() != 33990: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_payjoin_ffi_checksum_constructor_requestbuilder_from_psbt_and_uri() != 21795: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_payjoin_ffi_checksum_constructor_sessioninitializer_new() != 63778: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_constructor_uncheckedproposal_from_request() != 49662: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") @@ -578,6 +604,8 @@ def _uniffi_check_api_checksums(lib): raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_canbroadcast_callback() != 27867: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + if lib.uniffi_payjoin_ffi_checksum_method_generatescript_callback() != 38507: + raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_isoutputknown_callback() != 1120: raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") if lib.uniffi_payjoin_ffi_checksum_method_isscriptowned_callback() != 32829: @@ -589,237 +617,226 @@ def _uniffi_check_api_checksums(lib): # This is an implementation detail which will be called internally by the public API. _UniffiLib = _uniffi_load_indirect() -UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK = ctypes.CFUNCTYPE(None,ctypes.c_uint64,ctypes.c_int8, +_UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK = ctypes.CFUNCTYPE(None,ctypes.c_uint64,ctypes.c_int8, ) -UNIFFI_FOREIGN_FUTURE_FREE = ctypes.CFUNCTYPE(None,ctypes.c_uint64, +_UNIFFI_FOREIGN_FUTURE_FREE = ctypes.CFUNCTYPE(None,ctypes.c_uint64, ) -UNIFFI_CALLBACK_INTERFACE_FREE = ctypes.CFUNCTYPE(None,ctypes.c_uint64, +_UNIFFI_CALLBACK_INTERFACE_FREE = ctypes.CFUNCTYPE(None,ctypes.c_uint64, ) -class UniffiForeignFuture(ctypes.Structure): +class _UniffiForeignFuture(ctypes.Structure): _fields_ = [ ("handle", ctypes.c_uint64), - ("free", UNIFFI_FOREIGN_FUTURE_FREE), + ("free", _UNIFFI_FOREIGN_FUTURE_FREE), ] -class UniffiForeignFutureStructU8(ctypes.Structure): +class _UniffiForeignFutureStructU8(ctypes.Structure): _fields_ = [ ("return_value", ctypes.c_uint8), ("call_status", _UniffiRustCallStatus), ] -UNIFFI_FOREIGN_FUTURE_COMPLETE_U8 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,UniffiForeignFutureStructU8, +_UNIFFI_FOREIGN_FUTURE_COMPLETE_U8 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructU8, ) -class UniffiForeignFutureStructI8(ctypes.Structure): +class _UniffiForeignFutureStructI8(ctypes.Structure): _fields_ = [ ("return_value", ctypes.c_int8), ("call_status", _UniffiRustCallStatus), ] -UNIFFI_FOREIGN_FUTURE_COMPLETE_I8 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,UniffiForeignFutureStructI8, +_UNIFFI_FOREIGN_FUTURE_COMPLETE_I8 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructI8, ) -class UniffiForeignFutureStructU16(ctypes.Structure): +class _UniffiForeignFutureStructU16(ctypes.Structure): _fields_ = [ ("return_value", ctypes.c_uint16), ("call_status", _UniffiRustCallStatus), ] -UNIFFI_FOREIGN_FUTURE_COMPLETE_U16 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,UniffiForeignFutureStructU16, +_UNIFFI_FOREIGN_FUTURE_COMPLETE_U16 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructU16, ) -class UniffiForeignFutureStructI16(ctypes.Structure): +class _UniffiForeignFutureStructI16(ctypes.Structure): _fields_ = [ ("return_value", ctypes.c_int16), ("call_status", _UniffiRustCallStatus), ] -UNIFFI_FOREIGN_FUTURE_COMPLETE_I16 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,UniffiForeignFutureStructI16, +_UNIFFI_FOREIGN_FUTURE_COMPLETE_I16 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructI16, ) -class UniffiForeignFutureStructU32(ctypes.Structure): +class _UniffiForeignFutureStructU32(ctypes.Structure): _fields_ = [ ("return_value", ctypes.c_uint32), ("call_status", _UniffiRustCallStatus), ] -UNIFFI_FOREIGN_FUTURE_COMPLETE_U32 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,UniffiForeignFutureStructU32, +_UNIFFI_FOREIGN_FUTURE_COMPLETE_U32 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructU32, ) -class UniffiForeignFutureStructI32(ctypes.Structure): +class _UniffiForeignFutureStructI32(ctypes.Structure): _fields_ = [ ("return_value", ctypes.c_int32), ("call_status", _UniffiRustCallStatus), ] -UNIFFI_FOREIGN_FUTURE_COMPLETE_I32 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,UniffiForeignFutureStructI32, +_UNIFFI_FOREIGN_FUTURE_COMPLETE_I32 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructI32, ) -class UniffiForeignFutureStructU64(ctypes.Structure): +class _UniffiForeignFutureStructU64(ctypes.Structure): _fields_ = [ ("return_value", ctypes.c_uint64), ("call_status", _UniffiRustCallStatus), ] -UNIFFI_FOREIGN_FUTURE_COMPLETE_U64 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,UniffiForeignFutureStructU64, +_UNIFFI_FOREIGN_FUTURE_COMPLETE_U64 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructU64, ) -class UniffiForeignFutureStructI64(ctypes.Structure): +class _UniffiForeignFutureStructI64(ctypes.Structure): _fields_ = [ ("return_value", ctypes.c_int64), ("call_status", _UniffiRustCallStatus), ] -UNIFFI_FOREIGN_FUTURE_COMPLETE_I64 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,UniffiForeignFutureStructI64, +_UNIFFI_FOREIGN_FUTURE_COMPLETE_I64 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructI64, ) -class UniffiForeignFutureStructF32(ctypes.Structure): +class _UniffiForeignFutureStructF32(ctypes.Structure): _fields_ = [ ("return_value", ctypes.c_float), ("call_status", _UniffiRustCallStatus), ] -UNIFFI_FOREIGN_FUTURE_COMPLETE_F32 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,UniffiForeignFutureStructF32, +_UNIFFI_FOREIGN_FUTURE_COMPLETE_F32 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructF32, ) -class UniffiForeignFutureStructF64(ctypes.Structure): +class _UniffiForeignFutureStructF64(ctypes.Structure): _fields_ = [ ("return_value", ctypes.c_double), ("call_status", _UniffiRustCallStatus), ] -UNIFFI_FOREIGN_FUTURE_COMPLETE_F64 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,UniffiForeignFutureStructF64, +_UNIFFI_FOREIGN_FUTURE_COMPLETE_F64 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructF64, ) -class UniffiForeignFutureStructPointer(ctypes.Structure): +class _UniffiForeignFutureStructPointer(ctypes.Structure): _fields_ = [ ("return_value", ctypes.c_void_p), ("call_status", _UniffiRustCallStatus), ] -UNIFFI_FOREIGN_FUTURE_COMPLETE_POINTER = ctypes.CFUNCTYPE(None,ctypes.c_uint64,UniffiForeignFutureStructPointer, +_UNIFFI_FOREIGN_FUTURE_COMPLETE_POINTER = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructPointer, ) -class UniffiForeignFutureStructRustBuffer(ctypes.Structure): +class _UniffiForeignFutureStructRustBuffer(ctypes.Structure): _fields_ = [ ("return_value", _UniffiRustBuffer), ("call_status", _UniffiRustCallStatus), ] -UNIFFI_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER = ctypes.CFUNCTYPE(None,ctypes.c_uint64,UniffiForeignFutureStructRustBuffer, +_UNIFFI_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructRustBuffer, ) -class UniffiForeignFutureStructVoid(ctypes.Structure): +class _UniffiForeignFutureStructVoid(ctypes.Structure): _fields_ = [ ("call_status", _UniffiRustCallStatus), ] -UNIFFI_FOREIGN_FUTURE_COMPLETE_VOID = ctypes.CFUNCTYPE(None,ctypes.c_uint64,UniffiForeignFutureStructVoid, +_UNIFFI_FOREIGN_FUTURE_COMPLETE_VOID = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructVoid, +) +_UNIFFI_CALLBACK_INTERFACE_CAN_BROADCAST_METHOD0 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.POINTER(ctypes.c_int8), + ctypes.POINTER(_UniffiRustCallStatus), ) -UNIFFI_CALLBACK_INTERFACE_CAN_BROADCAST_METHOD0 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.POINTER(ctypes.c_int8), +_UNIFFI_CALLBACK_INTERFACE_GENERATE_SCRIPT_METHOD0 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,ctypes.POINTER(_UniffiRustBuffer), ctypes.POINTER(_UniffiRustCallStatus), ) -UNIFFI_CALLBACK_INTERFACE_IS_OUTPUT_KNOWN_METHOD0 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.POINTER(ctypes.c_int8), +_UNIFFI_CALLBACK_INTERFACE_IS_OUTPUT_KNOWN_METHOD0 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.POINTER(ctypes.c_int8), ctypes.POINTER(_UniffiRustCallStatus), ) -UNIFFI_CALLBACK_INTERFACE_IS_SCRIPT_OWNED_METHOD0 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.POINTER(ctypes.c_int8), +_UNIFFI_CALLBACK_INTERFACE_IS_SCRIPT_OWNED_METHOD0 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.POINTER(ctypes.c_int8), ctypes.POINTER(_UniffiRustCallStatus), ) -UNIFFI_CALLBACK_INTERFACE_PROCESS_PARTIALLY_SIGNED_TRANSACTION_METHOD0 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.POINTER(_UniffiRustBuffer), +_UNIFFI_CALLBACK_INTERFACE_PROCESS_PARTIALLY_SIGNED_TRANSACTION_METHOD0 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,ctypes.POINTER(_UniffiRustBuffer), ctypes.POINTER(_UniffiRustCallStatus), ) -class UniffiVTableCallbackInterfaceCanBroadcast(ctypes.Structure): +class _UniffiVTableCallbackInterfaceCanBroadcast(ctypes.Structure): _fields_ = [ - ("callback", UNIFFI_CALLBACK_INTERFACE_CAN_BROADCAST_METHOD0), - ("uniffi_free", UNIFFI_CALLBACK_INTERFACE_FREE), + ("callback", _UNIFFI_CALLBACK_INTERFACE_CAN_BROADCAST_METHOD0), + ("uniffi_free", _UNIFFI_CALLBACK_INTERFACE_FREE), ] -class UniffiVTableCallbackInterfaceIsOutputKnown(ctypes.Structure): +class _UniffiVTableCallbackInterfaceGenerateScript(ctypes.Structure): _fields_ = [ - ("callback", UNIFFI_CALLBACK_INTERFACE_IS_OUTPUT_KNOWN_METHOD0), - ("uniffi_free", UNIFFI_CALLBACK_INTERFACE_FREE), + ("callback", _UNIFFI_CALLBACK_INTERFACE_GENERATE_SCRIPT_METHOD0), + ("uniffi_free", _UNIFFI_CALLBACK_INTERFACE_FREE), ] -class UniffiVTableCallbackInterfaceIsScriptOwned(ctypes.Structure): +class _UniffiVTableCallbackInterfaceIsOutputKnown(ctypes.Structure): _fields_ = [ - ("callback", UNIFFI_CALLBACK_INTERFACE_IS_SCRIPT_OWNED_METHOD0), - ("uniffi_free", UNIFFI_CALLBACK_INTERFACE_FREE), + ("callback", _UNIFFI_CALLBACK_INTERFACE_IS_OUTPUT_KNOWN_METHOD0), + ("uniffi_free", _UNIFFI_CALLBACK_INTERFACE_FREE), ] -class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Structure): +class _UniffiVTableCallbackInterfaceIsScriptOwned(ctypes.Structure): _fields_ = [ - ("callback", UNIFFI_CALLBACK_INTERFACE_PROCESS_PARTIALLY_SIGNED_TRANSACTION_METHOD0), - ("uniffi_free", UNIFFI_CALLBACK_INTERFACE_FREE), + ("callback", _UNIFFI_CALLBACK_INTERFACE_IS_SCRIPT_OWNED_METHOD0), + ("uniffi_free", _UNIFFI_CALLBACK_INTERFACE_FREE), ] -_UniffiLib.uniffi_payjoin_ffi_fn_clone_clientresponse.argtypes = ( - ctypes.c_void_p, - ctypes.POINTER(_UniffiRustCallStatus), -) -_UniffiLib.uniffi_payjoin_ffi_fn_clone_clientresponse.restype = ctypes.c_void_p -_UniffiLib.uniffi_payjoin_ffi_fn_free_clientresponse.argtypes = ( - ctypes.c_void_p, - ctypes.POINTER(_UniffiRustCallStatus), -) -_UniffiLib.uniffi_payjoin_ffi_fn_free_clientresponse.restype = None -_UniffiLib.uniffi_payjoin_ffi_fn_clone_contextv1.argtypes = ( +class _UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Structure): + _fields_ = [ + ("callback", _UNIFFI_CALLBACK_INTERFACE_PROCESS_PARTIALLY_SIGNED_TRANSACTION_METHOD0), + ("uniffi_free", _UNIFFI_CALLBACK_INTERFACE_FREE), + ] +_UniffiLib.uniffi_payjoin_ffi_fn_clone_activesession.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_payjoin_ffi_fn_clone_contextv1.restype = ctypes.c_void_p -_UniffiLib.uniffi_payjoin_ffi_fn_free_contextv1.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_fn_clone_activesession.restype = ctypes.c_void_p +_UniffiLib.uniffi_payjoin_ffi_fn_free_activesession.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_payjoin_ffi_fn_free_contextv1.restype = None -_UniffiLib.uniffi_payjoin_ffi_fn_method_contextv1_process_response.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_fn_free_activesession.restype = None +_UniffiLib.uniffi_payjoin_ffi_fn_method_activesession_extract_req.argtypes = ( ctypes.c_void_p, - _UniffiRustBuffer, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_payjoin_ffi_fn_method_contextv1_process_response.restype = _UniffiRustBuffer -_UniffiLib.uniffi_payjoin_ffi_fn_clone_contextv2.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_fn_method_activesession_extract_req.restype = _UniffiRustBuffer +_UniffiLib.uniffi_payjoin_ffi_fn_method_activesession_pj_uri_builder.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_payjoin_ffi_fn_clone_contextv2.restype = ctypes.c_void_p -_UniffiLib.uniffi_payjoin_ffi_fn_free_contextv2.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_fn_method_activesession_pj_uri_builder.restype = ctypes.c_void_p +_UniffiLib.uniffi_payjoin_ffi_fn_method_activesession_pj_url.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_payjoin_ffi_fn_free_contextv2.restype = None -_UniffiLib.uniffi_payjoin_ffi_fn_method_contextv2_process_response.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_fn_method_activesession_pj_url.restype = ctypes.c_void_p +_UniffiLib.uniffi_payjoin_ffi_fn_method_activesession_process_res.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, - ctypes.POINTER(_UniffiRustCallStatus), -) -_UniffiLib.uniffi_payjoin_ffi_fn_method_contextv2_process_response.restype = _UniffiRustBuffer -_UniffiLib.uniffi_payjoin_ffi_fn_clone_enrolled.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_payjoin_ffi_fn_clone_enrolled.restype = ctypes.c_void_p -_UniffiLib.uniffi_payjoin_ffi_fn_free_enrolled.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_fn_method_activesession_process_res.restype = _UniffiRustBuffer +_UniffiLib.uniffi_payjoin_ffi_fn_method_activesession_public_key.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_payjoin_ffi_fn_free_enrolled.restype = None -_UniffiLib.uniffi_payjoin_ffi_fn_method_enrolled_extract_req.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_fn_method_activesession_public_key.restype = _UniffiRustBuffer +_UniffiLib.uniffi_payjoin_ffi_fn_clone_clientresponse.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_payjoin_ffi_fn_method_enrolled_extract_req.restype = _UniffiRustBuffer -_UniffiLib.uniffi_payjoin_ffi_fn_method_enrolled_fallback_target.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_fn_clone_clientresponse.restype = ctypes.c_void_p +_UniffiLib.uniffi_payjoin_ffi_fn_free_clientresponse.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_payjoin_ffi_fn_method_enrolled_fallback_target.restype = _UniffiRustBuffer -_UniffiLib.uniffi_payjoin_ffi_fn_method_enrolled_process_res.argtypes = ( - ctypes.c_void_p, - _UniffiRustBuffer, +_UniffiLib.uniffi_payjoin_ffi_fn_free_clientresponse.restype = None +_UniffiLib.uniffi_payjoin_ffi_fn_clone_contextv1.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_payjoin_ffi_fn_method_enrolled_process_res.restype = _UniffiRustBuffer -_UniffiLib.uniffi_payjoin_ffi_fn_clone_enroller.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_fn_clone_contextv1.restype = ctypes.c_void_p +_UniffiLib.uniffi_payjoin_ffi_fn_free_contextv1.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_payjoin_ffi_fn_clone_enroller.restype = ctypes.c_void_p -_UniffiLib.uniffi_payjoin_ffi_fn_free_enroller.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_fn_free_contextv1.restype = None +_UniffiLib.uniffi_payjoin_ffi_fn_method_contextv1_process_response.argtypes = ( ctypes.c_void_p, + _UniffiRustBuffer, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_payjoin_ffi_fn_free_enroller.restype = None -_UniffiLib.uniffi_payjoin_ffi_fn_constructor_enroller_from_directory_config.argtypes = ( - ctypes.c_void_p, - ctypes.c_void_p, +_UniffiLib.uniffi_payjoin_ffi_fn_method_contextv1_process_response.restype = _UniffiRustBuffer +_UniffiLib.uniffi_payjoin_ffi_fn_clone_contextv2.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_payjoin_ffi_fn_constructor_enroller_from_directory_config.restype = ctypes.c_void_p -_UniffiLib.uniffi_payjoin_ffi_fn_method_enroller_extract_req.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_fn_clone_contextv2.restype = ctypes.c_void_p +_UniffiLib.uniffi_payjoin_ffi_fn_free_contextv2.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_payjoin_ffi_fn_method_enroller_extract_req.restype = _UniffiRustBuffer -_UniffiLib.uniffi_payjoin_ffi_fn_method_enroller_process_res.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_fn_free_contextv2.restype = None +_UniffiLib.uniffi_payjoin_ffi_fn_method_contextv2_process_response.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, - ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_payjoin_ffi_fn_method_enroller_process_res.restype = ctypes.c_void_p +_UniffiLib.uniffi_payjoin_ffi_fn_method_contextv2_process_response.restype = _UniffiRustBuffer _UniffiLib.uniffi_payjoin_ffi_fn_clone_headers.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), @@ -958,23 +975,78 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_payjoin_ffi_fn_free_pjuri.restype = None -_UniffiLib.uniffi_payjoin_ffi_fn_clone_provisionalproposal.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuri_address.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_payjoin_ffi_fn_clone_provisionalproposal.restype = ctypes.c_void_p -_UniffiLib.uniffi_payjoin_ffi_fn_free_provisionalproposal.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuri_address.restype = _UniffiRustBuffer +_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuri_amount.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_payjoin_ffi_fn_free_provisionalproposal.restype = None -_UniffiLib.uniffi_payjoin_ffi_fn_method_provisionalproposal_contribute_non_witness_input.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuri_amount.restype = _UniffiRustBuffer +_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuri_as_string.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuri_as_string.restype = _UniffiRustBuffer +_UniffiLib.uniffi_payjoin_ffi_fn_clone_pjuribuilder.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_payjoin_ffi_fn_clone_pjuribuilder.restype = ctypes.c_void_p +_UniffiLib.uniffi_payjoin_ffi_fn_free_pjuribuilder.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_payjoin_ffi_fn_free_pjuribuilder.restype = None +_UniffiLib.uniffi_payjoin_ffi_fn_constructor_pjuribuilder_new.argtypes = ( + _UniffiRustBuffer, + ctypes.c_void_p, + _UniffiRustBuffer, + _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_payjoin_ffi_fn_constructor_pjuribuilder_new.restype = ctypes.c_void_p +_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuribuilder_amount.argtypes = ( + ctypes.c_void_p, + ctypes.c_uint64, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuribuilder_amount.restype = ctypes.c_void_p +_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuribuilder_build.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuribuilder_build.restype = ctypes.c_void_p +_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuribuilder_label.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuribuilder_label.restype = ctypes.c_void_p +_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuribuilder_message.argtypes = ( + ctypes.c_void_p, _UniffiRustBuffer, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_payjoin_ffi_fn_method_provisionalproposal_contribute_non_witness_input.restype = None +_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuribuilder_message.restype = ctypes.c_void_p +_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuribuilder_pjos.argtypes = ( + ctypes.c_void_p, + ctypes.c_int8, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuribuilder_pjos.restype = ctypes.c_void_p +_UniffiLib.uniffi_payjoin_ffi_fn_clone_provisionalproposal.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_payjoin_ffi_fn_clone_provisionalproposal.restype = ctypes.c_void_p +_UniffiLib.uniffi_payjoin_ffi_fn_free_provisionalproposal.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_payjoin_ffi_fn_free_provisionalproposal.restype = None _UniffiLib.uniffi_payjoin_ffi_fn_method_provisionalproposal_contribute_witness_input.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, @@ -989,18 +1061,18 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_payjoin_ffi_fn_method_provisionalproposal_finalize_proposal.restype = ctypes.c_void_p -_UniffiLib.uniffi_payjoin_ffi_fn_method_provisionalproposal_substitute_output_address.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_fn_method_provisionalproposal_try_preserving_privacy.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_payjoin_ffi_fn_method_provisionalproposal_substitute_output_address.restype = None -_UniffiLib.uniffi_payjoin_ffi_fn_method_provisionalproposal_try_preserving_privacy.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_fn_method_provisionalproposal_try_preserving_privacy.restype = _UniffiRustBuffer +_UniffiLib.uniffi_payjoin_ffi_fn_method_provisionalproposal_try_substitute_receiver_output.argtypes = ( ctypes.c_void_p, - _UniffiRustBuffer, + ctypes.c_uint64, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_payjoin_ffi_fn_method_provisionalproposal_try_preserving_privacy.restype = _UniffiRustBuffer +_UniffiLib.uniffi_payjoin_ffi_fn_method_provisionalproposal_try_substitute_receiver_output.restype = None _UniffiLib.uniffi_payjoin_ffi_fn_clone_requestbuilder.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), @@ -1025,6 +1097,7 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru _UniffiLib.uniffi_payjoin_ffi_fn_method_requestbuilder_always_disable_output_substitution.restype = ctypes.c_void_p _UniffiLib.uniffi_payjoin_ffi_fn_method_requestbuilder_build_non_incentivizing.argtypes = ( ctypes.c_void_p, + ctypes.c_uint64, ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_payjoin_ffi_fn_method_requestbuilder_build_non_incentivizing.restype = ctypes.c_void_p @@ -1064,6 +1137,38 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_payjoin_ffi_fn_method_requestcontext_extract_v2.restype = _UniffiRustBuffer +_UniffiLib.uniffi_payjoin_ffi_fn_clone_sessioninitializer.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_payjoin_ffi_fn_clone_sessioninitializer.restype = ctypes.c_void_p +_UniffiLib.uniffi_payjoin_ffi_fn_free_sessioninitializer.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_payjoin_ffi_fn_free_sessioninitializer.restype = None +_UniffiLib.uniffi_payjoin_ffi_fn_constructor_sessioninitializer_new.argtypes = ( + _UniffiRustBuffer, + _UniffiRustBuffer, + _UniffiRustBuffer, + ctypes.c_void_p, + ctypes.c_void_p, + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_payjoin_ffi_fn_constructor_sessioninitializer_new.restype = ctypes.c_void_p +_UniffiLib.uniffi_payjoin_ffi_fn_method_sessioninitializer_extract_req.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_payjoin_ffi_fn_method_sessioninitializer_extract_req.restype = _UniffiRustBuffer +_UniffiLib.uniffi_payjoin_ffi_fn_method_sessioninitializer_process_res.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_payjoin_ffi_fn_method_sessioninitializer_process_res.restype = ctypes.c_void_p _UniffiLib.uniffi_payjoin_ffi_fn_clone_uncheckedproposal.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), @@ -1123,6 +1228,16 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_payjoin_ffi_fn_method_uri_amount.restype = _UniffiRustBuffer +_UniffiLib.uniffi_payjoin_ffi_fn_method_uri_as_string.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_payjoin_ffi_fn_method_uri_as_string.restype = _UniffiRustBuffer +_UniffiLib.uniffi_payjoin_ffi_fn_method_uri_check_pj_supported.argtypes = ( + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_payjoin_ffi_fn_method_uri_check_pj_supported.restype = ctypes.c_void_p _UniffiLib.uniffi_payjoin_ffi_fn_clone_url.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), @@ -1221,13 +1336,16 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_payjoin_ffi_fn_free_v2payjoinproposal.restype = None -_UniffiLib.uniffi_payjoin_ffi_fn_method_v2payjoinproposal_deserialize_res.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_fn_method_v2payjoinproposal_extract_v1_req.argtypes = ( ctypes.c_void_p, - _UniffiRustBuffer, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_payjoin_ffi_fn_method_v2payjoinproposal_extract_v1_req.restype = _UniffiRustBuffer +_UniffiLib.uniffi_payjoin_ffi_fn_method_v2payjoinproposal_extract_v2_req.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_payjoin_ffi_fn_method_v2payjoinproposal_deserialize_res.restype = _UniffiRustBuffer +_UniffiLib.uniffi_payjoin_ffi_fn_method_v2payjoinproposal_extract_v2_req.restype = _UniffiRustBuffer _UniffiLib.uniffi_payjoin_ffi_fn_method_v2payjoinproposal_is_output_substitution_disabled.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), @@ -1238,6 +1356,13 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_payjoin_ffi_fn_method_v2payjoinproposal_owned_vouts.restype = _UniffiRustBuffer +_UniffiLib.uniffi_payjoin_ffi_fn_method_v2payjoinproposal_process_res.argtypes = ( + ctypes.c_void_p, + _UniffiRustBuffer, + ctypes.c_void_p, + ctypes.POINTER(_UniffiRustCallStatus), +) +_UniffiLib.uniffi_payjoin_ffi_fn_method_v2payjoinproposal_process_res.restype = None _UniffiLib.uniffi_payjoin_ffi_fn_method_v2payjoinproposal_psbt.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), @@ -1258,13 +1383,6 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_payjoin_ffi_fn_free_v2provisionalproposal.restype = None -_UniffiLib.uniffi_payjoin_ffi_fn_method_v2provisionalproposal_contribute_non_witness_input.argtypes = ( - ctypes.c_void_p, - _UniffiRustBuffer, - _UniffiRustBuffer, - ctypes.POINTER(_UniffiRustCallStatus), -) -_UniffiLib.uniffi_payjoin_ffi_fn_method_v2provisionalproposal_contribute_non_witness_input.restype = None _UniffiLib.uniffi_payjoin_ffi_fn_method_v2provisionalproposal_contribute_witness_input.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, @@ -1279,18 +1397,18 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.uniffi_payjoin_ffi_fn_method_v2provisionalproposal_finalize_proposal.restype = ctypes.c_void_p -_UniffiLib.uniffi_payjoin_ffi_fn_method_v2provisionalproposal_substitute_output_address.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_fn_method_v2provisionalproposal_try_preserving_privacy.argtypes = ( ctypes.c_void_p, _UniffiRustBuffer, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_payjoin_ffi_fn_method_v2provisionalproposal_substitute_output_address.restype = None -_UniffiLib.uniffi_payjoin_ffi_fn_method_v2provisionalproposal_try_preserving_privacy.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_fn_method_v2provisionalproposal_try_preserving_privacy.restype = _UniffiRustBuffer +_UniffiLib.uniffi_payjoin_ffi_fn_method_v2provisionalproposal_try_substitute_receiver_output.argtypes = ( ctypes.c_void_p, - _UniffiRustBuffer, + ctypes.c_uint64, ctypes.POINTER(_UniffiRustCallStatus), ) -_UniffiLib.uniffi_payjoin_ffi_fn_method_v2provisionalproposal_try_preserving_privacy.restype = _UniffiRustBuffer +_UniffiLib.uniffi_payjoin_ffi_fn_method_v2provisionalproposal_try_substitute_receiver_output.restype = None _UniffiLib.uniffi_payjoin_ffi_fn_clone_v2uncheckedproposal.argtypes = ( ctypes.c_void_p, ctypes.POINTER(_UniffiRustCallStatus), @@ -1319,19 +1437,23 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru ) _UniffiLib.uniffi_payjoin_ffi_fn_method_v2uncheckedproposal_extract_tx_to_schedule_broadcast.restype = _UniffiRustBuffer _UniffiLib.uniffi_payjoin_ffi_fn_init_callback_vtable_canbroadcast.argtypes = ( - ctypes.POINTER(UniffiVTableCallbackInterfaceCanBroadcast), + ctypes.POINTER(_UniffiVTableCallbackInterfaceCanBroadcast), ) _UniffiLib.uniffi_payjoin_ffi_fn_init_callback_vtable_canbroadcast.restype = None +_UniffiLib.uniffi_payjoin_ffi_fn_init_callback_vtable_generatescript.argtypes = ( + ctypes.POINTER(_UniffiVTableCallbackInterfaceGenerateScript), +) +_UniffiLib.uniffi_payjoin_ffi_fn_init_callback_vtable_generatescript.restype = None _UniffiLib.uniffi_payjoin_ffi_fn_init_callback_vtable_isoutputknown.argtypes = ( - ctypes.POINTER(UniffiVTableCallbackInterfaceIsOutputKnown), + ctypes.POINTER(_UniffiVTableCallbackInterfaceIsOutputKnown), ) _UniffiLib.uniffi_payjoin_ffi_fn_init_callback_vtable_isoutputknown.restype = None _UniffiLib.uniffi_payjoin_ffi_fn_init_callback_vtable_isscriptowned.argtypes = ( - ctypes.POINTER(UniffiVTableCallbackInterfaceIsScriptOwned), + ctypes.POINTER(_UniffiVTableCallbackInterfaceIsScriptOwned), ) _UniffiLib.uniffi_payjoin_ffi_fn_init_callback_vtable_isscriptowned.restype = None _UniffiLib.uniffi_payjoin_ffi_fn_init_callback_vtable_processpartiallysignedtransaction.argtypes = ( - ctypes.POINTER(UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction), + ctypes.POINTER(_UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction), ) _UniffiLib.uniffi_payjoin_ffi_fn_init_callback_vtable_processpartiallysignedtransaction.restype = None _UniffiLib.ffi_payjoin_ffi_rustbuffer_alloc.argtypes = ( @@ -1357,7 +1479,7 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru _UniffiLib.ffi_payjoin_ffi_rustbuffer_reserve.restype = _UniffiRustBuffer _UniffiLib.ffi_payjoin_ffi_rust_future_poll_u8.argtypes = ( ctypes.c_uint64, - UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, ctypes.c_uint64, ) _UniffiLib.ffi_payjoin_ffi_rust_future_poll_u8.restype = None @@ -1376,7 +1498,7 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru _UniffiLib.ffi_payjoin_ffi_rust_future_complete_u8.restype = ctypes.c_uint8 _UniffiLib.ffi_payjoin_ffi_rust_future_poll_i8.argtypes = ( ctypes.c_uint64, - UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, ctypes.c_uint64, ) _UniffiLib.ffi_payjoin_ffi_rust_future_poll_i8.restype = None @@ -1395,7 +1517,7 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru _UniffiLib.ffi_payjoin_ffi_rust_future_complete_i8.restype = ctypes.c_int8 _UniffiLib.ffi_payjoin_ffi_rust_future_poll_u16.argtypes = ( ctypes.c_uint64, - UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, ctypes.c_uint64, ) _UniffiLib.ffi_payjoin_ffi_rust_future_poll_u16.restype = None @@ -1414,7 +1536,7 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru _UniffiLib.ffi_payjoin_ffi_rust_future_complete_u16.restype = ctypes.c_uint16 _UniffiLib.ffi_payjoin_ffi_rust_future_poll_i16.argtypes = ( ctypes.c_uint64, - UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, ctypes.c_uint64, ) _UniffiLib.ffi_payjoin_ffi_rust_future_poll_i16.restype = None @@ -1433,7 +1555,7 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru _UniffiLib.ffi_payjoin_ffi_rust_future_complete_i16.restype = ctypes.c_int16 _UniffiLib.ffi_payjoin_ffi_rust_future_poll_u32.argtypes = ( ctypes.c_uint64, - UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, ctypes.c_uint64, ) _UniffiLib.ffi_payjoin_ffi_rust_future_poll_u32.restype = None @@ -1452,7 +1574,7 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru _UniffiLib.ffi_payjoin_ffi_rust_future_complete_u32.restype = ctypes.c_uint32 _UniffiLib.ffi_payjoin_ffi_rust_future_poll_i32.argtypes = ( ctypes.c_uint64, - UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, ctypes.c_uint64, ) _UniffiLib.ffi_payjoin_ffi_rust_future_poll_i32.restype = None @@ -1471,7 +1593,7 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru _UniffiLib.ffi_payjoin_ffi_rust_future_complete_i32.restype = ctypes.c_int32 _UniffiLib.ffi_payjoin_ffi_rust_future_poll_u64.argtypes = ( ctypes.c_uint64, - UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, ctypes.c_uint64, ) _UniffiLib.ffi_payjoin_ffi_rust_future_poll_u64.restype = None @@ -1490,7 +1612,7 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru _UniffiLib.ffi_payjoin_ffi_rust_future_complete_u64.restype = ctypes.c_uint64 _UniffiLib.ffi_payjoin_ffi_rust_future_poll_i64.argtypes = ( ctypes.c_uint64, - UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, ctypes.c_uint64, ) _UniffiLib.ffi_payjoin_ffi_rust_future_poll_i64.restype = None @@ -1509,7 +1631,7 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru _UniffiLib.ffi_payjoin_ffi_rust_future_complete_i64.restype = ctypes.c_int64 _UniffiLib.ffi_payjoin_ffi_rust_future_poll_f32.argtypes = ( ctypes.c_uint64, - UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, ctypes.c_uint64, ) _UniffiLib.ffi_payjoin_ffi_rust_future_poll_f32.restype = None @@ -1528,7 +1650,7 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru _UniffiLib.ffi_payjoin_ffi_rust_future_complete_f32.restype = ctypes.c_float _UniffiLib.ffi_payjoin_ffi_rust_future_poll_f64.argtypes = ( ctypes.c_uint64, - UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, ctypes.c_uint64, ) _UniffiLib.ffi_payjoin_ffi_rust_future_poll_f64.restype = None @@ -1547,7 +1669,7 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru _UniffiLib.ffi_payjoin_ffi_rust_future_complete_f64.restype = ctypes.c_double _UniffiLib.ffi_payjoin_ffi_rust_future_poll_pointer.argtypes = ( ctypes.c_uint64, - UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, ctypes.c_uint64, ) _UniffiLib.ffi_payjoin_ffi_rust_future_poll_pointer.restype = None @@ -1566,7 +1688,7 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru _UniffiLib.ffi_payjoin_ffi_rust_future_complete_pointer.restype = ctypes.c_void_p _UniffiLib.ffi_payjoin_ffi_rust_future_poll_rust_buffer.argtypes = ( ctypes.c_uint64, - UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, ctypes.c_uint64, ) _UniffiLib.ffi_payjoin_ffi_rust_future_poll_rust_buffer.restype = None @@ -1585,7 +1707,7 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru _UniffiLib.ffi_payjoin_ffi_rust_future_complete_rust_buffer.restype = _UniffiRustBuffer _UniffiLib.ffi_payjoin_ffi_rust_future_poll_void.argtypes = ( ctypes.c_uint64, - UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, + _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK, ctypes.c_uint64, ) _UniffiLib.ffi_payjoin_ffi_rust_future_poll_void.restype = None @@ -1602,27 +1724,27 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru ctypes.POINTER(_UniffiRustCallStatus), ) _UniffiLib.ffi_payjoin_ffi_rust_future_complete_void.restype = None -_UniffiLib.uniffi_payjoin_ffi_checksum_method_contextv1_process_response.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_checksum_method_activesession_extract_req.argtypes = ( ) -_UniffiLib.uniffi_payjoin_ffi_checksum_method_contextv1_process_response.restype = ctypes.c_uint16 -_UniffiLib.uniffi_payjoin_ffi_checksum_method_contextv2_process_response.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_checksum_method_activesession_extract_req.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_activesession_pj_uri_builder.argtypes = ( ) -_UniffiLib.uniffi_payjoin_ffi_checksum_method_contextv2_process_response.restype = ctypes.c_uint16 -_UniffiLib.uniffi_payjoin_ffi_checksum_method_enrolled_extract_req.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_checksum_method_activesession_pj_uri_builder.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_activesession_pj_url.argtypes = ( ) -_UniffiLib.uniffi_payjoin_ffi_checksum_method_enrolled_extract_req.restype = ctypes.c_uint16 -_UniffiLib.uniffi_payjoin_ffi_checksum_method_enrolled_fallback_target.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_checksum_method_activesession_pj_url.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_activesession_process_res.argtypes = ( ) -_UniffiLib.uniffi_payjoin_ffi_checksum_method_enrolled_fallback_target.restype = ctypes.c_uint16 -_UniffiLib.uniffi_payjoin_ffi_checksum_method_enrolled_process_res.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_checksum_method_activesession_process_res.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_activesession_public_key.argtypes = ( ) -_UniffiLib.uniffi_payjoin_ffi_checksum_method_enrolled_process_res.restype = ctypes.c_uint16 -_UniffiLib.uniffi_payjoin_ffi_checksum_method_enroller_extract_req.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_checksum_method_activesession_public_key.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_contextv1_process_response.argtypes = ( ) -_UniffiLib.uniffi_payjoin_ffi_checksum_method_enroller_extract_req.restype = ctypes.c_uint16 -_UniffiLib.uniffi_payjoin_ffi_checksum_method_enroller_process_res.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_checksum_method_contextv1_process_response.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_contextv2_process_response.argtypes = ( ) -_UniffiLib.uniffi_payjoin_ffi_checksum_method_enroller_process_res.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_contextv2_process_response.restype = ctypes.c_uint16 _UniffiLib.uniffi_payjoin_ffi_checksum_method_headers_get_map.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_method_headers_get_map.restype = ctypes.c_uint16 @@ -1650,21 +1772,42 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru _UniffiLib.uniffi_payjoin_ffi_checksum_method_payjoinproposal_utxos_to_be_locked.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_method_payjoinproposal_utxos_to_be_locked.restype = ctypes.c_uint16 -_UniffiLib.uniffi_payjoin_ffi_checksum_method_provisionalproposal_contribute_non_witness_input.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_checksum_method_pjuri_address.argtypes = ( +) +_UniffiLib.uniffi_payjoin_ffi_checksum_method_pjuri_address.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_pjuri_amount.argtypes = ( ) -_UniffiLib.uniffi_payjoin_ffi_checksum_method_provisionalproposal_contribute_non_witness_input.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_pjuri_amount.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_pjuri_as_string.argtypes = ( +) +_UniffiLib.uniffi_payjoin_ffi_checksum_method_pjuri_as_string.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_pjuribuilder_amount.argtypes = ( +) +_UniffiLib.uniffi_payjoin_ffi_checksum_method_pjuribuilder_amount.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_pjuribuilder_build.argtypes = ( +) +_UniffiLib.uniffi_payjoin_ffi_checksum_method_pjuribuilder_build.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_pjuribuilder_label.argtypes = ( +) +_UniffiLib.uniffi_payjoin_ffi_checksum_method_pjuribuilder_label.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_pjuribuilder_message.argtypes = ( +) +_UniffiLib.uniffi_payjoin_ffi_checksum_method_pjuribuilder_message.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_pjuribuilder_pjos.argtypes = ( +) +_UniffiLib.uniffi_payjoin_ffi_checksum_method_pjuribuilder_pjos.restype = ctypes.c_uint16 _UniffiLib.uniffi_payjoin_ffi_checksum_method_provisionalproposal_contribute_witness_input.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_method_provisionalproposal_contribute_witness_input.restype = ctypes.c_uint16 _UniffiLib.uniffi_payjoin_ffi_checksum_method_provisionalproposal_finalize_proposal.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_method_provisionalproposal_finalize_proposal.restype = ctypes.c_uint16 -_UniffiLib.uniffi_payjoin_ffi_checksum_method_provisionalproposal_substitute_output_address.argtypes = ( -) -_UniffiLib.uniffi_payjoin_ffi_checksum_method_provisionalproposal_substitute_output_address.restype = ctypes.c_uint16 _UniffiLib.uniffi_payjoin_ffi_checksum_method_provisionalproposal_try_preserving_privacy.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_method_provisionalproposal_try_preserving_privacy.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_provisionalproposal_try_substitute_receiver_output.argtypes = ( +) +_UniffiLib.uniffi_payjoin_ffi_checksum_method_provisionalproposal_try_substitute_receiver_output.restype = ctypes.c_uint16 _UniffiLib.uniffi_payjoin_ffi_checksum_method_requestbuilder_always_disable_output_substitution.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_method_requestbuilder_always_disable_output_substitution.restype = ctypes.c_uint16 @@ -1683,6 +1826,12 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru _UniffiLib.uniffi_payjoin_ffi_checksum_method_requestcontext_extract_v2.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_method_requestcontext_extract_v2.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_sessioninitializer_extract_req.argtypes = ( +) +_UniffiLib.uniffi_payjoin_ffi_checksum_method_sessioninitializer_extract_req.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_sessioninitializer_process_res.argtypes = ( +) +_UniffiLib.uniffi_payjoin_ffi_checksum_method_sessioninitializer_process_res.restype = ctypes.c_uint16 _UniffiLib.uniffi_payjoin_ffi_checksum_method_uncheckedproposal_assume_interactive_receiver.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_method_uncheckedproposal_assume_interactive_receiver.restype = ctypes.c_uint16 @@ -1698,6 +1847,12 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru _UniffiLib.uniffi_payjoin_ffi_checksum_method_uri_amount.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_method_uri_amount.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_uri_as_string.argtypes = ( +) +_UniffiLib.uniffi_payjoin_ffi_checksum_method_uri_as_string.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_uri_check_pj_supported.argtypes = ( +) +_UniffiLib.uniffi_payjoin_ffi_checksum_method_uri_check_pj_supported.restype = ctypes.c_uint16 _UniffiLib.uniffi_payjoin_ffi_checksum_method_url_as_string.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_method_url_as_string.restype = ctypes.c_uint16 @@ -1716,36 +1871,39 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru _UniffiLib.uniffi_payjoin_ffi_checksum_method_v2outputsunknown_identify_receiver_outputs.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_method_v2outputsunknown_identify_receiver_outputs.restype = ctypes.c_uint16 -_UniffiLib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_deserialize_res.argtypes = ( +_UniffiLib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_extract_v1_req.argtypes = ( ) -_UniffiLib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_deserialize_res.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_extract_v1_req.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_extract_v2_req.argtypes = ( +) +_UniffiLib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_extract_v2_req.restype = ctypes.c_uint16 _UniffiLib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_is_output_substitution_disabled.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_is_output_substitution_disabled.restype = ctypes.c_uint16 _UniffiLib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_owned_vouts.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_owned_vouts.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_process_res.argtypes = ( +) +_UniffiLib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_process_res.restype = ctypes.c_uint16 _UniffiLib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_psbt.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_psbt.restype = ctypes.c_uint16 _UniffiLib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_utxos_to_be_locked.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_method_v2payjoinproposal_utxos_to_be_locked.restype = ctypes.c_uint16 -_UniffiLib.uniffi_payjoin_ffi_checksum_method_v2provisionalproposal_contribute_non_witness_input.argtypes = ( -) -_UniffiLib.uniffi_payjoin_ffi_checksum_method_v2provisionalproposal_contribute_non_witness_input.restype = ctypes.c_uint16 _UniffiLib.uniffi_payjoin_ffi_checksum_method_v2provisionalproposal_contribute_witness_input.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_method_v2provisionalproposal_contribute_witness_input.restype = ctypes.c_uint16 _UniffiLib.uniffi_payjoin_ffi_checksum_method_v2provisionalproposal_finalize_proposal.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_method_v2provisionalproposal_finalize_proposal.restype = ctypes.c_uint16 -_UniffiLib.uniffi_payjoin_ffi_checksum_method_v2provisionalproposal_substitute_output_address.argtypes = ( -) -_UniffiLib.uniffi_payjoin_ffi_checksum_method_v2provisionalproposal_substitute_output_address.restype = ctypes.c_uint16 _UniffiLib.uniffi_payjoin_ffi_checksum_method_v2provisionalproposal_try_preserving_privacy.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_method_v2provisionalproposal_try_preserving_privacy.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_v2provisionalproposal_try_substitute_receiver_output.argtypes = ( +) +_UniffiLib.uniffi_payjoin_ffi_checksum_method_v2provisionalproposal_try_substitute_receiver_output.restype = ctypes.c_uint16 _UniffiLib.uniffi_payjoin_ffi_checksum_method_v2uncheckedproposal_assume_interactive_receiver.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_method_v2uncheckedproposal_assume_interactive_receiver.restype = ctypes.c_uint16 @@ -1755,18 +1913,21 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru _UniffiLib.uniffi_payjoin_ffi_checksum_method_v2uncheckedproposal_extract_tx_to_schedule_broadcast.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_method_v2uncheckedproposal_extract_tx_to_schedule_broadcast.restype = ctypes.c_uint16 -_UniffiLib.uniffi_payjoin_ffi_checksum_constructor_enroller_from_directory_config.argtypes = ( -) -_UniffiLib.uniffi_payjoin_ffi_checksum_constructor_enroller_from_directory_config.restype = ctypes.c_uint16 _UniffiLib.uniffi_payjoin_ffi_checksum_constructor_headers_from_vec.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_constructor_headers_from_vec.restype = ctypes.c_uint16 _UniffiLib.uniffi_payjoin_ffi_checksum_constructor_ohttpkeys_decode.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_constructor_ohttpkeys_decode.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_constructor_pjuribuilder_new.argtypes = ( +) +_UniffiLib.uniffi_payjoin_ffi_checksum_constructor_pjuribuilder_new.restype = ctypes.c_uint16 _UniffiLib.uniffi_payjoin_ffi_checksum_constructor_requestbuilder_from_psbt_and_uri.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_constructor_requestbuilder_from_psbt_and_uri.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_constructor_sessioninitializer_new.argtypes = ( +) +_UniffiLib.uniffi_payjoin_ffi_checksum_constructor_sessioninitializer_new.restype = ctypes.c_uint16 _UniffiLib.uniffi_payjoin_ffi_checksum_constructor_uncheckedproposal_from_request.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_constructor_uncheckedproposal_from_request.restype = ctypes.c_uint16 @@ -1779,6 +1940,9 @@ class UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction(ctypes.Stru _UniffiLib.uniffi_payjoin_ffi_checksum_method_canbroadcast_callback.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_method_canbroadcast_callback.restype = ctypes.c_uint16 +_UniffiLib.uniffi_payjoin_ffi_checksum_method_generatescript_callback.argtypes = ( +) +_UniffiLib.uniffi_payjoin_ffi_checksum_method_generatescript_callback.restype = ctypes.c_uint16 _UniffiLib.uniffi_payjoin_ffi_checksum_method_isoutputknown_callback.argtypes = ( ) _UniffiLib.uniffi_payjoin_ffi_checksum_method_isoutputknown_callback.restype = ctypes.c_uint16 @@ -1901,11 +2065,20 @@ def lower(value): -class ClientResponseProtocol(typing.Protocol): - pass +class ActiveSessionProtocol(typing.Protocol): + def extract_req(self, ): + raise NotImplementedError + def pj_uri_builder(self, ): + raise NotImplementedError + def pj_url(self, ): + raise NotImplementedError + def process_res(self, body: "typing.List[int]",ctx: "ClientResponse"): + raise NotImplementedError + def public_key(self, ): + raise NotImplementedError -class ClientResponse: +class ActiveSession: _pointer: ctypes.c_void_p def __init__(self, *args, **kwargs): @@ -1915,10 +2088,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_clientresponse, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_activesession, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_clientresponse, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_activesession, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -1930,73 +2103,51 @@ def _make_instance_(cls, pointer): return inst + def extract_req(self, ) -> "RequestResponse": + return _UniffiConverterTypeRequestResponse.lift( + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_activesession_extract_req,self._uniffi_clone_pointer(),) + ) -class _UniffiConverterTypeClientResponse: - @staticmethod - def lift(value: int): - return ClientResponse._make_instance_(value) - @staticmethod - def check_lower(value: ClientResponse): - if not isinstance(value, ClientResponse): - raise TypeError("Expected ClientResponse instance, {} found".format(type(value).__name__)) - @staticmethod - def lower(value: ClientResponseProtocol): - if not isinstance(value, ClientResponse): - raise TypeError("Expected ClientResponse instance, {} found".format(type(value).__name__)) - return value._uniffi_clone_pointer() - @classmethod - def read(cls, buf: _UniffiRustBuffer): - ptr = buf.read_u64() - if ptr == 0: - raise InternalError("Raw pointer value was null") - return cls.lift(ptr) + def pj_uri_builder(self, ) -> "PjUriBuilder": + return _UniffiConverterTypePjUriBuilder.lift( + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_activesession_pj_uri_builder,self._uniffi_clone_pointer(),) + ) - @classmethod - def write(cls, value: ClientResponseProtocol, buf: _UniffiRustBuffer): - buf.write_u64(cls.lower(value)) -class ContextV1Protocol(typing.Protocol): - def process_response(self, response: "typing.List[int]"): - raise NotImplementedError + def pj_url(self, ) -> "Url": + return _UniffiConverterTypeUrl.lift( + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_activesession_pj_url,self._uniffi_clone_pointer(),) + ) -class ContextV1: - _pointer: ctypes.c_void_p - - def __init__(self, *args, **kwargs): - raise ValueError("This class has no default constructor") - def __del__(self): - # In case of partial initialization of instances. - pointer = getattr(self, "_pointer", None) - if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_contextv1, pointer) - def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_contextv1, self._pointer) - - # Used by alternative constructors or any methods which return this type. - @classmethod - def _make_instance_(cls, pointer): - # Lightly yucky way to bypass the usual __init__ logic - # and just create a new instance with the required pointer. - inst = cls.__new__(cls) - inst._pointer = pointer - return inst - def process_response(self, response: "typing.List[int]") -> "str": - _UniffiConverterSequenceUInt8.check_lower(response) + def process_res(self, body: "typing.List[int]",ctx: "ClientResponse") -> "typing.Optional[V2UncheckedProposal]": + _UniffiConverterSequenceUInt8.check_lower(body) + _UniffiConverterTypeClientResponse.check_lower(ctx) + + return _UniffiConverterOptionalTypeV2UncheckedProposal.lift( + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_activesession_process_res,self._uniffi_clone_pointer(), + _UniffiConverterSequenceUInt8.lower(body), + _UniffiConverterTypeClientResponse.lower(ctx)) + ) + + + + + + def public_key(self, ) -> "str": return _UniffiConverterString.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_contextv1_process_response,self._uniffi_clone_pointer(), - _UniffiConverterSequenceUInt8.lower(response)) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_activesession_public_key,self._uniffi_clone_pointer(),) ) @@ -2004,21 +2155,21 @@ def process_response(self, response: "typing.List[int]") -> "str": -class _UniffiConverterTypeContextV1: +class _UniffiConverterTypeActiveSession: @staticmethod def lift(value: int): - return ContextV1._make_instance_(value) + return ActiveSession._make_instance_(value) @staticmethod - def check_lower(value: ContextV1): - if not isinstance(value, ContextV1): - raise TypeError("Expected ContextV1 instance, {} found".format(type(value).__name__)) + def check_lower(value: ActiveSession): + if not isinstance(value, ActiveSession): + raise TypeError("Expected ActiveSession instance, {} found".format(type(value).__name__)) @staticmethod - def lower(value: ContextV1Protocol): - if not isinstance(value, ContextV1): - raise TypeError("Expected ContextV1 instance, {} found".format(type(value).__name__)) + def lower(value: ActiveSessionProtocol): + if not isinstance(value, ActiveSession): + raise TypeError("Expected ActiveSession instance, {} found".format(type(value).__name__)) return value._uniffi_clone_pointer() @classmethod @@ -2029,17 +2180,16 @@ def read(cls, buf: _UniffiRustBuffer): return cls.lift(ptr) @classmethod - def write(cls, value: ContextV1Protocol, buf: _UniffiRustBuffer): + def write(cls, value: ActiveSessionProtocol, buf: _UniffiRustBuffer): buf.write_u64(cls.lower(value)) -class ContextV2Protocol(typing.Protocol): - def process_response(self, response: "typing.List[int]"): - raise NotImplementedError +class ClientResponseProtocol(typing.Protocol): + pass -class ContextV2: +class ClientResponse: _pointer: ctypes.c_void_p def __init__(self, *args, **kwargs): @@ -2049,10 +2199,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_contextv2, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_clientresponse, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_contextv2, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_clientresponse, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -2064,34 +2214,22 @@ def _make_instance_(cls, pointer): return inst - def process_response(self, response: "typing.List[int]") -> "typing.Optional[str]": - _UniffiConverterSequenceUInt8.check_lower(response) - - return _UniffiConverterOptionalString.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_contextv2_process_response,self._uniffi_clone_pointer(), - _UniffiConverterSequenceUInt8.lower(response)) - ) - - - - - -class _UniffiConverterTypeContextV2: +class _UniffiConverterTypeClientResponse: @staticmethod def lift(value: int): - return ContextV2._make_instance_(value) + return ClientResponse._make_instance_(value) @staticmethod - def check_lower(value: ContextV2): - if not isinstance(value, ContextV2): - raise TypeError("Expected ContextV2 instance, {} found".format(type(value).__name__)) + def check_lower(value: ClientResponse): + if not isinstance(value, ClientResponse): + raise TypeError("Expected ClientResponse instance, {} found".format(type(value).__name__)) @staticmethod - def lower(value: ContextV2Protocol): - if not isinstance(value, ContextV2): - raise TypeError("Expected ContextV2 instance, {} found".format(type(value).__name__)) + def lower(value: ClientResponseProtocol): + if not isinstance(value, ClientResponse): + raise TypeError("Expected ClientResponse instance, {} found".format(type(value).__name__)) return value._uniffi_clone_pointer() @classmethod @@ -2102,21 +2240,17 @@ def read(cls, buf: _UniffiRustBuffer): return cls.lift(ptr) @classmethod - def write(cls, value: ContextV2Protocol, buf: _UniffiRustBuffer): + def write(cls, value: ClientResponseProtocol, buf: _UniffiRustBuffer): buf.write_u64(cls.lower(value)) -class EnrolledProtocol(typing.Protocol): - def extract_req(self, ): - raise NotImplementedError - def fallback_target(self, ): - raise NotImplementedError - def process_res(self, body: "typing.List[int]",ctx: "ClientResponse"): +class ContextV1Protocol(typing.Protocol): + def process_response(self, response: "typing.List[int]"): raise NotImplementedError -class Enrolled: +class ContextV1: _pointer: ctypes.c_void_p def __init__(self, *args, **kwargs): @@ -2126,10 +2260,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_enrolled, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_contextv1, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_enrolled, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_contextv1, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -2141,33 +2275,12 @@ def _make_instance_(cls, pointer): return inst - def extract_req(self, ) -> "RequestResponse": - return _UniffiConverterTypeRequestResponse.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_enrolled_extract_req,self._uniffi_clone_pointer(),) - ) - - - - - - def fallback_target(self, ) -> "str": - return _UniffiConverterString.lift( - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_enrolled_fallback_target,self._uniffi_clone_pointer(),) - ) - - - - - - def process_res(self, body: "typing.List[int]",ctx: "ClientResponse") -> "typing.Optional[V2UncheckedProposal]": - _UniffiConverterSequenceUInt8.check_lower(body) - - _UniffiConverterTypeClientResponse.check_lower(ctx) + def process_response(self, response: "typing.List[int]") -> "str": + _UniffiConverterSequenceUInt8.check_lower(response) - return _UniffiConverterOptionalTypeV2UncheckedProposal.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_enrolled_process_res,self._uniffi_clone_pointer(), - _UniffiConverterSequenceUInt8.lower(body), - _UniffiConverterTypeClientResponse.lower(ctx)) + return _UniffiConverterString.lift( + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_contextv1_process_response,self._uniffi_clone_pointer(), + _UniffiConverterSequenceUInt8.lower(response)) ) @@ -2175,21 +2288,21 @@ def process_res(self, body: "typing.List[int]",ctx: "ClientResponse") -> "typing -class _UniffiConverterTypeEnrolled: +class _UniffiConverterTypeContextV1: @staticmethod def lift(value: int): - return Enrolled._make_instance_(value) + return ContextV1._make_instance_(value) @staticmethod - def check_lower(value: Enrolled): - if not isinstance(value, Enrolled): - raise TypeError("Expected Enrolled instance, {} found".format(type(value).__name__)) + def check_lower(value: ContextV1): + if not isinstance(value, ContextV1): + raise TypeError("Expected ContextV1 instance, {} found".format(type(value).__name__)) @staticmethod - def lower(value: EnrolledProtocol): - if not isinstance(value, Enrolled): - raise TypeError("Expected Enrolled instance, {} found".format(type(value).__name__)) + def lower(value: ContextV1Protocol): + if not isinstance(value, ContextV1): + raise TypeError("Expected ContextV1 instance, {} found".format(type(value).__name__)) return value._uniffi_clone_pointer() @classmethod @@ -2200,19 +2313,17 @@ def read(cls, buf: _UniffiRustBuffer): return cls.lift(ptr) @classmethod - def write(cls, value: EnrolledProtocol, buf: _UniffiRustBuffer): + def write(cls, value: ContextV1Protocol, buf: _UniffiRustBuffer): buf.write_u64(cls.lower(value)) -class EnrollerProtocol(typing.Protocol): - def extract_req(self, ): - raise NotImplementedError - def process_res(self, body: "typing.List[int]",ctx: "ClientResponse"): +class ContextV2Protocol(typing.Protocol): + def process_response(self, response: "typing.List[int]"): raise NotImplementedError -class Enroller: +class ContextV2: _pointer: ctypes.c_void_p def __init__(self, *args, **kwargs): @@ -2222,10 +2333,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_enroller, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_contextv2, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_enroller, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_contextv2, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -2236,41 +2347,13 @@ def _make_instance_(cls, pointer): inst._pointer = pointer return inst - @classmethod - def from_directory_config(cls, directory: "Url",ohttp_keys: "OhttpKeys",ohttp_relay: "Url"): - _UniffiConverterTypeUrl.check_lower(directory) - - _UniffiConverterTypeOhttpKeys.check_lower(ohttp_keys) - - _UniffiConverterTypeUrl.check_lower(ohttp_relay) - - # Call the (fallible) function before creating any half-baked object instances. - pointer = _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_constructor_enroller_from_directory_config, - _UniffiConverterTypeUrl.lower(directory), - _UniffiConverterTypeOhttpKeys.lower(ohttp_keys), - _UniffiConverterTypeUrl.lower(ohttp_relay)) - return cls._make_instance_(pointer) - - - def extract_req(self, ) -> "RequestResponse": - return _UniffiConverterTypeRequestResponse.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_enroller_extract_req,self._uniffi_clone_pointer(),) - ) - - - - - - def process_res(self, body: "typing.List[int]",ctx: "ClientResponse") -> "Enrolled": - _UniffiConverterSequenceUInt8.check_lower(body) - - _UniffiConverterTypeClientResponse.check_lower(ctx) + def process_response(self, response: "typing.List[int]") -> "typing.Optional[str]": + _UniffiConverterSequenceUInt8.check_lower(response) - return _UniffiConverterTypeEnrolled.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_enroller_process_res,self._uniffi_clone_pointer(), - _UniffiConverterSequenceUInt8.lower(body), - _UniffiConverterTypeClientResponse.lower(ctx)) + return _UniffiConverterOptionalString.lift( + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_contextv2_process_response,self._uniffi_clone_pointer(), + _UniffiConverterSequenceUInt8.lower(response)) ) @@ -2278,21 +2361,21 @@ def process_res(self, body: "typing.List[int]",ctx: "ClientResponse") -> "Enroll -class _UniffiConverterTypeEnroller: +class _UniffiConverterTypeContextV2: @staticmethod def lift(value: int): - return Enroller._make_instance_(value) + return ContextV2._make_instance_(value) @staticmethod - def check_lower(value: Enroller): - if not isinstance(value, Enroller): - raise TypeError("Expected Enroller instance, {} found".format(type(value).__name__)) + def check_lower(value: ContextV2): + if not isinstance(value, ContextV2): + raise TypeError("Expected ContextV2 instance, {} found".format(type(value).__name__)) @staticmethod - def lower(value: EnrollerProtocol): - if not isinstance(value, Enroller): - raise TypeError("Expected Enroller instance, {} found".format(type(value).__name__)) + def lower(value: ContextV2Protocol): + if not isinstance(value, ContextV2): + raise TypeError("Expected ContextV2 instance, {} found".format(type(value).__name__)) return value._uniffi_clone_pointer() @classmethod @@ -2303,7 +2386,7 @@ def read(cls, buf: _UniffiRustBuffer): return cls.lift(ptr) @classmethod - def write(cls, value: EnrollerProtocol, buf: _UniffiRustBuffer): + def write(cls, value: ContextV2Protocol, buf: _UniffiRustBuffer): buf.write_u64(cls.lower(value)) @@ -2323,10 +2406,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_headers, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_headers, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_headers, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_headers, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -2342,7 +2425,7 @@ def from_vec(cls, body: "typing.List[int]"): _UniffiConverterSequenceUInt8.check_lower(body) # Call the (fallible) function before creating any half-baked object instances. - pointer = _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_constructor_headers_from_vec, + pointer = _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_constructor_headers_from_vec, _UniffiConverterSequenceUInt8.lower(body)) return cls._make_instance_(pointer) @@ -2350,7 +2433,7 @@ def from_vec(cls, body: "typing.List[int]"): def get_map(self, ) -> "dict[str, str]": return _UniffiConverterMapStringString.lift( - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_headers_get_map,self._uniffi_clone_pointer(),) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_headers_get_map,self._uniffi_clone_pointer(),) ) @@ -2403,10 +2486,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_maybeinputsowned, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_maybeinputsowned, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_maybeinputsowned, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_maybeinputsowned, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -2422,7 +2505,7 @@ def check_inputs_not_owned(self, is_owned: "IsScriptOwned") -> "MaybeMixedInputS _UniffiConverterCallbackInterfaceIsScriptOwned.check_lower(is_owned) return _UniffiConverterTypeMaybeMixedInputScripts.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_maybeinputsowned_check_inputs_not_owned,self._uniffi_clone_pointer(), + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_maybeinputsowned_check_inputs_not_owned,self._uniffi_clone_pointer(), _UniffiConverterCallbackInterfaceIsScriptOwned.lower(is_owned)) ) @@ -2476,10 +2559,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_maybeinputsseen, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_maybeinputsseen, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_maybeinputsseen, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_maybeinputsseen, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -2495,7 +2578,7 @@ def check_no_inputs_seen_before(self, is_known: "IsOutputKnown") -> "OutputsUnkn _UniffiConverterCallbackInterfaceIsOutputKnown.check_lower(is_known) return _UniffiConverterTypeOutputsUnknown.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_maybeinputsseen_check_no_inputs_seen_before,self._uniffi_clone_pointer(), + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_maybeinputsseen_check_no_inputs_seen_before,self._uniffi_clone_pointer(), _UniffiConverterCallbackInterfaceIsOutputKnown.lower(is_known)) ) @@ -2549,10 +2632,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_maybemixedinputscripts, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_maybemixedinputscripts, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_maybemixedinputscripts, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_maybemixedinputscripts, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -2566,7 +2649,7 @@ def _make_instance_(cls, pointer): def check_no_mixed_input_scripts(self, ) -> "MaybeInputsSeen": return _UniffiConverterTypeMaybeInputsSeen.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_maybemixedinputscripts_check_no_mixed_input_scripts,self._uniffi_clone_pointer(),) + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_maybemixedinputscripts_check_no_mixed_input_scripts,self._uniffi_clone_pointer(),) ) @@ -2618,10 +2701,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_ohttpkeys, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_ohttpkeys, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_ohttpkeys, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_ohttpkeys, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -2637,7 +2720,7 @@ def decode(cls, bytes: "typing.List[int]"): _UniffiConverterSequenceUInt8.check_lower(bytes) # Call the (fallible) function before creating any half-baked object instances. - pointer = _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_constructor_ohttpkeys_decode, + pointer = _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_constructor_ohttpkeys_decode, _UniffiConverterSequenceUInt8.lower(bytes)) return cls._make_instance_(pointer) @@ -2689,10 +2772,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_outputsunknown, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_outputsunknown, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_outputsunknown, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_outputsunknown, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -2708,7 +2791,7 @@ def identify_receiver_outputs(self, is_receiver_output: "IsScriptOwned") -> "Pro _UniffiConverterCallbackInterfaceIsScriptOwned.check_lower(is_receiver_output) return _UniffiConverterTypeProvisionalProposal.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_outputsunknown_identify_receiver_outputs,self._uniffi_clone_pointer(), + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_outputsunknown_identify_receiver_outputs,self._uniffi_clone_pointer(), _UniffiConverterCallbackInterfaceIsScriptOwned.lower(is_receiver_output)) ) @@ -2768,10 +2851,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_payjoinproposal, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_payjoinproposal, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_payjoinproposal, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_payjoinproposal, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -2785,7 +2868,7 @@ def _make_instance_(cls, pointer): def is_output_substitution_disabled(self, ) -> "bool": return _UniffiConverterBool.lift( - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_payjoinproposal_is_output_substitution_disabled,self._uniffi_clone_pointer(),) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_payjoinproposal_is_output_substitution_disabled,self._uniffi_clone_pointer(),) ) @@ -2794,7 +2877,7 @@ def is_output_substitution_disabled(self, ) -> "bool": def owned_vouts(self, ) -> "typing.List[int]": return _UniffiConverterSequenceUInt64.lift( - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_payjoinproposal_owned_vouts,self._uniffi_clone_pointer(),) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_payjoinproposal_owned_vouts,self._uniffi_clone_pointer(),) ) @@ -2803,7 +2886,7 @@ def owned_vouts(self, ) -> "typing.List[int]": def psbt(self, ) -> "str": return _UniffiConverterString.lift( - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_payjoinproposal_psbt,self._uniffi_clone_pointer(),) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_payjoinproposal_psbt,self._uniffi_clone_pointer(),) ) @@ -2812,7 +2895,7 @@ def psbt(self, ) -> "str": def utxos_to_be_locked(self, ) -> "typing.List[OutPoint]": return _UniffiConverterSequenceTypeOutPoint.lift( - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_payjoinproposal_utxos_to_be_locked,self._uniffi_clone_pointer(),) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_payjoinproposal_utxos_to_be_locked,self._uniffi_clone_pointer(),) ) @@ -2851,7 +2934,12 @@ def write(cls, value: PayjoinProposalProtocol, buf: _UniffiRustBuffer): class PjUriProtocol(typing.Protocol): - pass + def address(self, ): + raise NotImplementedError + def amount(self, ): + raise NotImplementedError + def as_string(self, ): + raise NotImplementedError class PjUri: @@ -2864,10 +2952,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_pjuri, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_pjuri, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_pjuri, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_pjuri, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -2879,6 +2967,33 @@ def _make_instance_(cls, pointer): return inst + def address(self, ) -> "str": + return _UniffiConverterString.lift( + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuri_address,self._uniffi_clone_pointer(),) + ) + + + + + + def amount(self, ) -> "typing.Optional[float]": + return _UniffiConverterOptionalDouble.lift( + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuri_amount,self._uniffi_clone_pointer(),) + ) + + + + + + def as_string(self, ) -> "str": + return _UniffiConverterString.lift( + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuri_as_string,self._uniffi_clone_pointer(),) + ) + + + + + class _UniffiConverterTypePjUri: @@ -2910,33 +3025,44 @@ def write(cls, value: PjUriProtocol, buf: _UniffiRustBuffer): -class ProvisionalProposalProtocol(typing.Protocol): - def contribute_non_witness_input(self, tx: "typing.List[int]",outpoint: "OutPoint"): +class PjUriBuilderProtocol(typing.Protocol): + def amount(self, amount: "int"): raise NotImplementedError - def contribute_witness_input(self, txout: "TxOut",outpoint: "OutPoint"): + def build(self, ): raise NotImplementedError - def finalize_proposal(self, process_psbt: "ProcessPartiallySignedTransaction",min_feerate_sat_per_vb: "typing.Optional[int]"): + def label(self, label: "str"): raise NotImplementedError - def substitute_output_address(self, substitute_address: "str"): + def message(self, message: "str"): raise NotImplementedError - def try_preserving_privacy(self, candidate_inputs: "dict[int, OutPoint]"): + def pjos(self, pjos: "bool"): raise NotImplementedError -class ProvisionalProposal: +class PjUriBuilder: _pointer: ctypes.c_void_p - - def __init__(self, *args, **kwargs): - raise ValueError("This class has no default constructor") + def __init__(self, address: "str",pj: "Url",ohttp_keys: "typing.Optional[OhttpKeys]",expiry: "typing.Optional[int]"): + _UniffiConverterString.check_lower(address) + + _UniffiConverterTypeUrl.check_lower(pj) + + _UniffiConverterOptionalTypeOhttpKeys.check_lower(ohttp_keys) + + _UniffiConverterOptionalUInt64.check_lower(expiry) + + self._pointer = _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_constructor_pjuribuilder_new, + _UniffiConverterString.lower(address), + _UniffiConverterTypeUrl.lower(pj), + _UniffiConverterOptionalTypeOhttpKeys.lower(ohttp_keys), + _UniffiConverterOptionalUInt64.lower(expiry)) def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_provisionalproposal, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_pjuribuilder, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_provisionalproposal, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_pjuribuilder, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -2948,26 +3074,136 @@ def _make_instance_(cls, pointer): return inst - def contribute_non_witness_input(self, tx: "typing.List[int]",outpoint: "OutPoint") -> None: - _UniffiConverterSequenceUInt8.check_lower(tx) + def amount(self, amount: "int") -> "PjUriBuilder": + _UniffiConverterUInt64.check_lower(amount) - _UniffiConverterTypeOutPoint.check_lower(outpoint) + return _UniffiConverterTypePjUriBuilder.lift( + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuribuilder_amount,self._uniffi_clone_pointer(), + _UniffiConverterUInt64.lower(amount)) + ) + + + + + + def build(self, ) -> "PjUri": + return _UniffiConverterTypePjUri.lift( + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuribuilder_build,self._uniffi_clone_pointer(),) + ) + + + + + + def label(self, label: "str") -> "PjUriBuilder": + _UniffiConverterString.check_lower(label) - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_provisionalproposal_contribute_non_witness_input,self._uniffi_clone_pointer(), - _UniffiConverterSequenceUInt8.lower(tx), - _UniffiConverterTypeOutPoint.lower(outpoint)) + return _UniffiConverterTypePjUriBuilder.lift( + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuribuilder_label,self._uniffi_clone_pointer(), + _UniffiConverterString.lower(label)) + ) + + + + + + def message(self, message: "str") -> "PjUriBuilder": + _UniffiConverterString.check_lower(message) + + return _UniffiConverterTypePjUriBuilder.lift( + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuribuilder_message,self._uniffi_clone_pointer(), + _UniffiConverterString.lower(message)) + ) + def pjos(self, pjos: "bool") -> "PjUriBuilder": + _UniffiConverterBool.check_lower(pjos) + + return _UniffiConverterTypePjUriBuilder.lift( + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_pjuribuilder_pjos,self._uniffi_clone_pointer(), + _UniffiConverterBool.lower(pjos)) + ) + + + + + + +class _UniffiConverterTypePjUriBuilder: + + @staticmethod + def lift(value: int): + return PjUriBuilder._make_instance_(value) + + @staticmethod + def check_lower(value: PjUriBuilder): + if not isinstance(value, PjUriBuilder): + raise TypeError("Expected PjUriBuilder instance, {} found".format(type(value).__name__)) + + @staticmethod + def lower(value: PjUriBuilderProtocol): + if not isinstance(value, PjUriBuilder): + raise TypeError("Expected PjUriBuilder instance, {} found".format(type(value).__name__)) + return value._uniffi_clone_pointer() + + @classmethod + def read(cls, buf: _UniffiRustBuffer): + ptr = buf.read_u64() + if ptr == 0: + raise InternalError("Raw pointer value was null") + return cls.lift(ptr) + + @classmethod + def write(cls, value: PjUriBuilderProtocol, buf: _UniffiRustBuffer): + buf.write_u64(cls.lower(value)) + + + +class ProvisionalProposalProtocol(typing.Protocol): + def contribute_witness_input(self, txout: "TxOut",outpoint: "OutPoint"): + raise NotImplementedError + def finalize_proposal(self, process_psbt: "ProcessPartiallySignedTransaction",min_feerate_sat_per_vb: "typing.Optional[int]"): + raise NotImplementedError + def try_preserving_privacy(self, candidate_inputs: "dict[int, OutPoint]"): + raise NotImplementedError + def try_substitute_receiver_output(self, generate_script: "GenerateScript"): + raise NotImplementedError + + +class ProvisionalProposal: + _pointer: ctypes.c_void_p + + def __init__(self, *args, **kwargs): + raise ValueError("This class has no default constructor") + + def __del__(self): + # In case of partial initialization of instances. + pointer = getattr(self, "_pointer", None) + if pointer is not None: + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_provisionalproposal, pointer) + + def _uniffi_clone_pointer(self): + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_provisionalproposal, self._pointer) + + # Used by alternative constructors or any methods which return this type. + @classmethod + def _make_instance_(cls, pointer): + # Lightly yucky way to bypass the usual __init__ logic + # and just create a new instance with the required pointer. + inst = cls.__new__(cls) + inst._pointer = pointer + return inst + def contribute_witness_input(self, txout: "TxOut",outpoint: "OutPoint") -> None: _UniffiConverterTypeTxOut.check_lower(txout) _UniffiConverterTypeOutPoint.check_lower(outpoint) - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_provisionalproposal_contribute_witness_input,self._uniffi_clone_pointer(), + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_provisionalproposal_contribute_witness_input,self._uniffi_clone_pointer(), _UniffiConverterTypeTxOut.lower(txout), _UniffiConverterTypeOutPoint.lower(outpoint)) @@ -2982,7 +3218,7 @@ def finalize_proposal(self, process_psbt: "ProcessPartiallySignedTransaction",mi _UniffiConverterOptionalUInt64.check_lower(min_feerate_sat_per_vb) return _UniffiConverterTypePayjoinProposal.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_provisionalproposal_finalize_proposal,self._uniffi_clone_pointer(), + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_provisionalproposal_finalize_proposal,self._uniffi_clone_pointer(), _UniffiConverterCallbackInterfaceProcessPartiallySignedTransaction.lower(process_psbt), _UniffiConverterOptionalUInt64.lower(min_feerate_sat_per_vb)) ) @@ -2991,24 +3227,24 @@ def finalize_proposal(self, process_psbt: "ProcessPartiallySignedTransaction",mi - def substitute_output_address(self, substitute_address: "str") -> None: - _UniffiConverterString.check_lower(substitute_address) + def try_preserving_privacy(self, candidate_inputs: "dict[int, OutPoint]") -> "OutPoint": + _UniffiConverterMapUInt64TypeOutPoint.check_lower(candidate_inputs) - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_provisionalproposal_substitute_output_address,self._uniffi_clone_pointer(), - _UniffiConverterString.lower(substitute_address)) - + return _UniffiConverterTypeOutPoint.lift( + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_provisionalproposal_try_preserving_privacy,self._uniffi_clone_pointer(), + _UniffiConverterMapUInt64TypeOutPoint.lower(candidate_inputs)) + ) - def try_preserving_privacy(self, candidate_inputs: "dict[int, OutPoint]") -> "OutPoint": - _UniffiConverterMapUInt64TypeOutPoint.check_lower(candidate_inputs) + def try_substitute_receiver_output(self, generate_script: "GenerateScript") -> None: + _UniffiConverterCallbackInterfaceGenerateScript.check_lower(generate_script) - return _UniffiConverterTypeOutPoint.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_provisionalproposal_try_preserving_privacy,self._uniffi_clone_pointer(), - _UniffiConverterMapUInt64TypeOutPoint.lower(candidate_inputs)) - ) + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_provisionalproposal_try_substitute_receiver_output,self._uniffi_clone_pointer(), + _UniffiConverterCallbackInterfaceGenerateScript.lower(generate_script)) + @@ -3048,7 +3284,7 @@ def write(cls, value: ProvisionalProposalProtocol, buf: _UniffiRustBuffer): class RequestBuilderProtocol(typing.Protocol): def always_disable_output_substitution(self, disable: "bool"): raise NotImplementedError - def build_non_incentivizing(self, ): + def build_non_incentivizing(self, min_fee_rate: "int"): raise NotImplementedError def build_recommended(self, min_fee_rate: "int"): raise NotImplementedError @@ -3066,10 +3302,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_requestbuilder, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_requestbuilder, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_requestbuilder, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_requestbuilder, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -3081,15 +3317,15 @@ def _make_instance_(cls, pointer): return inst @classmethod - def from_psbt_and_uri(cls, psbt: "str",uri: "Uri"): + def from_psbt_and_uri(cls, psbt: "str",uri: "PjUri"): _UniffiConverterString.check_lower(psbt) - _UniffiConverterTypeUri.check_lower(uri) + _UniffiConverterTypePjUri.check_lower(uri) # Call the (fallible) function before creating any half-baked object instances. - pointer = _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_constructor_requestbuilder_from_psbt_and_uri, + pointer = _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_constructor_requestbuilder_from_psbt_and_uri, _UniffiConverterString.lower(psbt), - _UniffiConverterTypeUri.lower(uri)) + _UniffiConverterTypePjUri.lower(uri)) return cls._make_instance_(pointer) @@ -3098,7 +3334,7 @@ def always_disable_output_substitution(self, disable: "bool") -> "RequestBuilder _UniffiConverterBool.check_lower(disable) return _UniffiConverterTypeRequestBuilder.lift( - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_requestbuilder_always_disable_output_substitution,self._uniffi_clone_pointer(), + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_requestbuilder_always_disable_output_substitution,self._uniffi_clone_pointer(), _UniffiConverterBool.lower(disable)) ) @@ -3106,9 +3342,12 @@ def always_disable_output_substitution(self, disable: "bool") -> "RequestBuilder - def build_non_incentivizing(self, ) -> "RequestContext": + def build_non_incentivizing(self, min_fee_rate: "int") -> "RequestContext": + _UniffiConverterUInt64.check_lower(min_fee_rate) + return _UniffiConverterTypeRequestContext.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_requestbuilder_build_non_incentivizing,self._uniffi_clone_pointer(),) + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_requestbuilder_build_non_incentivizing,self._uniffi_clone_pointer(), + _UniffiConverterUInt64.lower(min_fee_rate)) ) @@ -3119,7 +3358,7 @@ def build_recommended(self, min_fee_rate: "int") -> "RequestContext": _UniffiConverterUInt64.check_lower(min_fee_rate) return _UniffiConverterTypeRequestContext.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_requestbuilder_build_recommended,self._uniffi_clone_pointer(), + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_requestbuilder_build_recommended,self._uniffi_clone_pointer(), _UniffiConverterUInt64.lower(min_fee_rate)) ) @@ -3137,7 +3376,7 @@ def build_with_additional_fee(self, max_fee_contribution: "int",change_index: "t _UniffiConverterBool.check_lower(clamp_fee_contribution) return _UniffiConverterTypeRequestContext.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_requestbuilder_build_with_additional_fee,self._uniffi_clone_pointer(), + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_requestbuilder_build_with_additional_fee,self._uniffi_clone_pointer(), _UniffiConverterUInt64.lower(max_fee_contribution), _UniffiConverterOptionalUInt8.lower(change_index), _UniffiConverterUInt64.lower(min_fee_rate), @@ -3196,10 +3435,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_requestcontext, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_requestcontext, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_requestcontext, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_requestcontext, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -3213,7 +3452,7 @@ def _make_instance_(cls, pointer): def extract_v1(self, ) -> "RequestContextV1": return _UniffiConverterTypeRequestContextV1.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_requestcontext_extract_v1,self._uniffi_clone_pointer(),) + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_requestcontext_extract_v1,self._uniffi_clone_pointer(),) ) @@ -3224,7 +3463,7 @@ def extract_v2(self, ohttp_proxy_url: "Url") -> "RequestContextV2": _UniffiConverterTypeUrl.check_lower(ohttp_proxy_url) return _UniffiConverterTypeRequestContextV2.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_requestcontext_extract_v2,self._uniffi_clone_pointer(), + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_requestcontext_extract_v2,self._uniffi_clone_pointer(), _UniffiConverterTypeUrl.lower(ohttp_proxy_url)) ) @@ -3263,6 +3502,110 @@ def write(cls, value: RequestContextProtocol, buf: _UniffiRustBuffer): +class SessionInitializerProtocol(typing.Protocol): + def extract_req(self, ): + raise NotImplementedError + def process_res(self, body: "typing.List[int]",ctx: "ClientResponse"): + raise NotImplementedError + + +class SessionInitializer: + _pointer: ctypes.c_void_p + def __init__(self, address: "str",expire_after: "typing.Optional[int]",network: "Network",directory: "Url",ohttp_keys: "OhttpKeys",ohttp_relay: "Url"): + _UniffiConverterString.check_lower(address) + + _UniffiConverterOptionalUInt64.check_lower(expire_after) + + _UniffiConverterTypeNetwork.check_lower(network) + + _UniffiConverterTypeUrl.check_lower(directory) + + _UniffiConverterTypeOhttpKeys.check_lower(ohttp_keys) + + _UniffiConverterTypeUrl.check_lower(ohttp_relay) + + self._pointer = _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_constructor_sessioninitializer_new, + _UniffiConverterString.lower(address), + _UniffiConverterOptionalUInt64.lower(expire_after), + _UniffiConverterTypeNetwork.lower(network), + _UniffiConverterTypeUrl.lower(directory), + _UniffiConverterTypeOhttpKeys.lower(ohttp_keys), + _UniffiConverterTypeUrl.lower(ohttp_relay)) + + def __del__(self): + # In case of partial initialization of instances. + pointer = getattr(self, "_pointer", None) + if pointer is not None: + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_sessioninitializer, pointer) + + def _uniffi_clone_pointer(self): + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_sessioninitializer, self._pointer) + + # Used by alternative constructors or any methods which return this type. + @classmethod + def _make_instance_(cls, pointer): + # Lightly yucky way to bypass the usual __init__ logic + # and just create a new instance with the required pointer. + inst = cls.__new__(cls) + inst._pointer = pointer + return inst + + + def extract_req(self, ) -> "RequestResponse": + return _UniffiConverterTypeRequestResponse.lift( + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_sessioninitializer_extract_req,self._uniffi_clone_pointer(),) + ) + + + + + + def process_res(self, body: "typing.List[int]",ctx: "ClientResponse") -> "ActiveSession": + _UniffiConverterSequenceUInt8.check_lower(body) + + _UniffiConverterTypeClientResponse.check_lower(ctx) + + return _UniffiConverterTypeActiveSession.lift( + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_sessioninitializer_process_res,self._uniffi_clone_pointer(), + _UniffiConverterSequenceUInt8.lower(body), + _UniffiConverterTypeClientResponse.lower(ctx)) + ) + + + + + + +class _UniffiConverterTypeSessionInitializer: + + @staticmethod + def lift(value: int): + return SessionInitializer._make_instance_(value) + + @staticmethod + def check_lower(value: SessionInitializer): + if not isinstance(value, SessionInitializer): + raise TypeError("Expected SessionInitializer instance, {} found".format(type(value).__name__)) + + @staticmethod + def lower(value: SessionInitializerProtocol): + if not isinstance(value, SessionInitializer): + raise TypeError("Expected SessionInitializer instance, {} found".format(type(value).__name__)) + return value._uniffi_clone_pointer() + + @classmethod + def read(cls, buf: _UniffiRustBuffer): + ptr = buf.read_u64() + if ptr == 0: + raise InternalError("Raw pointer value was null") + return cls.lift(ptr) + + @classmethod + def write(cls, value: SessionInitializerProtocol, buf: _UniffiRustBuffer): + buf.write_u64(cls.lower(value)) + + + class UncheckedProposalProtocol(typing.Protocol): def assume_interactive_receiver(self, ): raise NotImplementedError @@ -3282,10 +3625,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_uncheckedproposal, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_uncheckedproposal, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_uncheckedproposal, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_uncheckedproposal, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -3305,7 +3648,7 @@ def from_request(cls, body: "typing.List[int]",query: "str",headers: "Headers"): _UniffiConverterTypeHeaders.check_lower(headers) # Call the (fallible) function before creating any half-baked object instances. - pointer = _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_constructor_uncheckedproposal_from_request, + pointer = _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_constructor_uncheckedproposal_from_request, _UniffiConverterSequenceUInt8.lower(body), _UniffiConverterString.lower(query), _UniffiConverterTypeHeaders.lower(headers)) @@ -3315,7 +3658,7 @@ def from_request(cls, body: "typing.List[int]",query: "str",headers: "Headers"): def assume_interactive_receiver(self, ) -> "MaybeInputsOwned": return _UniffiConverterTypeMaybeInputsOwned.lift( - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_uncheckedproposal_assume_interactive_receiver,self._uniffi_clone_pointer(),) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_uncheckedproposal_assume_interactive_receiver,self._uniffi_clone_pointer(),) ) @@ -3328,7 +3671,7 @@ def check_broadcast_suitability(self, min_fee_rate: "typing.Optional[int]",can_b _UniffiConverterCallbackInterfaceCanBroadcast.check_lower(can_broadcast) return _UniffiConverterTypeMaybeInputsOwned.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_uncheckedproposal_check_broadcast_suitability,self._uniffi_clone_pointer(), + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_uncheckedproposal_check_broadcast_suitability,self._uniffi_clone_pointer(), _UniffiConverterOptionalUInt64.lower(min_fee_rate), _UniffiConverterCallbackInterfaceCanBroadcast.lower(can_broadcast)) ) @@ -3339,7 +3682,7 @@ def check_broadcast_suitability(self, min_fee_rate: "typing.Optional[int]",can_b def extract_tx_to_schedule_broadcast(self, ) -> "typing.List[int]": return _UniffiConverterSequenceUInt8.lift( - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_uncheckedproposal_extract_tx_to_schedule_broadcast,self._uniffi_clone_pointer(),) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_uncheckedproposal_extract_tx_to_schedule_broadcast,self._uniffi_clone_pointer(),) ) @@ -3382,6 +3725,10 @@ def address(self, ): raise NotImplementedError def amount(self, ): raise NotImplementedError + def as_string(self, ): + raise NotImplementedError + def check_pj_supported(self, ): + raise NotImplementedError class Uri: @@ -3394,10 +3741,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_uri, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_uri, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_uri, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_uri, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -3413,7 +3760,7 @@ def from_str(cls, uri: "str"): _UniffiConverterString.check_lower(uri) # Call the (fallible) function before creating any half-baked object instances. - pointer = _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_constructor_uri_from_str, + pointer = _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_constructor_uri_from_str, _UniffiConverterString.lower(uri)) return cls._make_instance_(pointer) @@ -3421,7 +3768,7 @@ def from_str(cls, uri: "str"): def address(self, ) -> "str": return _UniffiConverterString.lift( - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_uri_address,self._uniffi_clone_pointer(),) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_uri_address,self._uniffi_clone_pointer(),) ) @@ -3430,7 +3777,25 @@ def address(self, ) -> "str": def amount(self, ) -> "typing.Optional[float]": return _UniffiConverterOptionalDouble.lift( - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_uri_amount,self._uniffi_clone_pointer(),) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_uri_amount,self._uniffi_clone_pointer(),) + ) + + + + + + def as_string(self, ) -> "str": + return _UniffiConverterString.lift( + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_uri_as_string,self._uniffi_clone_pointer(),) + ) + + + + + + def check_pj_supported(self, ) -> "PjUri": + return _UniffiConverterTypePjUri.lift( + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_uri_check_pj_supported,self._uniffi_clone_pointer(),) ) @@ -3485,10 +3850,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_url, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_url, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_url, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_url, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -3504,7 +3869,7 @@ def from_str(cls, input: "str"): _UniffiConverterString.check_lower(input) # Call the (fallible) function before creating any half-baked object instances. - pointer = _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_constructor_url_from_str, + pointer = _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_constructor_url_from_str, _UniffiConverterString.lower(input)) return cls._make_instance_(pointer) @@ -3512,7 +3877,7 @@ def from_str(cls, input: "str"): def as_string(self, ) -> "str": return _UniffiConverterString.lift( - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_url_as_string,self._uniffi_clone_pointer(),) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_url_as_string,self._uniffi_clone_pointer(),) ) @@ -3521,7 +3886,7 @@ def as_string(self, ) -> "str": def query(self, ) -> "typing.Optional[str]": return _UniffiConverterOptionalString.lift( - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_url_query,self._uniffi_clone_pointer(),) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_url_query,self._uniffi_clone_pointer(),) ) @@ -3574,10 +3939,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_v2maybeinputsowned, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_v2maybeinputsowned, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_v2maybeinputsowned, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_v2maybeinputsowned, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -3593,7 +3958,7 @@ def check_inputs_not_owned(self, is_owned: "IsScriptOwned") -> "V2MaybeMixedInpu _UniffiConverterCallbackInterfaceIsScriptOwned.check_lower(is_owned) return _UniffiConverterTypeV2MaybeMixedInputScripts.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_v2maybeinputsowned_check_inputs_not_owned,self._uniffi_clone_pointer(), + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_v2maybeinputsowned_check_inputs_not_owned,self._uniffi_clone_pointer(), _UniffiConverterCallbackInterfaceIsScriptOwned.lower(is_owned)) ) @@ -3647,10 +4012,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_v2maybeinputsseen, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_v2maybeinputsseen, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_v2maybeinputsseen, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_v2maybeinputsseen, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -3666,7 +4031,7 @@ def check_no_inputs_seen_before(self, is_known: "IsOutputKnown") -> "V2OutputsUn _UniffiConverterCallbackInterfaceIsOutputKnown.check_lower(is_known) return _UniffiConverterTypeV2OutputsUnknown.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_v2maybeinputsseen_check_no_inputs_seen_before,self._uniffi_clone_pointer(), + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_v2maybeinputsseen_check_no_inputs_seen_before,self._uniffi_clone_pointer(), _UniffiConverterCallbackInterfaceIsOutputKnown.lower(is_known)) ) @@ -3720,10 +4085,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_v2maybemixedinputscripts, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_v2maybemixedinputscripts, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_v2maybemixedinputscripts, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_v2maybemixedinputscripts, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -3737,7 +4102,7 @@ def _make_instance_(cls, pointer): def check_no_mixed_input_scripts(self, ) -> "V2MaybeInputsSeen": return _UniffiConverterTypeV2MaybeInputsSeen.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_v2maybemixedinputscripts_check_no_mixed_input_scripts,self._uniffi_clone_pointer(),) + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_v2maybemixedinputscripts_check_no_mixed_input_scripts,self._uniffi_clone_pointer(),) ) @@ -3790,10 +4155,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_v2outputsunknown, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_v2outputsunknown, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_v2outputsunknown, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_v2outputsunknown, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -3809,7 +4174,7 @@ def identify_receiver_outputs(self, is_receiver_output: "IsScriptOwned") -> "V2P _UniffiConverterCallbackInterfaceIsScriptOwned.check_lower(is_receiver_output) return _UniffiConverterTypeV2ProvisionalProposal.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_v2outputsunknown_identify_receiver_outputs,self._uniffi_clone_pointer(), + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_v2outputsunknown_identify_receiver_outputs,self._uniffi_clone_pointer(), _UniffiConverterCallbackInterfaceIsScriptOwned.lower(is_receiver_output)) ) @@ -3849,12 +4214,16 @@ def write(cls, value: V2OutputsUnknownProtocol, buf: _UniffiRustBuffer): class V2PayjoinProposalProtocol(typing.Protocol): - def deserialize_res(self, res: "typing.List[int]",ohttp_context: "ClientResponse"): + def extract_v1_req(self, ): + raise NotImplementedError + def extract_v2_req(self, ): raise NotImplementedError def is_output_substitution_disabled(self, ): raise NotImplementedError def owned_vouts(self, ): raise NotImplementedError + def process_res(self, res: "typing.List[int]",ohttp_context: "ClientResponse"): + raise NotImplementedError def psbt(self, ): raise NotImplementedError def utxos_to_be_locked(self, ): @@ -3871,10 +4240,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_v2payjoinproposal, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_v2payjoinproposal, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_v2payjoinproposal, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_v2payjoinproposal, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -3886,15 +4255,18 @@ def _make_instance_(cls, pointer): return inst - def deserialize_res(self, res: "typing.List[int]",ohttp_context: "ClientResponse") -> "typing.List[int]": - _UniffiConverterSequenceUInt8.check_lower(res) - - _UniffiConverterTypeClientResponse.check_lower(ohttp_context) - - return _UniffiConverterSequenceUInt8.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_v2payjoinproposal_deserialize_res,self._uniffi_clone_pointer(), - _UniffiConverterSequenceUInt8.lower(res), - _UniffiConverterTypeClientResponse.lower(ohttp_context)) + def extract_v1_req(self, ) -> "str": + return _UniffiConverterString.lift( + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_v2payjoinproposal_extract_v1_req,self._uniffi_clone_pointer(),) + ) + + + + + + def extract_v2_req(self, ) -> "RequestResponse": + return _UniffiConverterTypeRequestResponse.lift( + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_v2payjoinproposal_extract_v2_req,self._uniffi_clone_pointer(),) ) @@ -3903,7 +4275,7 @@ def deserialize_res(self, res: "typing.List[int]",ohttp_context: "ClientResponse def is_output_substitution_disabled(self, ) -> "bool": return _UniffiConverterBool.lift( - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_v2payjoinproposal_is_output_substitution_disabled,self._uniffi_clone_pointer(),) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_v2payjoinproposal_is_output_substitution_disabled,self._uniffi_clone_pointer(),) ) @@ -3912,16 +4284,30 @@ def is_output_substitution_disabled(self, ) -> "bool": def owned_vouts(self, ) -> "typing.List[int]": return _UniffiConverterSequenceUInt64.lift( - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_v2payjoinproposal_owned_vouts,self._uniffi_clone_pointer(),) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_v2payjoinproposal_owned_vouts,self._uniffi_clone_pointer(),) ) + def process_res(self, res: "typing.List[int]",ohttp_context: "ClientResponse") -> None: + _UniffiConverterSequenceUInt8.check_lower(res) + + _UniffiConverterTypeClientResponse.check_lower(ohttp_context) + + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_v2payjoinproposal_process_res,self._uniffi_clone_pointer(), + _UniffiConverterSequenceUInt8.lower(res), + _UniffiConverterTypeClientResponse.lower(ohttp_context)) + + + + + + def psbt(self, ) -> "str": return _UniffiConverterString.lift( - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_v2payjoinproposal_psbt,self._uniffi_clone_pointer(),) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_v2payjoinproposal_psbt,self._uniffi_clone_pointer(),) ) @@ -3930,7 +4316,7 @@ def psbt(self, ) -> "str": def utxos_to_be_locked(self, ) -> "typing.List[OutPoint]": return _UniffiConverterSequenceTypeOutPoint.lift( - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_v2payjoinproposal_utxos_to_be_locked,self._uniffi_clone_pointer(),) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_v2payjoinproposal_utxos_to_be_locked,self._uniffi_clone_pointer(),) ) @@ -3969,16 +4355,14 @@ def write(cls, value: V2PayjoinProposalProtocol, buf: _UniffiRustBuffer): class V2ProvisionalProposalProtocol(typing.Protocol): - def contribute_non_witness_input(self, tx: "typing.List[int]",outpoint: "OutPoint"): - raise NotImplementedError def contribute_witness_input(self, txout: "TxOut",outpoint: "OutPoint"): raise NotImplementedError def finalize_proposal(self, process_psbt: "ProcessPartiallySignedTransaction",min_feerate_sat_per_vb: "typing.Optional[int]"): raise NotImplementedError - def substitute_output_address(self, substitute_address: "str"): - raise NotImplementedError def try_preserving_privacy(self, candidate_inputs: "dict[int, OutPoint]"): raise NotImplementedError + def try_substitute_receiver_output(self, generate_script: "GenerateScript"): + raise NotImplementedError class V2ProvisionalProposal: @@ -3991,10 +4375,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_v2provisionalproposal, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_v2provisionalproposal, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_v2provisionalproposal, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_v2provisionalproposal, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -4006,26 +4390,12 @@ def _make_instance_(cls, pointer): return inst - def contribute_non_witness_input(self, tx: "typing.List[int]",outpoint: "OutPoint") -> None: - _UniffiConverterSequenceUInt8.check_lower(tx) - - _UniffiConverterTypeOutPoint.check_lower(outpoint) - - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_v2provisionalproposal_contribute_non_witness_input,self._uniffi_clone_pointer(), - _UniffiConverterSequenceUInt8.lower(tx), - _UniffiConverterTypeOutPoint.lower(outpoint)) - - - - - - def contribute_witness_input(self, txout: "TxOut",outpoint: "OutPoint") -> None: _UniffiConverterTypeTxOut.check_lower(txout) _UniffiConverterTypeOutPoint.check_lower(outpoint) - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_v2provisionalproposal_contribute_witness_input,self._uniffi_clone_pointer(), + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_v2provisionalproposal_contribute_witness_input,self._uniffi_clone_pointer(), _UniffiConverterTypeTxOut.lower(txout), _UniffiConverterTypeOutPoint.lower(outpoint)) @@ -4040,7 +4410,7 @@ def finalize_proposal(self, process_psbt: "ProcessPartiallySignedTransaction",mi _UniffiConverterOptionalUInt64.check_lower(min_feerate_sat_per_vb) return _UniffiConverterTypeV2PayjoinProposal.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_v2provisionalproposal_finalize_proposal,self._uniffi_clone_pointer(), + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_v2provisionalproposal_finalize_proposal,self._uniffi_clone_pointer(), _UniffiConverterCallbackInterfaceProcessPartiallySignedTransaction.lower(process_psbt), _UniffiConverterOptionalUInt64.lower(min_feerate_sat_per_vb)) ) @@ -4049,24 +4419,24 @@ def finalize_proposal(self, process_psbt: "ProcessPartiallySignedTransaction",mi - def substitute_output_address(self, substitute_address: "str") -> None: - _UniffiConverterString.check_lower(substitute_address) + def try_preserving_privacy(self, candidate_inputs: "dict[int, OutPoint]") -> "OutPoint": + _UniffiConverterMapUInt64TypeOutPoint.check_lower(candidate_inputs) - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_v2provisionalproposal_substitute_output_address,self._uniffi_clone_pointer(), - _UniffiConverterString.lower(substitute_address)) - + return _UniffiConverterTypeOutPoint.lift( + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_v2provisionalproposal_try_preserving_privacy,self._uniffi_clone_pointer(), + _UniffiConverterMapUInt64TypeOutPoint.lower(candidate_inputs)) + ) - def try_preserving_privacy(self, candidate_inputs: "dict[int, OutPoint]") -> "OutPoint": - _UniffiConverterMapUInt64TypeOutPoint.check_lower(candidate_inputs) + def try_substitute_receiver_output(self, generate_script: "GenerateScript") -> None: + _UniffiConverterCallbackInterfaceGenerateScript.check_lower(generate_script) - return _UniffiConverterTypeOutPoint.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_v2provisionalproposal_try_preserving_privacy,self._uniffi_clone_pointer(), - _UniffiConverterMapUInt64TypeOutPoint.lower(candidate_inputs)) - ) + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_v2provisionalproposal_try_substitute_receiver_output,self._uniffi_clone_pointer(), + _UniffiConverterCallbackInterfaceGenerateScript.lower(generate_script)) + @@ -4122,10 +4492,10 @@ def __del__(self): # In case of partial initialization of instances. pointer = getattr(self, "_pointer", None) if pointer is not None: - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_v2uncheckedproposal, pointer) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_free_v2uncheckedproposal, pointer) def _uniffi_clone_pointer(self): - return _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_v2uncheckedproposal, self._pointer) + return _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_clone_v2uncheckedproposal, self._pointer) # Used by alternative constructors or any methods which return this type. @classmethod @@ -4139,7 +4509,7 @@ def _make_instance_(cls, pointer): def assume_interactive_receiver(self, ) -> "V2MaybeInputsOwned": return _UniffiConverterTypeV2MaybeInputsOwned.lift( - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_v2uncheckedproposal_assume_interactive_receiver,self._uniffi_clone_pointer(),) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_v2uncheckedproposal_assume_interactive_receiver,self._uniffi_clone_pointer(),) ) @@ -4152,7 +4522,7 @@ def check_broadcast_suitability(self, min_fee_rate: "typing.Optional[int]",can_b _UniffiConverterCallbackInterfaceCanBroadcast.check_lower(can_broadcast) return _UniffiConverterTypeV2MaybeInputsOwned.lift( - _rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_v2uncheckedproposal_check_broadcast_suitability,self._uniffi_clone_pointer(), + _uniffi_rust_call_with_error(_UniffiConverterTypePayjoinError,_UniffiLib.uniffi_payjoin_ffi_fn_method_v2uncheckedproposal_check_broadcast_suitability,self._uniffi_clone_pointer(), _UniffiConverterOptionalUInt64.lower(min_fee_rate), _UniffiConverterCallbackInterfaceCanBroadcast.lower(can_broadcast)) ) @@ -4163,7 +4533,7 @@ def check_broadcast_suitability(self, min_fee_rate: "typing.Optional[int]",can_b def extract_tx_to_schedule_broadcast(self, ) -> "typing.List[int]": return _UniffiConverterSequenceUInt8.lift( - _rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_v2uncheckedproposal_extract_tx_to_schedule_broadcast,self._uniffi_clone_pointer(),) + _uniffi_rust_call(_UniffiLib.uniffi_payjoin_ffi_fn_method_v2uncheckedproposal_extract_tx_to_schedule_broadcast,self._uniffi_clone_pointer(),) ) @@ -4203,7 +4573,6 @@ def write(cls, value: V2UncheckedProposalProtocol, buf: _UniffiRustBuffer): class OutPoint: txid: "str" vout: "int" - @typing.no_type_check def __init__(self, *, txid: "str", vout: "int"): self.txid = txid self.vout = vout @@ -4240,7 +4609,6 @@ def write(value, buf): class Request: url: "Url" body: "typing.List[int]" - @typing.no_type_check def __init__(self, *, url: "Url", body: "typing.List[int]"): self.url = url self.body = body @@ -4277,7 +4645,6 @@ def write(value, buf): class RequestContextV1: request: "Request" context_v1: "ContextV1" - @typing.no_type_check def __init__(self, *, request: "Request", context_v1: "ContextV1"): self.request = request self.context_v1 = context_v1 @@ -4314,7 +4681,6 @@ def write(value, buf): class RequestContextV2: request: "Request" context_v2: "ContextV2" - @typing.no_type_check def __init__(self, *, request: "Request", context_v2: "ContextV2"): self.request = request self.context_v2 = context_v2 @@ -4351,7 +4717,6 @@ def write(value, buf): class RequestResponse: request: "Request" client_response: "ClientResponse" - @typing.no_type_check def __init__(self, *, request: "Request", client_response: "ClientResponse"): self.request = request self.client_response = client_response @@ -4388,7 +4753,6 @@ def write(value, buf): class TxOut: value: "int" script_pubkey: "typing.List[int]" - @typing.no_type_check def __init__(self, *, value: "int", script_pubkey: "typing.List[int]"): self.value = value self.script_pubkey = script_pubkey @@ -4488,175 +4852,185 @@ class PayjoinError(Exception): class PayjoinError: # type: ignore class InvalidAddress(_UniffiTempPayjoinError): - def __init__(self, message): super().__init__(", ".join([ "message={!r}".format(message), ])) self.message = message + def __repr__(self): return "PayjoinError.InvalidAddress({})".format(str(self)) _UniffiTempPayjoinError.InvalidAddress = InvalidAddress # type: ignore class InvalidScript(_UniffiTempPayjoinError): - def __init__(self, message): super().__init__(", ".join([ "message={!r}".format(message), ])) self.message = message + def __repr__(self): return "PayjoinError.InvalidScript({})".format(str(self)) _UniffiTempPayjoinError.InvalidScript = InvalidScript # type: ignore class PsbtParseError(_UniffiTempPayjoinError): - def __init__(self, message): super().__init__(", ".join([ "message={!r}".format(message), ])) self.message = message + def __repr__(self): return "PayjoinError.PsbtParseError({})".format(str(self)) _UniffiTempPayjoinError.PsbtParseError = PsbtParseError # type: ignore class ResponseError(_UniffiTempPayjoinError): - def __init__(self, message): super().__init__(", ".join([ "message={!r}".format(message), ])) self.message = message + def __repr__(self): return "PayjoinError.ResponseError({})".format(str(self)) _UniffiTempPayjoinError.ResponseError = ResponseError # type: ignore class RequestError(_UniffiTempPayjoinError): - def __init__(self, message): super().__init__(", ".join([ "message={!r}".format(message), ])) self.message = message + def __repr__(self): return "PayjoinError.RequestError({})".format(str(self)) _UniffiTempPayjoinError.RequestError = RequestError # type: ignore class SelectionError(_UniffiTempPayjoinError): - def __init__(self, message): super().__init__(", ".join([ "message={!r}".format(message), ])) self.message = message + def __repr__(self): return "PayjoinError.SelectionError({})".format(str(self)) _UniffiTempPayjoinError.SelectionError = SelectionError # type: ignore class CreateRequestError(_UniffiTempPayjoinError): - def __init__(self, message): super().__init__(", ".join([ "message={!r}".format(message), ])) self.message = message + def __repr__(self): return "PayjoinError.CreateRequestError({})".format(str(self)) _UniffiTempPayjoinError.CreateRequestError = CreateRequestError # type: ignore class PjParseError(_UniffiTempPayjoinError): - def __init__(self, message): super().__init__(", ".join([ "message={!r}".format(message), ])) self.message = message + def __repr__(self): return "PayjoinError.PjParseError({})".format(str(self)) _UniffiTempPayjoinError.PjParseError = PjParseError # type: ignore class PjNotSupported(_UniffiTempPayjoinError): - def __init__(self, message): super().__init__(", ".join([ "message={!r}".format(message), ])) self.message = message + def __repr__(self): return "PayjoinError.PjNotSupported({})".format(str(self)) _UniffiTempPayjoinError.PjNotSupported = PjNotSupported # type: ignore class V2Error(_UniffiTempPayjoinError): - def __init__(self, message): super().__init__(", ".join([ "message={!r}".format(message), ])) self.message = message + def __repr__(self): return "PayjoinError.V2Error({})".format(str(self)) _UniffiTempPayjoinError.V2Error = V2Error # type: ignore class ValidationError(_UniffiTempPayjoinError): - def __init__(self, message): super().__init__(", ".join([ "message={!r}".format(message), ])) self.message = message + def __repr__(self): return "PayjoinError.ValidationError({})".format(str(self)) _UniffiTempPayjoinError.ValidationError = ValidationError # type: ignore class TransactionError(_UniffiTempPayjoinError): - def __init__(self, message): super().__init__(", ".join([ "message={!r}".format(message), ])) self.message = message + def __repr__(self): return "PayjoinError.TransactionError({})".format(str(self)) _UniffiTempPayjoinError.TransactionError = TransactionError # type: ignore class UnexpectedError(_UniffiTempPayjoinError): - def __init__(self, message): super().__init__(", ".join([ "message={!r}".format(message), ])) self.message = message + def __repr__(self): return "PayjoinError.UnexpectedError({})".format(str(self)) _UniffiTempPayjoinError.UnexpectedError = UnexpectedError # type: ignore class ServerError(_UniffiTempPayjoinError): - def __init__(self, message): super().__init__(", ".join([ "message={!r}".format(message), ])) self.message = message + def __repr__(self): return "PayjoinError.ServerError({})".format(str(self)) _UniffiTempPayjoinError.ServerError = ServerError # type: ignore class NetworkValidation(_UniffiTempPayjoinError): - def __init__(self, message): super().__init__(", ".join([ "message={!r}".format(message), ])) self.message = message + def __repr__(self): return "PayjoinError.NetworkValidation({})".format(str(self)) _UniffiTempPayjoinError.NetworkValidation = NetworkValidation # type: ignore class OhttpError(_UniffiTempPayjoinError): - def __init__(self, message): super().__init__(", ".join([ "message={!r}".format(message), ])) self.message = message + def __repr__(self): return "PayjoinError.OhttpError({})".format(str(self)) _UniffiTempPayjoinError.OhttpError = OhttpError # type: ignore class UrlError(_UniffiTempPayjoinError): - def __init__(self, message): super().__init__(", ".join([ "message={!r}".format(message), ])) self.message = message + def __repr__(self): return "PayjoinError.UrlError({})".format(str(self)) _UniffiTempPayjoinError.UrlError = UrlError # type: ignore + class IoError(_UniffiTempPayjoinError): + def __init__(self, message): + super().__init__(", ".join([ + "message={!r}".format(message), + ])) + self.message = message + + def __repr__(self): + return "PayjoinError.IoError({})".format(str(self)) + _UniffiTempPayjoinError.IoError = IoError # type: ignore PayjoinError = _UniffiTempPayjoinError # type: ignore del _UniffiTempPayjoinError @@ -4668,71 +5042,75 @@ def read(buf): variant = buf.read_i32() if variant == 1: return PayjoinError.InvalidAddress( - message=_UniffiConverterString.read(buf), + _UniffiConverterString.read(buf), ) if variant == 2: return PayjoinError.InvalidScript( - message=_UniffiConverterString.read(buf), + _UniffiConverterString.read(buf), ) if variant == 3: return PayjoinError.PsbtParseError( - message=_UniffiConverterString.read(buf), + _UniffiConverterString.read(buf), ) if variant == 4: return PayjoinError.ResponseError( - message=_UniffiConverterString.read(buf), + _UniffiConverterString.read(buf), ) if variant == 5: return PayjoinError.RequestError( - message=_UniffiConverterString.read(buf), + _UniffiConverterString.read(buf), ) if variant == 6: return PayjoinError.SelectionError( - message=_UniffiConverterString.read(buf), + _UniffiConverterString.read(buf), ) if variant == 7: return PayjoinError.CreateRequestError( - message=_UniffiConverterString.read(buf), + _UniffiConverterString.read(buf), ) if variant == 8: return PayjoinError.PjParseError( - message=_UniffiConverterString.read(buf), + _UniffiConverterString.read(buf), ) if variant == 9: return PayjoinError.PjNotSupported( - message=_UniffiConverterString.read(buf), + _UniffiConverterString.read(buf), ) if variant == 10: return PayjoinError.V2Error( - message=_UniffiConverterString.read(buf), + _UniffiConverterString.read(buf), ) if variant == 11: return PayjoinError.ValidationError( - message=_UniffiConverterString.read(buf), + _UniffiConverterString.read(buf), ) if variant == 12: return PayjoinError.TransactionError( - message=_UniffiConverterString.read(buf), + _UniffiConverterString.read(buf), ) if variant == 13: return PayjoinError.UnexpectedError( - message=_UniffiConverterString.read(buf), + _UniffiConverterString.read(buf), ) if variant == 14: return PayjoinError.ServerError( - message=_UniffiConverterString.read(buf), + _UniffiConverterString.read(buf), ) if variant == 15: return PayjoinError.NetworkValidation( - message=_UniffiConverterString.read(buf), + _UniffiConverterString.read(buf), ) if variant == 16: return PayjoinError.OhttpError( - message=_UniffiConverterString.read(buf), + _UniffiConverterString.read(buf), ) if variant == 17: return PayjoinError.UrlError( - message=_UniffiConverterString.read(buf), + _UniffiConverterString.read(buf), + ) + if variant == 18: + return PayjoinError.IoError( + _UniffiConverterString.read(buf), ) raise InternalError("Raw enum value doesn't match any cases") @@ -4789,6 +5167,9 @@ def check_lower(value): if isinstance(value, PayjoinError.UrlError): _UniffiConverterString.check_lower(value.message) return + if isinstance(value, PayjoinError.IoError): + _UniffiConverterString.check_lower(value.message) + return @staticmethod def write(value, buf): @@ -4843,6 +5224,9 @@ def write(value, buf): if isinstance(value, PayjoinError.UrlError): buf.write_i32(17) _UniffiConverterString.write(value.message, buf) + if isinstance(value, PayjoinError.IoError): + buf.write_i32(18) + _UniffiConverterString.write(value.message, buf) @@ -4851,13 +5235,13 @@ def callback(self, tx: "typing.List[int]"): raise NotImplementedError # Magic number for the Rust proxy to call using the same mechanism as every other method, # to free the callback once it's dropped by Rust. -IDX_CALLBACK_FREE = 0 +_UNIFFI_IDX_CALLBACK_FREE = 0 # Return codes for callback calls _UNIFFI_CALLBACK_SUCCESS = 0 _UNIFFI_CALLBACK_ERROR = 1 _UNIFFI_CALLBACK_UNEXPECTED_ERROR = 2 -class UniffiCallbackInterfaceFfiConverter: +class _UniffiCallbackInterfaceFfiConverter: _handle_map = _UniffiHandleMap() @classmethod @@ -4883,10 +5267,10 @@ def write(cls, cb, buf): buf.write_u64(cls.lower(cb)) # Put all the bits inside a class to keep the top-level namespace clean -class UniffiTraitImplCanBroadcast: +class _UniffiTraitImplCanBroadcast: # For each method, generate a callback function to pass to Rust - @UNIFFI_CALLBACK_INTERFACE_CAN_BROADCAST_METHOD0 + @_UNIFFI_CALLBACK_INTERFACE_CAN_BROADCAST_METHOD0 def callback( uniffi_handle, tx, @@ -4910,21 +5294,71 @@ def write_return_value(v): _UniffiConverterTypePayjoinError.lower, ) - @UNIFFI_CALLBACK_INTERFACE_FREE - def uniffi_free(uniffi_handle): + @_UNIFFI_CALLBACK_INTERFACE_FREE + def _uniffi_free(uniffi_handle): _UniffiConverterCallbackInterfaceCanBroadcast._handle_map.remove(uniffi_handle) # Generate the FFI VTable. This has a field for each callback interface method. - uniffi_vtable = UniffiVTableCallbackInterfaceCanBroadcast( + _uniffi_vtable = _UniffiVTableCallbackInterfaceCanBroadcast( + callback, + _uniffi_free + ) + # Send Rust a pointer to the VTable. Note: this means we need to keep the struct alive forever, + # or else bad things will happen when Rust tries to access it. + _UniffiLib.uniffi_payjoin_ffi_fn_init_callback_vtable_canbroadcast(ctypes.byref(_uniffi_vtable)) + +# The _UniffiConverter which transforms the Callbacks in to Handles to pass to Rust. +_UniffiConverterCallbackInterfaceCanBroadcast = _UniffiCallbackInterfaceFfiConverter() + + + +class GenerateScript(typing.Protocol): + def callback(self, ): + raise NotImplementedError + + +# Put all the bits inside a class to keep the top-level namespace clean +class _UniffiTraitImplGenerateScript: + # For each method, generate a callback function to pass to Rust + + @_UNIFFI_CALLBACK_INTERFACE_GENERATE_SCRIPT_METHOD0 + def callback( + uniffi_handle, + uniffi_out_return, + uniffi_call_status_ptr, + ): + uniffi_obj = _UniffiConverterCallbackInterfaceGenerateScript._handle_map.get(uniffi_handle) + def make_call(): + args = () + method = uniffi_obj.callback + return method(*args) + + + def write_return_value(v): + uniffi_out_return[0] = _UniffiConverterSequenceUInt8.lower(v) + _uniffi_trait_interface_call_with_error( + uniffi_call_status_ptr.contents, + make_call, + write_return_value, + PayjoinError, + _UniffiConverterTypePayjoinError.lower, + ) + + @_UNIFFI_CALLBACK_INTERFACE_FREE + def _uniffi_free(uniffi_handle): + _UniffiConverterCallbackInterfaceGenerateScript._handle_map.remove(uniffi_handle) + + # Generate the FFI VTable. This has a field for each callback interface method. + _uniffi_vtable = _UniffiVTableCallbackInterfaceGenerateScript( callback, - uniffi_free + _uniffi_free ) # Send Rust a pointer to the VTable. Note: this means we need to keep the struct alive forever, # or else bad things will happen when Rust tries to access it. - _UniffiLib.uniffi_payjoin_ffi_fn_init_callback_vtable_canbroadcast(ctypes.byref(uniffi_vtable)) + _UniffiLib.uniffi_payjoin_ffi_fn_init_callback_vtable_generatescript(ctypes.byref(_uniffi_vtable)) # The _UniffiConverter which transforms the Callbacks in to Handles to pass to Rust. -_UniffiConverterCallbackInterfaceCanBroadcast = UniffiCallbackInterfaceFfiConverter() +_UniffiConverterCallbackInterfaceGenerateScript = _UniffiCallbackInterfaceFfiConverter() @@ -4934,10 +5368,10 @@ def callback(self, outpoint: "OutPoint"): # Put all the bits inside a class to keep the top-level namespace clean -class UniffiTraitImplIsOutputKnown: +class _UniffiTraitImplIsOutputKnown: # For each method, generate a callback function to pass to Rust - @UNIFFI_CALLBACK_INTERFACE_IS_OUTPUT_KNOWN_METHOD0 + @_UNIFFI_CALLBACK_INTERFACE_IS_OUTPUT_KNOWN_METHOD0 def callback( uniffi_handle, outpoint, @@ -4961,21 +5395,21 @@ def write_return_value(v): _UniffiConverterTypePayjoinError.lower, ) - @UNIFFI_CALLBACK_INTERFACE_FREE - def uniffi_free(uniffi_handle): + @_UNIFFI_CALLBACK_INTERFACE_FREE + def _uniffi_free(uniffi_handle): _UniffiConverterCallbackInterfaceIsOutputKnown._handle_map.remove(uniffi_handle) # Generate the FFI VTable. This has a field for each callback interface method. - uniffi_vtable = UniffiVTableCallbackInterfaceIsOutputKnown( + _uniffi_vtable = _UniffiVTableCallbackInterfaceIsOutputKnown( callback, - uniffi_free + _uniffi_free ) # Send Rust a pointer to the VTable. Note: this means we need to keep the struct alive forever, # or else bad things will happen when Rust tries to access it. - _UniffiLib.uniffi_payjoin_ffi_fn_init_callback_vtable_isoutputknown(ctypes.byref(uniffi_vtable)) + _UniffiLib.uniffi_payjoin_ffi_fn_init_callback_vtable_isoutputknown(ctypes.byref(_uniffi_vtable)) # The _UniffiConverter which transforms the Callbacks in to Handles to pass to Rust. -_UniffiConverterCallbackInterfaceIsOutputKnown = UniffiCallbackInterfaceFfiConverter() +_UniffiConverterCallbackInterfaceIsOutputKnown = _UniffiCallbackInterfaceFfiConverter() @@ -4985,10 +5419,10 @@ def callback(self, script: "typing.List[int]"): # Put all the bits inside a class to keep the top-level namespace clean -class UniffiTraitImplIsScriptOwned: +class _UniffiTraitImplIsScriptOwned: # For each method, generate a callback function to pass to Rust - @UNIFFI_CALLBACK_INTERFACE_IS_SCRIPT_OWNED_METHOD0 + @_UNIFFI_CALLBACK_INTERFACE_IS_SCRIPT_OWNED_METHOD0 def callback( uniffi_handle, script, @@ -5012,21 +5446,21 @@ def write_return_value(v): _UniffiConverterTypePayjoinError.lower, ) - @UNIFFI_CALLBACK_INTERFACE_FREE - def uniffi_free(uniffi_handle): + @_UNIFFI_CALLBACK_INTERFACE_FREE + def _uniffi_free(uniffi_handle): _UniffiConverterCallbackInterfaceIsScriptOwned._handle_map.remove(uniffi_handle) # Generate the FFI VTable. This has a field for each callback interface method. - uniffi_vtable = UniffiVTableCallbackInterfaceIsScriptOwned( + _uniffi_vtable = _UniffiVTableCallbackInterfaceIsScriptOwned( callback, - uniffi_free + _uniffi_free ) # Send Rust a pointer to the VTable. Note: this means we need to keep the struct alive forever, # or else bad things will happen when Rust tries to access it. - _UniffiLib.uniffi_payjoin_ffi_fn_init_callback_vtable_isscriptowned(ctypes.byref(uniffi_vtable)) + _UniffiLib.uniffi_payjoin_ffi_fn_init_callback_vtable_isscriptowned(ctypes.byref(_uniffi_vtable)) # The _UniffiConverter which transforms the Callbacks in to Handles to pass to Rust. -_UniffiConverterCallbackInterfaceIsScriptOwned = UniffiCallbackInterfaceFfiConverter() +_UniffiConverterCallbackInterfaceIsScriptOwned = _UniffiCallbackInterfaceFfiConverter() @@ -5036,10 +5470,10 @@ def callback(self, psbt: "str"): # Put all the bits inside a class to keep the top-level namespace clean -class UniffiTraitImplProcessPartiallySignedTransaction: +class _UniffiTraitImplProcessPartiallySignedTransaction: # For each method, generate a callback function to pass to Rust - @UNIFFI_CALLBACK_INTERFACE_PROCESS_PARTIALLY_SIGNED_TRANSACTION_METHOD0 + @_UNIFFI_CALLBACK_INTERFACE_PROCESS_PARTIALLY_SIGNED_TRANSACTION_METHOD0 def callback( uniffi_handle, psbt, @@ -5063,21 +5497,21 @@ def write_return_value(v): _UniffiConverterTypePayjoinError.lower, ) - @UNIFFI_CALLBACK_INTERFACE_FREE - def uniffi_free(uniffi_handle): + @_UNIFFI_CALLBACK_INTERFACE_FREE + def _uniffi_free(uniffi_handle): _UniffiConverterCallbackInterfaceProcessPartiallySignedTransaction._handle_map.remove(uniffi_handle) # Generate the FFI VTable. This has a field for each callback interface method. - uniffi_vtable = UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction( + _uniffi_vtable = _UniffiVTableCallbackInterfaceProcessPartiallySignedTransaction( callback, - uniffi_free + _uniffi_free ) # Send Rust a pointer to the VTable. Note: this means we need to keep the struct alive forever, # or else bad things will happen when Rust tries to access it. - _UniffiLib.uniffi_payjoin_ffi_fn_init_callback_vtable_processpartiallysignedtransaction(ctypes.byref(uniffi_vtable)) + _UniffiLib.uniffi_payjoin_ffi_fn_init_callback_vtable_processpartiallysignedtransaction(ctypes.byref(_uniffi_vtable)) # The _UniffiConverter which transforms the Callbacks in to Handles to pass to Rust. -_UniffiConverterCallbackInterfaceProcessPartiallySignedTransaction = UniffiCallbackInterfaceFfiConverter() +_UniffiConverterCallbackInterfaceProcessPartiallySignedTransaction = _UniffiCallbackInterfaceFfiConverter() @@ -5189,6 +5623,33 @@ def read(cls, buf): +class _UniffiConverterOptionalTypeOhttpKeys(_UniffiConverterRustBuffer): + @classmethod + def check_lower(cls, value): + if value is not None: + _UniffiConverterTypeOhttpKeys.check_lower(value) + + @classmethod + def write(cls, value, buf): + if value is None: + buf.write_u8(0) + return + + buf.write_u8(1) + _UniffiConverterTypeOhttpKeys.write(value, buf) + + @classmethod + def read(cls, buf): + flag = buf.read_u8() + if flag == 0: + return None + elif flag == 1: + return _UniffiConverterTypeOhttpKeys.read(buf) + else: + raise InternalError("Unexpected flag byte for optional type") + + + class _UniffiConverterOptionalTypeV2UncheckedProposal(_UniffiConverterRustBuffer): @classmethod def check_lower(cls, value): @@ -5367,11 +5828,10 @@ def read(cls, buf): "RequestContextV2", "RequestResponse", "TxOut", + "ActiveSession", "ClientResponse", "ContextV1", "ContextV2", - "Enrolled", - "Enroller", "Headers", "MaybeInputsOwned", "MaybeInputsSeen", @@ -5380,9 +5840,11 @@ def read(cls, buf): "OutputsUnknown", "PayjoinProposal", "PjUri", + "PjUriBuilder", "ProvisionalProposal", "RequestBuilder", "RequestContext", + "SessionInitializer", "UncheckedProposal", "Uri", "Url", @@ -5394,6 +5856,7 @@ def read(cls, buf): "V2ProvisionalProposal", "V2UncheckedProposal", "CanBroadcast", + "GenerateScript", "IsOutputKnown", "IsScriptOwned", "ProcessPartiallySignedTransaction", diff --git a/python/test/payjoin_integration_test.py b/python/test/payjoin_integration_test.py index fc78f52..02de768 100644 --- a/python/test/payjoin_integration_test.py +++ b/python/test/payjoin_integration_test.py @@ -15,7 +15,6 @@ import unittest from pprint import * from bitcoin import SelectParams -from bitcoin.core import Hash160, CMutableTransaction, CTransaction from bitcoin.core.script import ( CScript, OP_0, @@ -88,12 +87,10 @@ def test_integration(self): pj_uri_string = "{}?amount={}&pj=https://example.com".format( f"bitcoin:{str(pj_uri_address)}", 1 ) - print(f"\npj_uri_string: {pj_uri_string}") - prj_uri = Uri.from_str(pj_uri_string) - print(f"\nprj_uri: {prj_uri}") + prj_uri = Uri.from_str(pj_uri_string).check_pj_supported() + print(f"\nprj_uri: {prj_uri.as_string()}") outputs = {} outputs[prj_uri.address()] = prj_uri.amount() - pprint(outputs) pre_processed_psbt = self.sender._call( "walletcreatefundedpsbt", [], @@ -177,8 +174,6 @@ def handle_pj_request(self, req: Request, headers: Headers, connection: Proxy): txid=selected_utxo["txid"], vout=int(selected_utxo["vout"]) ) payjoin.contribute_witness_input(txo_to_contribute, outpoint_to_contribute) - receiver_substitute_address = connection.getnewaddress() - payjoin.substitute_output_address(str(receiver_substitute_address)) payjoin_proposal = payjoin.finalize_proposal( ProcessPartiallySignedTransactionCallBack(connection=connection), 1, @@ -229,7 +224,6 @@ def callback(self, script): try: script = CScript(bytes(script)) witness_program = script[2:] - print(witness_program) address = P2WPKHBitcoinAddress.from_bytes(0, witness_program) return self.connection._call("getaddressinfo", str(address))["ismine"] except Exception as e: diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..2ee1b17 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "nightly-2024-07-24" +components = ["rustfmt"] diff --git a/rustfmt.toml b/rustfmt.toml index 943435c..fe9dc15 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -70,7 +70,7 @@ color = "Auto" unstable_features = false disable_all_formatting = false skip_children = false -hide_parse_errors = false +show_parse_errors = true error_on_line_overflow = false error_on_unformatted = false emit_mode = "Files" diff --git a/src/error.rs b/src/error.rs index 8a98ebc..5190580 100644 --- a/src/error.rs +++ b/src/error.rs @@ -43,7 +43,7 @@ pub enum PayjoinError { PjParseError { message: String }, #[error("{message}")] - PjNotSupported{ message: String }, + PjNotSupported { message: String }, #[error("Malformed response from receiver: {message}")] ValidationError { message: String }, @@ -80,7 +80,7 @@ impl_from_error! { ohttp::Error => OhttpError, PsbtParseError => PsbtParseError, payjoin::bitcoin::consensus::encode::Error => TransactionError, - payjoin::bitcoin::address::Error => InvalidAddress, + payjoin::bitcoin::address::ParseError => InvalidAddress, RequestError => RequestError, PdkResponseError => ResponseError, ValidationError => ValidationError, diff --git a/src/lib.rs b/src/lib.rs index de43581..84b6331 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,7 @@ pub mod uri; use crate::error::PayjoinError; #[cfg(feature = "uniffi")] use crate::receive::v1::{ - CanBroadcast, IsOutputKnown, IsScriptOwned, ProcessPartiallySignedTransaction, + CanBroadcast, GenerateScript, IsOutputKnown, IsScriptOwned, ProcessPartiallySignedTransaction, }; #[allow(unused_imports)] use crate::receive::v1::{ @@ -32,7 +32,7 @@ use crate::send::v2::ContextV2; #[allow(unused_imports)] use crate::types::{Network, OhttpKeys, OutPoint, Request, TxOut}; #[allow(unused_imports)] -use crate::uri::{PjUri, Uri, Url}; +use crate::uri::{PjUri, PjUriBuilder, Uri, Url}; #[cfg(feature = "uniffi")] uniffi::include_scaffolding!("payjoin_ffi"); diff --git a/src/payjoin_ffi.udl b/src/payjoin_ffi.udl index e0047f2..05d993e 100644 --- a/src/payjoin_ffi.udl +++ b/src/payjoin_ffi.udl @@ -20,6 +20,7 @@ interface PayjoinError { NetworkValidation(string message); OhttpError(string message); UrlError(string message); + IoError(string message); }; @@ -27,6 +28,10 @@ callback interface CanBroadcast { [Throws=PayjoinError] boolean callback(sequence tx); }; +callback interface GenerateScript { + [Throws=PayjoinError] + sequence callback(); +}; callback interface IsScriptOwned { [Throws=PayjoinError] boolean callback(sequence script); @@ -75,9 +80,24 @@ interface Uri { constructor(string uri); string address(); f64? amount(); + [Throws=PayjoinError] + PjUri check_pj_supported(); + string as_string(); +}; +interface PjUri{ + string address(); + f64? amount(); + string as_string(); +}; +interface PjUriBuilder{ + [Throws=PayjoinError] + constructor( string address, Url pj, OhttpKeys? ohttp_keys, u64? expiry ); + PjUriBuilder amount( u64 amount ); + PjUriBuilder message( string message ); + PjUriBuilder label( string label ); + PjUriBuilder pjos( boolean pjos ); + PjUri build(); }; -interface PjUri{}; - interface ClientResponse{}; @@ -113,9 +133,7 @@ interface ProvisionalProposal{ [Throws=PayjoinError] void contribute_witness_input(TxOut txout, OutPoint outpoint); [Throws=PayjoinError] - void contribute_non_witness_input(sequence tx, OutPoint outpoint); - [Throws=PayjoinError] - void substitute_output_address(string substitute_address); + void try_substitute_receiver_output(GenerateScript generate_script); [Throws=PayjoinError] OutPoint try_preserving_privacy(record candidate_inputs); [Throws=PayjoinError] @@ -129,14 +147,14 @@ interface PayjoinProposal{ }; interface RequestBuilder{ [Throws=PayjoinError, Name=from_psbt_and_uri] - constructor(string psbt, Uri uri); + constructor(string psbt, PjUri uri); RequestBuilder always_disable_output_substitution( boolean disable ); [Throws=PayjoinError] RequestContext build_recommended( u64 min_fee_rate); [Throws=PayjoinError] RequestContext build_with_additional_fee( u64 max_fee_contribution, u8? change_index, u64 min_fee_rate, boolean clamp_fee_contribution ); [Throws=PayjoinError] - RequestContext build_non_incentivizing(); + RequestContext build_non_incentivizing( u64 min_fee_rate ); }; interface RequestContext{ @@ -163,7 +181,7 @@ interface ContextV1{ interface ContextV2{ [Throws=PayjoinError] - string? process_response( sequence response ); + string? process_response( sequence response ); }; interface OhttpKeys{ @@ -171,19 +189,21 @@ interface OhttpKeys{ constructor( sequence bytes ); }; -interface Enroller{ - [Name=from_directory_config] - constructor(Url directory, OhttpKeys ohttp_keys, Url ohttp_relay); +interface SessionInitializer{ + [Throws=PayjoinError] + constructor( string address, u64? expire_after, Network network, Url directory, OhttpKeys ohttp_keys, Url ohttp_relay); [Throws=PayjoinError] RequestResponse extract_req(); [Throws=PayjoinError] - Enrolled process_res(sequence body, ClientResponse ctx); + ActiveSession process_res(sequence body, ClientResponse ctx); }; -interface Enrolled { - string fallback_target(); +interface ActiveSession { [Throws=PayjoinError] RequestResponse extract_req(); + Url pj_url(); + string public_key(); + PjUriBuilder pj_uri_builder(); [Throws=PayjoinError] V2UncheckedProposal? process_res(sequence body, ClientResponse ctx); }; @@ -215,9 +235,7 @@ interface V2ProvisionalProposal{ [Throws=PayjoinError] void contribute_witness_input(TxOut txout, OutPoint outpoint); [Throws=PayjoinError] - void contribute_non_witness_input(sequence tx, OutPoint outpoint); - [Throws=PayjoinError] - void substitute_output_address(string substitute_address); + void try_substitute_receiver_output(GenerateScript generate_script); [Throws=PayjoinError] OutPoint try_preserving_privacy(record candidate_inputs); [Throws=PayjoinError] @@ -229,6 +247,9 @@ interface V2PayjoinProposal{ boolean is_output_substitution_disabled(); sequence owned_vouts(); string psbt(); + string extract_v1_req(); + [Throws=PayjoinError] + RequestResponse extract_v2_req(); [Throws=PayjoinError] - sequence deserialize_res(sequence res, ClientResponse ohttp_context); + void process_res(sequence res, ClientResponse ohttp_context); }; \ No newline at end of file diff --git a/src/receive/v1.rs b/src/receive/v1.rs index 54c6a24..7602ad3 100644 --- a/src/receive/v1.rs +++ b/src/receive/v1.rs @@ -12,7 +12,9 @@ use crate::types::{OutPoint, TxOut}; pub trait CanBroadcast { fn callback(&self, tx: Vec) -> Result; } - +pub trait GenerateScript { + fn callback(&self) -> Result, PayjoinError>; +} #[derive(Clone)] pub struct Headers(pub HashMap); @@ -324,8 +326,16 @@ impl ProvisionalProposal { #[cfg(feature = "uniffi")] pub fn try_substitute_receiver_output( &self, - generate_script: impl Fn() -> Result, PayjoinError>, + generate_script: Box, ) -> Result<(), PayjoinError> { + self.mutex_guard() + .try_substitute_receiver_output(|| { + generate_script + .callback() + .map(|e| payjoin::bitcoin::ScriptBuf::from_bytes(e)) + .map_err(|e| payjoin::Error::Server(Box::new(e))) + }) + .map_err(|e| e.into()) } pub fn contribute_witness_input( &self, @@ -336,16 +346,6 @@ impl ProvisionalProposal { Ok(self.mutex_guard().contribute_witness_input(txo, outpoint.into())) } - pub fn contribute_non_witness_input( - &self, - tx: Vec, - outpoint: OutPoint, - ) -> Result<(), PayjoinError> { - let tx: payjoin::bitcoin::Transaction = - payjoin::bitcoin::consensus::encode::deserialize(&*tx)?; - Ok(self.mutex_guard().contribute_non_witness_input(tx, outpoint.into())) - } - /// Select receiver input such that the payjoin avoids surveillance. Return the input chosen that has been applied to the Proposal. /// /// Proper coin selection allows payjoin to resemble ordinary transactions. To ensure the resemblance, a number of heuristics must be avoided. @@ -484,9 +484,10 @@ mod test { .identify_receiver_outputs(|script| { let network = payjoin::bitcoin::Network::Bitcoin; let script = payjoin::bitcoin::ScriptBuf::from_bytes(script.to_vec()); - Ok(payjoin::bitcoin::Address::from_script(&script, network) + Ok(payjoin::bitcoin::Address::from_script(&script, network).unwrap() == payjoin::bitcoin::Address::from_str("3CZZi7aWFugaCdUCS15dgrUUViupmB8bVM") - .map(|x| x.require_network(network).expect("Invalid address"))) + .map(|x| x.require_network(network).unwrap()) + .unwrap()) }) .expect("Receiver output should be identified"); } diff --git a/src/receive/v2.rs b/src/receive/v2.rs index aea7b1f..de8ee22 100644 --- a/src/receive/v2.rs +++ b/src/receive/v2.rs @@ -10,7 +10,7 @@ use payjoin::receive as pdk; #[cfg(feature = "uniffi")] use crate::receive::v1::{ - CanBroadcast, IsOutputKnown, IsScriptOwned, ProcessPartiallySignedTransaction, + CanBroadcast, GenerateScript, IsOutputKnown, IsScriptOwned, ProcessPartiallySignedTransaction, }; use crate::types::Network; use crate::uri::PjUriBuilder; @@ -84,21 +84,22 @@ impl SessionInitializer { ) .into()) } + #[cfg(not(feature = "uniffi"))] pub fn new( address: String, expire_after: Option, network: Network, - directory: Arc, - ohttp_keys: Arc, - ohttp_relay: Arc, + directory: Url, + ohttp_keys: OhttpKeys, + ohttp_relay: Url, ) -> Result { let address = payjoin::bitcoin::Address::from_str(address.as_str())? .require_network(network.into())?; Ok(payjoin::receive::v2::SessionInitializer::new( address, - (*directory).clone().into(), - (*ohttp_keys).clone().into(), - (*ohttp_relay).clone().into(), + directory.into(), + ohttp_keys.into(), + ohttp_relay.into(), expire_after.map(|e| Duration::from_secs(e)), ) .into()) @@ -199,13 +200,31 @@ impl ActiveSession { .map(|e| e.map(|o| o.into())) .map_err(|e| e.into()) } + #[cfg(not(feature = "uniffi"))] pub fn pj_uri_builder(&self) -> PjUriBuilder { >::into(self.clone()) .pj_uri_builder() .into() } + #[cfg(feature = "uniffi")] + pub fn pj_uri_builder(&self) -> Arc { + Arc::new( + >::into(self.clone()) + .pj_uri_builder() + .into(), + ) + } /// The contents of the `&pj=` query parameter including the base64url-encoded public key receiver subdirectory. /// This identifies a session at the payjoin directory server. + #[cfg(feature = "uniffi")] + pub fn pj_url(&self) -> Arc { + Arc::new( + >::into(self.clone()) + .pj_url() + .into(), + ) + } + #[cfg(not(feature = "uniffi"))] pub fn pj_url(&self) -> Url { >::into(self.clone()) .pj_url() @@ -473,15 +492,6 @@ impl V2ProvisionalProposal { let txo: payjoin::bitcoin::blockdata::transaction::TxOut = txo.into(); Ok(self.mutex_guard().contribute_witness_input(txo, outpoint.into())) } - pub fn contribute_non_witness_input( - &self, - tx: Vec, - outpoint: OutPoint, - ) -> Result<(), PayjoinError> { - let tx: payjoin::bitcoin::Transaction = - payjoin::bitcoin::consensus::encode::deserialize(&*tx)?; - Ok(self.mutex_guard().contribute_non_witness_input(tx, outpoint.into())) - } /// Select receiver input such that the payjoin avoids surveillance. /// Return the input chosen that has been applied to the Proposal. /// @@ -526,12 +536,19 @@ impl V2ProvisionalProposal { }) .map_err(|e| e.into()) } - //TODO; create try_substitute_receiver_output for uniffi build #[cfg(feature = "uniffi")] pub fn try_substitute_receiver_output( &self, - generate_script: impl Fn() -> Result, PayjoinError>, + generate_script: Box, ) -> Result<(), PayjoinError> { + self.mutex_guard() + .try_substitute_receiver_output(|| { + generate_script + .callback() + .map(|e| payjoin::bitcoin::ScriptBuf::from_bytes(e)) + .map_err(|e| payjoin::Error::Server(Box::new(e))) + }) + .map_err(|e| e.into()) } #[cfg(feature = "uniffi")] @@ -605,7 +622,7 @@ impl V2PayjoinProposal { >::into(self.clone()) .utxos_to_be_locked() { - outpoints.push((e.to_owned()).into()) + outpoints.push(e.to_owned().into()); } outpoints } diff --git a/src/send/v1.rs b/src/send/v1.rs index 570a1b5..cc5b392 100644 --- a/src/send/v1.rs +++ b/src/send/v1.rs @@ -22,14 +22,21 @@ impl From> for RequestBuilder { } impl RequestBuilder { + //TODO: Replicate all functions like this & remove duplicate code /// Prepare an HTTP request and request context to process the response /// /// An HTTP client will own the Request data while Context sticks around so /// a `(Request, Context)` tuple is returned from `RequestBuilder::build()` /// to keep them separated. - pub fn from_psbt_and_uri(psbt: String, uri: Arc) -> Result { - let psbt = payjoin::bitcoin::psbt::PartiallySignedTransaction::from_str(psbt.as_str())?; - pdk::RequestBuilder::from_psbt_and_uri(psbt, (*uri).clone().into()) + pub fn from_psbt_and_uri( + psbt: String, + #[cfg(not(feature = "uniffi"))] uri: PjUri, + #[cfg(feature = "uniffi")] uri: Arc, + ) -> Result { + let psbt = payjoin::bitcoin::psbt::Psbt::from_str(psbt.as_str())?; + #[cfg(feature = "uniffi")] + let uri: PjUri = (*uri).clone(); + pdk::RequestBuilder::from_psbt_and_uri(psbt, uri.into()) .map(|e| e.into()) .map_err(|e| e.into()) } diff --git a/src/types.rs b/src/types.rs index 2573565..54425a2 100644 --- a/src/types.rs +++ b/src/types.rs @@ -58,7 +58,7 @@ pub struct TxOut { impl From for payjoin::bitcoin::TxOut { fn from(tx_out: TxOut) -> Self { payjoin::bitcoin::TxOut { - value: tx_out.value, + value: payjoin::bitcoin::amount::Amount::from_sat(tx_out.value), script_pubkey: payjoin::bitcoin::ScriptBuf::from_bytes(tx_out.script_pubkey), } } @@ -66,7 +66,7 @@ impl From for payjoin::bitcoin::TxOut { impl From for TxOut { fn from(tx_out: payjoin::bitcoin::TxOut) -> Self { - TxOut { value: tx_out.value, script_pubkey: tx_out.script_pubkey.to_bytes() } + TxOut { value: tx_out.value.to_sat(), script_pubkey: tx_out.script_pubkey.to_bytes() } } } diff --git a/src/uri.rs b/src/uri.rs index 5cabdc3..e53118d 100644 --- a/src/uri.rs +++ b/src/uri.rs @@ -1,11 +1,12 @@ use std::str::FromStr; +#[cfg(feature = "uniffi")] +use std::sync::Arc; use std::time::{Duration, UNIX_EPOCH}; use payjoin::bitcoin::address::NetworkChecked; use payjoin::UriExt; use crate::error::PayjoinError; -#[cfg(not(feature = "uniffi"))] use crate::types::OhttpKeys; #[derive(Clone)] pub struct Uri(payjoin::Uri<'static, NetworkChecked>); @@ -33,9 +34,9 @@ impl Uri { } ///Gets the amount in satoshis. pub fn amount(&self) -> Option { - self.0.amount.map(|x| x.to_btc()) } + #[cfg(not(feature = "uniffi"))] pub fn check_pj_supported(&self) -> Result { match self.0.clone().check_pj_supported() { Ok(e) => Ok(e.into()), @@ -46,6 +47,17 @@ impl Uri { } } } + #[cfg(feature = "uniffi")] + pub fn check_pj_supported(&self) -> Result, PayjoinError> { + match self.0.clone().check_pj_supported() { + Ok(e) => Ok(Arc::new(e.into())), + Err(_) => { + Err(PayjoinError::PjNotSupported { + message: "Uri doesn't support payjoin".to_string(), + }) + } + } + } pub fn as_string(&self) -> String { self.0.clone().to_string() } @@ -111,7 +123,6 @@ impl Url { ///Build a valid PjUri. // Payjoin receiver can use this builder to create a payjoin uri to send to the sender. -#[cfg(not(feature = "uniffi"))] pub struct PjUriBuilder(pub payjoin::PjUriBuilder); impl From for PjUriBuilder { @@ -119,6 +130,50 @@ impl From for PjUriBuilder { Self(value) } } +#[cfg(feature = "uniffi")] +impl PjUriBuilder { + ///Create a new PjUriBuilder with required parameters. + /// Parameters + /// address: Represents a bitcoin address. + /// ohttp_keys: Optional OHTTP keys for v2. + /// expiry: Optional non-default duration_since epoch expiry for the payjoin session. + pub fn new( + address: String, + pj: Arc, + ohttp_keys: Option>, + expiry: Option, + ) -> Result { + let address = payjoin::bitcoin::Address::from_str(&address)?.assume_checked(); + Ok(payjoin::PjUriBuilder::new( + address, + (*pj).clone().into(), + ohttp_keys.map(|e| e.0.clone()), + expiry.map(|e| UNIX_EPOCH + Duration::from_secs(e)), + ) + .into()) + } + ///Accepts the amount you want to receive in sats and sets it in btc . + pub fn amount(&self, amount: u64) -> Arc { + let amount = payjoin::bitcoin::Amount::from_sat(amount); + Arc::new(self.0.clone().amount(amount).into()) + } + /// Set the message. + pub fn message(&self, message: String) -> Arc { + Arc::new(self.0.clone().message(message).into()) + } + ///Set the label. + pub fn label(&self, label: String) -> Arc { + Arc::new(self.0.clone().label(label).into()) + } + ///Set whether payjoin output substitution is allowed. + pub fn pjos(&self, pjos: bool) -> Arc { + Arc::new(self.0.clone().pjos(pjos).into()) + } + ///Constructs a Uri with PayjoinParams from the parameters set in the builder. + pub fn build(&self) -> Arc { + Arc::new(self.0.clone().build().into()) + } +} #[cfg(not(feature = "uniffi"))] impl PjUriBuilder { ///Create a new PjUriBuilder with required parameters. diff --git a/tests/bdk_integration_test.rs b/tests/bdk_integration_test.rs index 9b199d4..d56edf4 100644 --- a/tests/bdk_integration_test.rs +++ b/tests/bdk_integration_test.rs @@ -1,10 +1,9 @@ use std::collections::HashMap; -use std::error::Error; use std::str::FromStr; use std::sync::{Arc, Mutex, MutexGuard}; use bdk::bitcoin::psbt::PartiallySignedTransaction; -use bdk::bitcoin::{Address, Script, Transaction}; +use bdk::bitcoin::{Address, Network, Script, Transaction}; use bdk::blockchain::EsploraBlockchain; use bdk::database::MemoryDatabase; use bdk::wallet::AddressIndex; @@ -12,8 +11,8 @@ use bdk::{FeeRate, LocalUtxo, SignOptions, Wallet as BdkWallet}; use bitcoincore_rpc::{Auth, Client, RpcApi}; use payjoin_ffi::error::PayjoinError; use payjoin_ffi::receive::v1::{Headers, PayjoinProposal, UncheckedProposal}; -use payjoin_ffi::types::{Network, OutPoint, Request, TxOut}; -use payjoin_ffi::uri::Uri; +use payjoin_ffi::types::{OutPoint, Request, TxOut}; +use payjoin_ffi::uri::{PjUri, Uri}; use uniffi::deps::log::debug; // Set up RPC connections @@ -22,7 +21,7 @@ static RPC_PASSWORD: &str = "123"; static RPC_HOST: &str = "localhost"; static RPC_PORT: &str = "18443"; static ESPLORA_URL: &str = "http://0.0.0.0:30000"; - +type BoxError = Box; pub struct EsploraClient(EsploraBlockchain); impl EsploraClient { @@ -32,7 +31,7 @@ impl EsploraClient { } #[allow(dead_code)] - pub fn broadcast(&self, transaction: Transaction) -> Result<(), Box> { + pub fn broadcast(&self, transaction: Transaction) -> Result<(), BoxError> { match self.0.broadcast(&transaction) { Ok(_) => Ok(()), Err(e) => panic!("{}", e.to_string()), @@ -40,7 +39,7 @@ impl EsploraClient { } } -fn restore_wallet(descriptor: String) -> Result> { +fn restore_wallet(descriptor: String) -> Result { match Wallet::new_no_persist(descriptor.to_string(), Network::Regtest) { Ok(e) => Ok(e), Err(e) => panic!("{}", e.to_string()), @@ -112,7 +111,7 @@ fn init_sender_receiver_wallet() -> (Wallet, Wallet, Client) { } #[allow(dead_code)] -fn broadcast_tx(esplora_client: EsploraClient, tx: Transaction) -> Result<(), Box> { +fn broadcast_tx(esplora_client: EsploraClient, tx: Transaction) -> Result<(), BoxError> { esplora_client.broadcast(tx) } fn build_pj_uri<'a>( @@ -120,7 +119,7 @@ fn build_pj_uri<'a>( amount: u64, pj: &str, ohttp: Option<&str>, -) -> Result> { +) -> Result { let pj_uri_string = format!("{}?amount={}&pj={}", address, (amount as f64 / 100_000_000.0), pj,); if let Some(ohttp) = ohttp { @@ -136,8 +135,9 @@ fn build_pj_uri<'a>( pub struct Wallet { inner_mutex: Mutex>, } + impl Wallet { - pub fn new_no_persist(descriptor: String, network: Network) -> Result> { + pub fn new_no_persist(descriptor: String, network: Network) -> Result { let wallet = BdkWallet::new(descriptor.as_str(), None, network.into(), MemoryDatabase::new())?; @@ -175,7 +175,7 @@ impl Wallet { &self, psbt: &mut PartiallySignedTransaction, remove: bool, - ) -> Result> { + ) -> Result { let f = psbt.to_string(); match self.get_wallet().sign( psbt, @@ -202,7 +202,7 @@ fn get_receiver_descriptor() -> String { "wpkh(tprv8ZgxMBicQKsPczV7D2zfMr7oUzHDhNPEuBUgrwRoWM3ijLRvhG87xYiqh9JFLPqojuhmqwMdo1oJzbe5GUpxCbDHnqyGhQa5Jg1Wt6rc9di/84'/1'/0'/0/*)#kdnuw5lq".to_string() } #[allow(dead_code)] -fn extract_pj_tx(sender_wallet: &Wallet, psbt: &str) -> Result> { +fn extract_pj_tx(sender_wallet: &Wallet, psbt: &str) -> Result { let mut psbt: PartiallySignedTransaction = PartiallySignedTransaction::from_str(psbt).expect("Invalid psbt"); println!("Sender's Payjoin PSBT1: {:#?}", psbt.to_string()); @@ -309,8 +309,8 @@ fn handle_pj_request(req: Request, headers: Headers, receiver: Wallet) -> String } fn build_original_psbt( sender_wallet: &Wallet, - pj_uri: &Uri, -) -> Result> { + pj_uri: &PjUri, +) -> Result { let wallet_mutex = sender_wallet.get_wallet(); let mut builder = wallet_mutex.build_tx(); let script = bdk::bitcoin::Address::from_str(pj_uri.address().as_str())? @@ -340,18 +340,20 @@ mod v1 { const EXAMPLE_URL: &str = "https://example.com"; #[test] - fn v1_to_v1_full_cycle() -> Result<(), Box> { - let (sender, receiver, _btc_client) = init_sender_receiver_wallet(); + fn v1_to_v1_full_cycle() -> Result<(), BoxError> { + let (sender, receiver, _) = init_sender_receiver_wallet(); let _esplora_client = restore_esplora_client(); let pj_receiver_address = receiver.get_address(AddressIndex::New); - let pj_uri = - build_pj_uri(pj_receiver_address.to_qr_uri(), 500000, EXAMPLE_URL, None).unwrap(); + let pj_uri = build_pj_uri(pj_receiver_address.to_qr_uri(), 500000, EXAMPLE_URL, None) + .unwrap() + .check_pj_supported() + .unwrap(); let psbt = build_original_psbt(&sender, &pj_uri)?; println!("\nOriginal sender psbt: {:#?}", psbt.to_string()); - let req_ctx = RequestBuilder::from_psbt_and_uri(psbt.to_string(), Arc::new(pj_uri.check_pj_supported().unwrap()))? + let req_ctx = RequestBuilder::from_psbt_and_uri(psbt.to_string(), pj_uri)? .build_with_additional_fee(10000, None, 0, false)? .extract_v1()?; let headers = Headers::from_vec(req_ctx.request.body.clone()); @@ -367,3 +369,287 @@ mod v1 { Ok(()) } } + +mod v2 { + use std::collections::HashMap; + use std::str::FromStr; + use std::sync::Arc; + use std::time::Duration; + + use bdk::bitcoin::psbt::PartiallySignedTransaction; + use bdk::bitcoin::{Address, Script}; + use bdk::wallet::AddressIndex; + use http::StatusCode; + use payjoin_ffi::error::PayjoinError; + use payjoin_ffi::receive::v2::{ + ActiveSession, SessionInitializer, V2PayjoinProposal, V2UncheckedProposal, + }; + use payjoin_ffi::send::v1::RequestBuilder; + use payjoin_ffi::types::{Network, OhttpKeys, OutPoint, TxOut}; + use payjoin_ffi::uri::{Uri, Url}; + use reqwest::{Client, ClientBuilder}; + use testcontainers::clients::Cli; + use testcontainers_modules::redis::Redis; + + use crate::{ + broadcast_tx, build_original_psbt, extract_pj_tx, init_sender_receiver_wallet, + restore_esplora_client, BoxError, Wallet, + }; + #[tokio::test] + + async fn v2_to_v2_full_cycle() { + let (cert, key) = local_cert_key(); + let ohttp_relay_port = find_free_port(); + let ohttp_relay = Url::from_str(format!("http://localhost:{}", ohttp_relay_port)).unwrap(); + let directory_port = find_free_port(); + let directory = Url::from_str(format!("https://localhost:{}", directory_port)).unwrap(); + let gateway_origin = http::Uri::from_str(directory.as_string().as_str()).unwrap(); + tokio::select!( + _ = ohttp_relay::listen_tcp(ohttp_relay_port, gateway_origin) => assert!(false, "Ohttp relay is long running"), + _ = init_directory(directory_port, (cert.clone(), key)) => assert!(false, "Directory server is long running"), + res = do_v2_send_receive(ohttp_relay, directory, cert) => assert!(res.is_ok(), "v2 send receive failed: {:#?}", res) + ); + + async fn do_v2_send_receive( + ohttp_relay: Url, + directory: Url, + cert_der: Vec, + ) -> Result<(), BoxError> { + let (sender, receiver, _) = init_sender_receiver_wallet(); + let esplora_client = restore_esplora_client(); + let agent = Arc::new(http_agent(cert_der.clone()).unwrap()); + wait_for_service_ready(ohttp_relay.clone(), agent.clone()).await?; + wait_for_service_ready(directory.clone(), agent.clone()).await?; + let ohttp_keys = + payjoin_ffi::io::fetch_ohttp_keys(ohttp_relay, directory.clone(), cert_der.clone()) + .await?; + let address = receiver.get_address(AddressIndex::New); + // test session with expiry in the future + let session = initialize_session( + address.clone(), + directory.clone(), + ohttp_keys.clone(), + cert_der.clone(), + None, + ) + .await?; + let pj_uri_string = session.pj_uri_builder().amount(5000000).build().as_string(); + // Poll receive request + let (req, ctx) = session.extract_req()?; + let response = agent.post(req.url.as_string()).body(req.body).send().await?; + assert!(response.status().is_success()); + let response_body = session.process_res(response.bytes().await?.to_vec(), ctx).unwrap(); + // No proposal yet since sender has not responded + assert!(response_body.is_none()); + let pj_uri = Uri::from_str(pj_uri_string).unwrap().check_pj_supported().unwrap(); + let psbt = build_original_psbt(&sender, &pj_uri)?; + println!("\nOriginal sender psbt: {:#?}", psbt.to_string()); + + let req_ctx = RequestBuilder::from_psbt_and_uri(psbt.to_string(), pj_uri)? + .build_recommended(payjoin::bitcoin::FeeRate::BROADCAST_MIN.to_sat_per_kwu())?; + let req_ctx_v2 = req_ctx.extract_v2(Arc::new(directory.to_owned()))?; + let response = agent + .post(req_ctx_v2.request.url.as_string()) + .header("Content-Type", payjoin::V1_REQ_CONTENT_TYPE) + .body(req_ctx_v2.request.body.clone()) + .send() + .await + .unwrap(); + assert!(response.status().is_success()); + let response_body = + req_ctx_v2.context_v2.process_response(response.bytes().await?.to_vec())?; + // No response body yet since we are async and pushed fallback_psbt to the buffer + assert!(response_body.is_none()); + // ********************** + // Inside the Receiver: + + // GET fallback psbt + let (req, ctx) = session.extract_req()?; + let response = agent.post(req.url.as_string()).body(req.body).send().await?; + let proposal = session.process_res(response.bytes().await?.to_vec(), ctx)?.unwrap(); + let payjoin_proposal = handle_directory_proposal(receiver, proposal); + assert!(!payjoin_proposal.is_output_substitution_disabled()); + let (req, ctx) = payjoin_proposal.extract_v2_req()?; + let response = agent.post(req.url.as_string()).body(req.body).send().await?; + let res = response.bytes().await?.to_vec(); + payjoin_proposal.process_res(res, ctx)?; + let req_ctx_v2 = req_ctx.extract_v2(Arc::new(directory.to_owned()))?; + let response = agent + .post(req_ctx_v2.request.url.as_string()) + .body(req_ctx_v2.request.body) + .send() + .await?; + let checked_payjoin_proposal_psbt = + req_ctx_v2.context_v2.process_response(response.bytes().await?.to_vec())?.unwrap(); + let payjoin_tx = extract_pj_tx(&sender, checked_payjoin_proposal_psbt.as_str())?; + broadcast_tx(esplora_client, payjoin_tx).unwrap(); + Ok(()) + } + } + async fn initialize_session( + address: Address, + directory: Url, + ohttp_keys: OhttpKeys, + cert_der: Vec, + custom_expire_after: Option, + ) -> Result { + let mock_ohttp_relay = directory.clone(); // pass through to + let initializer = SessionInitializer::new( + address.to_string(), + custom_expire_after, + Network::Regtest, + directory, + ohttp_keys, + mock_ohttp_relay, + ) + .unwrap(); + let (req, ctx) = initializer.extract_req()?; + println!("enroll req: {:#?}", &req.url.as_string()); + let response = + http_agent(cert_der).unwrap().post(req.url.as_string()).body(req.body).send().await?; + assert!(response.status().is_success()); + Ok(initializer.process_res(response.bytes().await?.to_vec(), ctx)?) + } + async fn wait_for_service_ready( + service_url: Url, + agent: Arc, + ) -> Result<(), &'static str> { + let health_url = >::into(service_url) + .join("/health") + .map_err(|_| "Invalid URL")?; + let start = std::time::Instant::now(); + + while start.elapsed() < Duration::from_secs(20) { + let request_result = + agent.get(health_url.as_str()).send().await.map_err(|_| "Bad request")?; + + match request_result.status() { + StatusCode::OK => return Ok(()), + StatusCode::NOT_FOUND => return Err("Endpoint not found"), + _ => std::thread::sleep(Duration::from_secs(3)), + } + } + + Err("Timeout waiting for service to be ready") + } + fn handle_directory_proposal( + receiver: Wallet, + proposal: V2UncheckedProposal, + ) -> V2PayjoinProposal { + // in a payment processor where the sender could go offline, this is where you schedule to broadcast the original_tx + let _to_broadcast_in_failure_case = proposal.extract_tx_to_schedule_broadcast(); + + // Receive Check 1: Can Broadcast + let proposal = proposal.assume_interactive_receiver(); + + // Receive Check 2: receiver can't sign for proposal inputs + let proposal = proposal + .check_inputs_not_owned(|input| { + receiver + .is_mine(Script::from_bytes(input)) + .map_err(|x| PayjoinError::UnexpectedError { message: x.to_string() }) + }) + .expect("Receiver should not own any of the inputs"); + + // Receive Check 3: receiver can't sign for proposal inputs + let proposal = proposal.check_no_mixed_input_scripts().unwrap(); + + // Receive Check 4: have we seen this input before? More of a check for non-interactive i.e. payment processor receivers. + let payjoin = proposal + .check_no_inputs_seen_before(|_| Ok(false)) + .unwrap() + .identify_receiver_outputs(|output_script| { + receiver + .is_mine(Script::from_bytes(output_script.as_slice())) + .map_err(|x| PayjoinError::UnexpectedError { message: x.to_string() }) + }) + .expect("Receiver should have at least one output"); + + // Select receiver payjoin inputs. TODO Lock them. + let available_inputs = receiver.list_unspent(); + let candidate_inputs: HashMap = available_inputs + .iter() + .map(|i| { + ( + i.txout.value, + OutPoint { txid: i.outpoint.txid.to_string(), vout: i.outpoint.vout }, + ) + }) + .collect(); + let selected_outpoint = payjoin + .try_preserving_privacy(candidate_inputs) + .expect("receiver input that avoids surveillance not found"); + let selected_utxo = available_inputs + .iter() + .find(|i| { + i.outpoint.txid.to_string() == selected_outpoint.txid + && i.outpoint.vout == selected_outpoint.vout + }) + .unwrap(); + + // calculate receiver payjoin outputs given receiver payjoin inputs and original_psbt, + let txo_to_contribute = TxOut { + value: selected_utxo.txout.value, + script_pubkey: selected_utxo.txout.script_pubkey.clone().into_bytes(), + }; + let outpoint_to_contribute = OutPoint { + txid: selected_utxo.outpoint.txid.to_string(), + vout: selected_utxo.outpoint.vout, + }; + let _ = payjoin.contribute_witness_input(txo_to_contribute, outpoint_to_contribute); + + _ = payjoin.try_substitute_receiver_output(|| { + Ok(receiver.get_address(AddressIndex::New).script_pubkey().into_bytes()) + }); + let payjoin_proposal = payjoin + .finalize_proposal( + |psbt| { + match receiver.sign( + &mut PartiallySignedTransaction::from_str(psbt.as_str()).unwrap(), + true, + ) { + Ok(e) => Ok(e.to_string()), + Err(e) => Err(PayjoinError::UnexpectedError { message: e.to_string() }), + } + }, + Some(10), + ) + .unwrap(); + (*payjoin_proposal).clone() + } + async fn init_directory(port: u16, local_cert_key: (Vec, Vec)) -> Result<(), BoxError> { + let docker: Cli = Cli::default(); + let timeout = Duration::from_secs(2); + let db = docker.run(Redis::default()); + let db_host = format!("127.0.0.1:{}", db.get_host_port_ipv4(6379)); + println!("Database running on {}", db.get_host_port_ipv4(6379)); + payjoin_directory::listen_tcp_with_tls(port, db_host, timeout, local_cert_key).await + } + // generates or gets a DER encoded localhost cert and key. + fn local_cert_key() -> (Vec, Vec) { + let cert = rcgen::generate_simple_self_signed(vec![ + "0.0.0.0".to_string(), + "localhost".to_string(), + ]) + .expect("Failed to generate cert"); + let cert_der = cert.serialize_der().expect("Failed to serialize cert"); + let key_der = cert.serialize_private_key_der(); + (cert_der, key_der) + } + fn find_free_port() -> u16 { + let listener = std::net::TcpListener::bind("0.0.0.0:0").unwrap(); + listener.local_addr().unwrap().port() + } + fn http_agent(cert_der: Vec) -> Result { + Ok(http_agent_builder(cert_der)?.build()?) + } + + fn http_agent_builder(cert_der: Vec) -> Result { + Ok(ClientBuilder::new() + .danger_accept_invalid_certs(true) + .use_rustls_tls() + .add_root_certificate( + reqwest::tls::Certificate::from_der(cert_der.as_slice()).unwrap(), + )) + } +} diff --git a/tests/bitcoin_core_integration.rs b/tests/bitcoin_core_integration.rs index 3f3d8cf..f2caef4 100644 --- a/tests/bitcoin_core_integration.rs +++ b/tests/bitcoin_core_integration.rs @@ -61,9 +61,10 @@ fn v1_to_v1_full_cycle() -> Result<(), BoxError> { .psbt; let psbt_base64 = sender.wallet_process_psbt(&psbt, None, None, None)?.psbt; eprintln!("Original psbt: {:#?}", psbt_base64); - let req_ctx = RequestBuilder::from_psbt_and_uri(psbt_base64, Arc::new(pj_uri.check_pj_supported().unwrap()))? - .build_with_additional_fee(10000, None, 0, false)? - .extract_v1()?; + let req_ctx = + RequestBuilder::from_psbt_and_uri(psbt_base64, pj_uri.check_pj_supported().unwrap())? + .build_with_additional_fee(10000, None, 0, false)? + .extract_v1()?; let req = req_ctx.request; let ctx = req_ctx.context_v1; let headers = Headers::from_vec(req.body.clone()); @@ -215,11 +216,9 @@ fn extract_pj_tx(sender: &Client, psbt: String) -> payjoin::bitcoin::Transaction let payjoin_psbt = sender.finalize_psbt(&payjoin_psbt, Some(false)).expect("finalize error").psbt.unwrap(); - let payjoin_psbt = - payjoin::bitcoin::psbt::PartiallySignedTransaction::from_str(payjoin_psbt.as_str()) - .unwrap(); + let payjoin_psbt = payjoin::bitcoin::psbt::Psbt::from_str(payjoin_psbt.as_str()).unwrap(); eprintln!("Sender's Payjoin PSBT: {:#?}", payjoin_psbt); - payjoin_psbt.extract_tx() + payjoin_psbt.extract_tx().unwrap() } fn get_client(wallet_name: &str) -> Client { let url = format!("http://{}:{}/wallet/{}", RPC_HOST, RPC_PORT, wallet_name);