Cycles withdrawal from canister when deleting throws error

I am trying to delete a canister and withdraw the remaining cycles from it using this call

dfx canister --network ic delete --withdraw-cycles-to-dank

The call fails right after the console prints this

Transfering 3883671082016 cycles to dank principal .

with an error saying

The invocation to the wallet call forward method failed with the error: An error happened during the call: 5: IC0503: Canister trapped explicitly: Custom(Fail to decode argument 0 from table0 to principal

> Caused by:
>     0: input: 4449444c016e680100_01011dcec68e31c2ed30bd538dc5d5db7399095d6ddc5c6565d9faf1b2036b02
>        table: type table0 = opt principal
>        wire_type: table0, expect_type: principal
>     1: table0 is not a subtype of principal
>     2: opt principal is not a subtype of principal)

The canister is written in Motoko

Which version of dfx are we talking about? 0.10.1?

Yes, sorry. Should have mentioned.

Dfx version: 0.10.1
OS: Ubuntu 20.04

Hmm… I’m not familiar with the withdraw-cycles-to-dank flag. Do you need that one really? If you skip it, dfx should automatically withdraw the cycles to your wallet. Or does that not work for you?

1 Like

Well…I did not try it because I was not sure that the cycles will be given back to me. But I’ll try it now that you confirmed it.

dfx only does not withdraw the cycles if you add --no-withdrawal. Otherwise I’d consider that a critical bug.

1 Like