-
Notifications
You must be signed in to change notification settings - Fork 114
feat(wallet-connect): impl BTC (UTxO) for swaps v2 #2617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
this method will be needed in swaps as we can't use sendTransfer for unlocking HTLCs (i.e. needed for swaps v1 and v2)
which forces us to return Public instead of &Public from this function, and a whole wave of ripple effects all over
no watchers, just plain swaps v1 methods
the caller needs to provide a map of utxo transactions for the p2pkh inputs, otherwise signing will fail
soley contained in geenrate_and_send_tx
…s in utxo_common so kdf won't panic cuz we don't have walletconnect we better remove these panics tho note that not all these methods are needed for swap v1. but i did them nontheless
requires manual testing with walletconnect capable wallets by the test step by step
idk why we sent the watcher message one time then moved to the next step and created a handle to keep sending it periodically. this commit makes it so we don't do the initial send but only create the handler to keep sending it periodically as before (this part didin't change, but the log message was put in the appropriate place)
this is to be handled in a different PR since it seems it might be complext. we need to sign the watcher msg with the htlc privkey which means we will ask walletconnect for one more signature. this might get entangled with p2p crate code
via reverting back to use derive_htlc_key_pair using the unique swap data
…etconnect signing yet to be tested
This reverts commit 5bf8727.
Co-authored-by: Onur Özkan <[email protected]>
we don't need the custom error message given we already have the error trace using MmError
…ctions for both: p2pkh and p2sh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for swaps v2 (TPU) via WalletConnect for UTxO-based cryptocurrencies. It refactors the existing WalletConnect swap functionality to handle both v1 and v2 swap protocols by introducing a new P2SHSigner abstraction that enables cooperative signing for funding and payment spend transactions.
- Introduces
P2SHSignerenum to abstract between KeyPair and WalletConnect signing methods - Adds new WalletConnect signing functions for v2 swap cooperative signing
- Updates swap transaction generation and signing functions to use the new signer abstraction
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| wallet_connect_tests.rs | Parameterizes test function to support both v1 and v2 swap protocols |
| wallet_connect.rs | Adds v2-specific WalletConnect signing functions with bare signature extraction |
| utxo_standard.rs | Updates v2 swap operations to use new P2SHSigner abstraction |
| utxo_common.rs | Refactors signing logic throughout swap functions to support both KeyPair and WalletConnect signers |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| ) -> Result<UtxoTx, TransactionErr> { | ||
| let secret_hash = dhash160(secret); | ||
| let redeem_script = swap_proto_v2_scripts::taker_payment_script( | ||
| try_tx_s!(gen_args.time_lock.try_into()), | ||
| secret_hash.as_slice(), | ||
| gen_args.taker_pub, | ||
| htlc_keypair.public(), | ||
| gen_args.maker_pub, |
Copilot
AI
Sep 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line appears to be a bug fix - changing from htlc_keypair.public() to gen_args.maker_pub. This should be verified as it changes the public key being used in the script generation.
|
@dimxy @shamardy @onur-ozkan |
|
@dimxy @shamardy @onur-ozkan |
|
@dimxy @shamardy @onur-ozkan |
|
@dimxy @shamardy @onur-ozkan |
|
@dimxy @shamardy @onur-ozkan |
7 similar comments
|
@dimxy @shamardy @onur-ozkan |
|
@dimxy @shamardy @onur-ozkan |
|
@dimxy @shamardy @onur-ozkan |
|
@dimxy @shamardy @onur-ozkan |
|
@dimxy @shamardy @onur-ozkan |
|
@dimxy @shamardy @onur-ozkan |
|
@dimxy @shamardy @onur-ozkan |
|
@shamardy |
1 similar comment
|
@shamardy |
|
@shamardy |
This PR adds support for swaps v2 (TPU) via WalletConnect for UTxO.
The only difference in transaction signing between v1 and v2 swaps are just the co-operative signing step in:
funding spend (aka taker payment)taker payment spend (aka finalizing tx)In these two, each side performs pretty much the same P2SH signing call as before but only stores (and sends) the bare signature returned from WalletConnect. This is analogous to calling
calc_and_sign_sighashusing aKeyPair.And then the same process as before goes on: signatures are later combined to create the complete
script_sig, etc...A manual test is added for this feat:
test_walletconnect_swap_v2, and this: #2566 (comment) is how to run it.