Trap in Motoko Bitcoin example

Hello ,

I’m trying to get through the example
[examples/motoko/basic_bitcoin/README.md at master · dfinity/examples · GitHub](https://Motoko basic bitcoin)

When I get to :

dfx canister --network=ic call basic_bitcoin send '(record { destination_address = "tb1ql7w62elx9ucw4pj5lgw4l028hmuw80sndtntxt"; amount_in_satoshi = 4321; })'

The aswer is:


Error: Failed update call.
Caused by: The replica returned a rejection error: reject code CanisterReject, reject message IC0503: Error from Canister o2zdy-paaaa-aaaap-ahukq-cai: Canister called `ic0.trap` with message: assertion failed at Base58.mo:89.11-89.32.
Consider gracefully handling failures from this canister or altering the canister to handle exceptions. See documentation: http://internetcomputer.org/docs/current/references/execution-errors#trapped-explicitly, error code None

So sending the transaction is unsuccessfull

Please, help

Matiki

1 Like

How did you get this Bitcoin address? I see that may not be in Base58 format since there are zeros in it. Any insight on which type of address this is would be helpful!

I took it from

I can see addresses like that on the Bitcoin testnet3 explorer
https://live.blockcypher.com/btc-testnet/address/tb1p7akprqxz7hwqgfvhz6len7t8nzfvfuuvzlpvux0f5a7fwdx5ne5qe3xksg/

Let me do some digging and get back to you by tomorrow.

Thank you for pointing this out.

Our team advised that the Motoko example currently only supports P2PKH addresses which are in Base58 format.

The Rust example supports P2TR addresses which are not in Base58 format. The example provided is only valid for the Rust example. We’ll update the docs to make it more clear that you need to use a Base58 address for the Motoko example

You will need to use a P2PKH address for the Motoko example.

Hi Jennifer,

Thank you so much for the quick response and for looking into this. I appreciate the clarification on the address format and the support from your team.

I’ll go ahead and try using a P2PKH address as you suggested.

Thanks again for your help!

Best,
Matiki