pub fn derivative_account_id<AccountId: Encode + Decode>(
who: AccountId,
index: u16,
) -> AccountId
Expand description
Derive a derivative account ID from the owner account and the sub-account index.
The derived account with index
of who
is defined as:
b2b256("modlpy/utilisuba" ++ who ++ index)
where index is encoded as fixed size SCALE u16, the
prefix string as SCALE u8 vector and who
by its canonical SCALE encoding. The resulting
account ID is then decoded from the hash with trailing zero bytes in case that the AccountId
type is longer than 32 bytes. Note that this could lead to collisions when using AccountId
types that are shorter than 32 bytes, especially in testing environments that are using u64.