How to turn principal+subaccount into a subaccount of a canister?

say a user calls a canister and provide a subaccount

and the canister will use its own canister id as principal, but how to convert the caller principal and the given subaccount into the canister’s subaccount?

should i turn the caller’s principal+subaccount to accoundid blob first? since it’s 32 bytes same as subaccount?

thank you for your time

1 Like

If it is important to preserve the user-specified subaccount, then turning principal/subaccount into an account id sounds pretty reasonable. If you only care about the principal, then I would suggest using this function

1 Like