The error is produced here:
I’m using an address derived this way
// Get BTC address for a given user:
public func get_btc_address_for_a_given_user(user_principal : Principal) : async Text {
let derivation_path_with_double_array : [[Nat8]] = await get_btc_derivation_path_for_a_given_user(user_principal);
let bitcoin_address : Text = await get_p2pkh_address_for_a_given_derivation_path(derivation_path_with_double_array);
return bitcoin_address;
};
// Get BTC derivation path for a given user:
public func get_btc_derivation_path_for_a_given_user(user_principal : Principal) : async [[Nat8]] {
let user_principal_blob : Blob = Principal.toBlob(user_principal);
let user_principal_array : [Nat8] = Blob.toArray(user_principal_blob);
let derivation_path_with_double_array : [[Nat8]] = [user_principal_array];
return derivation_path_with_double_array;
};
// Adapted from BasicBitcoin example:
/// Returns the P2PKH address of this canister for a given (as an argument) derivation path.
public func get_p2pkh_address_for_a_given_derivation_path(derivation_path : [[Nat8]]) : async BitcoinAddress {
await BitcoinWallet.get_p2pkh_address(NETWORK, KEY_NAME, derivation_path);
};
And on send I’m seeing
Uncaught (in promise) Error: Call was rejected:
Request ID: bdd267afdeb9a1abda78fd1627bbdae5ea7654a2ef1e03e7ab43f64f7fa63ab6
Reject code: 4
Reject text: IC0503: Canister rrkah-fqaaa-aaaaa-aaaaq-cai trapped explicitly: Error building transaction.
and
[Canister rrkah-fqaaa-aaaaa-aaaaq-cai] Fetching UTXOs...
[Canister rrkah-fqaaa-aaaaa-aaaaq-cai] Building transaction...
[Canister rrkah-fqaaa-aaaaa-aaaaq-cai] pattern failed
How might I fix this?
The problem arises only on send. Address generation throws no errors.