Persu
September 12, 2022, 7:37am
1
I am using WSL 2 in my windows 10. I have follow all the steps to set up bitcoin integration locally. It works fine. When I open the candid UI and call the function get_p2pkh_address it shows me an error!
I have also tried calling the same from the terminal using the command
dfx canister call basic_bitcoin get_p2pkh_address
and It shows me the same error
Error: Failed update call.
Caused by: Failed update call.
The Replica returned an error: code 4, message: "No route to canister aaaaa-aa"
What causing this error?
2 Likes
kinwo
September 13, 2022, 5:16am
2
I came across the same error when I deploy basic_bitcoin example (either local or IC mainnet).
However, the other example - threshold-ecdsa works perfectly fine.
I have a quick look on the code.
threshold-ecdsa uses lower case secp256k1 while basic_bitcoin use uppercase Secp256k1.
let ecdsa_canister_actor : EcdsaCanisterActor = actor("aaaaa-aa");
/// Returns the ECDSA public key of this canister at the given derivation path.
public func ecdsa_public_key(key_name : Text, derivation_path : [Blob]) : async Blob {
// Retrieve the public key of this canister at derivation path
// from the ECDSA API.
let res = await ecdsa_canister_actor.ecdsa_public_key({
canister_id = null;
derivation_path;
key_id = {
curve = #Secp256k1;
name = key_name;
};
});
res.public_key
};
public func sign_with_ecdsa(key_name : Text, derivation_path : [Blob], message_hash : Blob) : async Blob {
ExperimentalCycles.add(10_000_000_000);
let res = await ecdsa_canister_actor.sign_with_ecdsa({
res.public_key
};
public func sign_with_ecdsa(key_name : Text, derivation_path : [Blob], message_hash : Blob) : async Blob {
ExperimentalCycles.add(10_000_000_000);
let res = await ecdsa_canister_actor.sign_with_ecdsa({
message_hash;
derivation_path;
key_id = {
curve = #Secp256k1;
name = key_name;
};
});
res.signature
};
}
After I updated basic_bitcoin to use lower case secp256k1 and redeploy, it works fine with local regtest and IC Bitcoin testnet.
Give it a try. See if it works.
Btw, I am on dfx 0.11.2.
4 Likes
ielashi
September 13, 2022, 11:26am
3
@kinwo Thanks for looking into this.
This looks like a bug in the Motoko example. We just opened a PR now to fix this. In the future, don’t hesitate to open a PR if you find other issues
Update: The fix has now been merged into the dfinity/examples
repo.
4 Likes
kinwo
September 14, 2022, 12:51am
4
Awesome! Thanks for updating it. I was about to submit PR.