-
Notifications
You must be signed in to change notification settings - Fork 19
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
Magic Routing Hint #43
Conversation
src/util/mod.rs
Outdated
|
||
use crate::{error::Error, network::electrum::ElectrumConfig}; | ||
|
||
pub mod ec; | ||
pub mod secrets; | ||
|
||
const ENDPOINT: &str = "https://api.testnet.boltz.exchange"; | ||
const MAGIC_ROUTING_HINT_CONSTANT: &str = "0846c900051c0000"; | ||
const LBTC_ASSET_HASH: &str = "144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49"; |
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.
The L-BTC asset hash depends on the network
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.
I only found one asset hash from your doc. Added a placeholder for mainnet asset hash. Can be easily updated when I have it.
tests/bitcoin_v2.rs
Outdated
let address_hash = sha256::Hash::hash(&Vec::from_hex(&bip21.address.to_string()).unwrap()); | ||
let msg = Message::from_digest_slice(address_hash.as_byte_array()).unwrap(); | ||
|
||
let receiver_sig = bitcoin::secp256k1::schnorr::Signature::from_slice( | ||
&Vec::from_hex(&mrh_resp.signature).unwrap(), | ||
) | ||
.unwrap(); | ||
|
||
let receiver_pubkey = PublicKey::from_str(&route_hint.src_node_id.to_string()) | ||
.unwrap() | ||
.inner; | ||
|
||
secp.verify_schnorr(&receiver_sig, &msg, &receiver_pubkey.x_only_public_key().0) | ||
.unwrap(); |
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 shouldn't just be in a test but a public function that is available for consumers of the library to
call
We might want to integrate this in the library function that creates a swap
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.
There is no function as "create swap". Depends on the structure of the lib. Currently swap creating steps are in the test itself. Moved the MRH parts into it's own module magic_routing.rs
and all the relevant functions are added there.
Create a new Magic Routing Hint module with all the relevant code. Remove them from utility module. New place holder added for liquid mainnet asset hash. Remove bip21 as uri parsing isn't supported for liquid. So manual URI string parsing is added.
Thanks @rajarshimaitra ! |
This code adds the Magic Routing Hint logic. As most of the logic is at the application layer, the code is added in the test cases of v2 swaps.
No changes in the internals of the library is required.
This is untested. And to test it one has to perform the following.