language/diem-framework/modules/doc/AccountAdministrationScripts.md
<a name="0x1_AccountAdministrationScripts"></a>
0x1::AccountAdministrationScriptsThis module holds transactions that can be used to administer accounts in the Diem Framework.
add_currency_to_account
add_recovery_rotation_capability
publish_shared_ed25519_public_key
rotate_authentication_key
rotate_authentication_key_with_nonce
rotate_authentication_key_with_nonce_admin
rotate_authentication_key_with_recovery_address
rotate_dual_attestation_info
rotate_shared_ed25519_public_key
create_recovery_address
create_vasp_domains
opt_in_to_crsn
force_expire
<a name="0x1_AccountAdministrationScripts_add_currency_to_account"></a>
add_currency_to_account<a name="@Summary_0"></a>
Adds a zero <code>Currency</code> balance to the sending <code>account</code>. This will enable <code>account</code> to send, receive, and hold <code><a href="Diem.md#0x1_Diem_Diem">Diem::Diem</a><Currency></code> coins. This transaction can be successfully sent by any account that is allowed to hold balances (e.g., VASP, Designated Dealer).
<a name="@Technical_Description_1"></a>
After the successful execution of this transaction the sending account will have a <code><a href="DiemAccount.md#0x1_DiemAccount_Balance">DiemAccount::Balance</a><Currency></code> resource with zero balance published under it. Only accounts that can hold balances can send this transaction, the sending account cannot already have a <code><a href="DiemAccount.md#0x1_DiemAccount_Balance">DiemAccount::Balance</a><Currency></code> published under it.
<a name="@Parameters_2"></a>
| Name | Type | Description |
|---|---|---|
| <code>Currency</code> | Type | The Move type for the <code>Currency</code> being added to the sending account of the transaction. <code>Currency</code> must be an already-registered currency on-chain. |
| <code>account</code> | <code>signer</code> | The signer of the sending account of the transaction. |
<a name="@Common_Abort_Conditions_3"></a>
| Error Category | Error Reason | Description |
|---|---|---|
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_NOT_PUBLISHED">Errors::NOT_PUBLISHED</a></code> | <code><a href="Diem.md#0x1_Diem_ECURRENCY_INFO">Diem::ECURRENCY_INFO</a></code> | The <code>Currency</code> is not a registered currency on-chain. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a></code> | <code><a href="DiemAccount.md#0x1_DiemAccount_EROLE_CANT_STORE_BALANCE">DiemAccount::EROLE_CANT_STORE_BALANCE</a></code> | The sending <code>account</code>'s role does not permit balances. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_ALREADY_PUBLISHED">Errors::ALREADY_PUBLISHED</a></code> | <code><a href="DiemAccount.md#0x1_DiemAccount_EADD_EXISTING_CURRENCY">DiemAccount::EADD_EXISTING_CURRENCY</a></code> | A balance for <code>Currency</code> is already published under the sending <code>account</code>. |
<a name="@Related_Scripts_4"></a>
Access Control: The account must be allowed to hold balances. Only Designated Dealers, Parent VASPs, and Child VASPs can hold balances [D1][D2][D3][D4][D5][D6][D7].
<pre><code><b>aborts_if</b> !<a href="Roles.md#0x1_Roles_can_hold_balance">Roles::can_hold_balance</a>(account) <b>with</b> <a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a>; </code></pre> </details><a name="0x1_AccountAdministrationScripts_add_recovery_rotation_capability"></a>
add_recovery_rotation_capability<a name="@Summary_5"></a>
Stores the sending accounts ability to rotate its authentication key with a designated recovery account. Both the sending and recovery accounts need to belong to the same VASP and both be VASP accounts. After this transaction both the sending account and the specified recovery account can rotate the sender account's authentication key.
<a name="@Technical_Description_6"></a>
Adds the <code><a href="DiemAccount.md#0x1_DiemAccount_KeyRotationCapability">DiemAccount::KeyRotationCapability</a></code> for the sending account (<code>to_recover_account</code>) to the <code><a href="RecoveryAddress.md#0x1_RecoveryAddress_RecoveryAddress">RecoveryAddress::RecoveryAddress</a></code> resource under <code>recovery_address</code>. After this transaction has been executed successfully the account at <code>recovery_address</code> and the <code>to_recover_account</code> may rotate the authentication key of <code>to_recover_account</code> (the sender of this transaction).
The sending account of this transaction (<code>to_recover_account</code>) must not have previously given away its unique key rotation capability, and must be a VASP account. The account at <code>recovery_address</code> must also be a VASP account belonging to the same VASP as the <code>to_recover_account</code>. Additionally the account at <code>recovery_address</code> must have already initialized itself as a recovery account address using the <code><a href="AccountAdministrationScripts.md#0x1_AccountAdministrationScripts_create_recovery_address">AccountAdministrationScripts::create_recovery_address</a></code> transaction script.
The sending account's (<code>to_recover_account</code>) key rotation capability is removed in this transaction and stored in the <code><a href="RecoveryAddress.md#0x1_RecoveryAddress_RecoveryAddress">RecoveryAddress::RecoveryAddress</a></code> resource stored under the account at <code>recovery_address</code>.
<a name="@Parameters_7"></a>
| Name | Type | Description |
|---|---|---|
| <code>to_recover_account</code> | <code>signer</code> | The signer of the sending account of this transaction. |
| <code>recovery_address</code> | <code>address</code> | The account address where the <code>to_recover_account</code>'s <code><a href="DiemAccount.md#0x1_DiemAccount_KeyRotationCapability">DiemAccount::KeyRotationCapability</a></code> will be stored. |
<a name="@Common_Abort_Conditions_8"></a>
| Error Category | Error Reason | Description |
|---|---|---|
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_STATE">Errors::INVALID_STATE</a></code> | <code><a href="DiemAccount.md#0x1_DiemAccount_EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED">DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED</a></code> | <code>to_recover_account</code> has already delegated/extracted its <code><a href="DiemAccount.md#0x1_DiemAccount_KeyRotationCapability">DiemAccount::KeyRotationCapability</a></code>. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_NOT_PUBLISHED">Errors::NOT_PUBLISHED</a></code> | <code><a href="RecoveryAddress.md#0x1_RecoveryAddress_ERECOVERY_ADDRESS">RecoveryAddress::ERECOVERY_ADDRESS</a></code> | <code>recovery_address</code> does not have a <code><a href="RecoveryAddress.md#0x1_RecoveryAddress">RecoveryAddress</a></code> resource published under it. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a></code> | <code><a href="RecoveryAddress.md#0x1_RecoveryAddress_EINVALID_KEY_ROTATION_DELEGATION">RecoveryAddress::EINVALID_KEY_ROTATION_DELEGATION</a></code> | <code>to_recover_account</code> and <code>recovery_address</code> do not belong to the same VASP. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_LIMIT_EXCEEDED">Errors::LIMIT_EXCEEDED</a></code> | <code> <a href="RecoveryAddress.md#0x1_RecoveryAddress_EMAX_KEYS_REGISTERED">RecoveryAddress::EMAX_KEYS_REGISTERED</a></code> | <code><a href="RecoveryAddress.md#0x1_RecoveryAddress_MAX_REGISTERED_KEYS">RecoveryAddress::MAX_REGISTERED_KEYS</a></code> have already been registered with this <code>recovery_address</code>. |
<a name="@Related_Scripts_9"></a>
<a name="0x1_AccountAdministrationScripts_publish_shared_ed25519_public_key"></a>
publish_shared_ed25519_public_key<a name="@Summary_10"></a>
Rotates the authentication key of the sending account to the newly-specified ed25519 public key and publishes a new shared authentication key derived from that public key under the sender's account. Any account can send this transaction.
<a name="@Technical_Description_11"></a>
Rotates the authentication key of the sending account to the authentication key derived from <code>public_key</code> and publishes a <code><a href="SharedEd25519PublicKey.md#0x1_SharedEd25519PublicKey_SharedEd25519PublicKey">SharedEd25519PublicKey::SharedEd25519PublicKey</a></code> resource containing the 32-byte ed25519 <code>public_key</code> and the <code><a href="DiemAccount.md#0x1_DiemAccount_KeyRotationCapability">DiemAccount::KeyRotationCapability</a></code> for <code>account</code> under <code>account</code>.
<a name="@Parameters_12"></a>
| Name | Type | Description |
|---|---|---|
| <code>account</code> | <code>signer</code> | The signer of the sending account of the transaction. |
| <code>public_key</code> | <code>vector<u8></code> | A valid 32-byte Ed25519 public key for <code>account</code>'s authentication key to be rotated to and stored. |
<a name="@Common_Abort_Conditions_13"></a>
| Error Category | Error Reason | Description |
|---|---|---|
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_STATE">Errors::INVALID_STATE</a></code> | <code><a href="DiemAccount.md#0x1_DiemAccount_EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED">DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED</a></code> | <code>account</code> has already delegated/extracted its <code><a href="DiemAccount.md#0x1_DiemAccount_KeyRotationCapability">DiemAccount::KeyRotationCapability</a></code> resource. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_ALREADY_PUBLISHED">Errors::ALREADY_PUBLISHED</a></code> | <code><a href="SharedEd25519PublicKey.md#0x1_SharedEd25519PublicKey_ESHARED_KEY">SharedEd25519PublicKey::ESHARED_KEY</a></code> | The <code><a href="SharedEd25519PublicKey.md#0x1_SharedEd25519PublicKey_SharedEd25519PublicKey">SharedEd25519PublicKey::SharedEd25519PublicKey</a></code> resource is already published under <code>account</code>. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a></code> | <code><a href="SharedEd25519PublicKey.md#0x1_SharedEd25519PublicKey_EMALFORMED_PUBLIC_KEY">SharedEd25519PublicKey::EMALFORMED_PUBLIC_KEY</a></code> | <code>public_key</code> is an invalid ed25519 public key. |
<a name="@Related_Scripts_14"></a>
<a name="0x1_AccountAdministrationScripts_rotate_authentication_key"></a>
rotate_authentication_key<a name="@Summary_15"></a>
Rotates the <code>account</code>'s authentication key to the supplied new authentication key. May be sent by any account.
<a name="@Technical_Description_16"></a>
Rotate the <code>account</code>'s <code><a href="DiemAccount.md#0x1_DiemAccount_DiemAccount">DiemAccount::DiemAccount</a></code> <code>authentication_key</code> field to <code>new_key</code>. <code>new_key</code> must be a valid authentication key that corresponds to an ed25519 public key as described here, and <code>account</code> must not have previously delegated its <code><a href="DiemAccount.md#0x1_DiemAccount_KeyRotationCapability">DiemAccount::KeyRotationCapability</a></code>.
<a name="@Parameters_17"></a>
| Name | Type | Description |
|---|---|---|
| <code>account</code> | <code>signer</code> | Signer of the sending account of the transaction. |
| <code>new_key</code> | <code>vector<u8></code> | New authentication key to be used for <code>account</code>. |
<a name="@Common_Abort_Conditions_18"></a>
| Error Category | Error Reason | Description |
|---|---|---|
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_STATE">Errors::INVALID_STATE</a></code> | <code><a href="DiemAccount.md#0x1_DiemAccount_EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED">DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED</a></code> | <code>account</code> has already delegated/extracted its <code><a href="DiemAccount.md#0x1_DiemAccount_KeyRotationCapability">DiemAccount::KeyRotationCapability</a></code>. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a></code> | <code><a href="DiemAccount.md#0x1_DiemAccount_EMALFORMED_AUTHENTICATION_KEY">DiemAccount::EMALFORMED_AUTHENTICATION_KEY</a></code> | <code>new_key</code> was an invalid length. |
<a name="@Related_Scripts_19"></a>
This rotates the authentication key of <code>account</code> to <code>new_key</code>
<pre><code><b>include</b> <a href="DiemAccount.md#0x1_DiemAccount_RotateAuthenticationKeyEnsures">DiemAccount::RotateAuthenticationKeyEnsures</a>{addr: account_addr, new_authentication_key: new_key}; <b>aborts_with</b> [check] <a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_STATE">Errors::INVALID_STATE</a>, <a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a>; </code></pre>Access Control: The account can rotate its own authentication key unless it has delegrated the capability [H18][J18].
<pre><code><b>include</b> <a href="DiemAccount.md#0x1_DiemAccount_AbortsIfDelegatedKeyRotationCapability">DiemAccount::AbortsIfDelegatedKeyRotationCapability</a>; </code></pre> </details><a name="0x1_AccountAdministrationScripts_rotate_authentication_key_with_nonce"></a>
rotate_authentication_key_with_nonce<a name="@Summary_20"></a>
Rotates the sender's authentication key to the supplied new authentication key. May be sent by any account that has a sliding nonce resource published under it (usually this is Treasury Compliance or Diem Root accounts).
<a name="@Technical_Description_21"></a>
Rotates the <code>account</code>'s <code><a href="DiemAccount.md#0x1_DiemAccount_DiemAccount">DiemAccount::DiemAccount</a></code> <code>authentication_key</code> field to <code>new_key</code>. <code>new_key</code> must be a valid authentication key that corresponds to an ed25519 public key as described here, and <code>account</code> must not have previously delegated its <code><a href="DiemAccount.md#0x1_DiemAccount_KeyRotationCapability">DiemAccount::KeyRotationCapability</a></code>.
<a name="@Parameters_22"></a>
| Name | Type | Description |
|---|---|---|
| <code>account</code> | <code>signer</code> | Signer of the sending account of the transaction. |
| <code>sliding_nonce</code> | <code>u64</code> | The <code>sliding_nonce</code> (see: <code><a href="SlidingNonce.md#0x1_SlidingNonce">SlidingNonce</a></code>) to be used for this transaction. |
| <code>new_key</code> | <code>vector<u8></code> | New authentication key to be used for <code>account</code>. |
<a name="@Common_Abort_Conditions_23"></a>
| Error Category | Error Reason | Description |
|---|---|---|
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_NOT_PUBLISHED">Errors::NOT_PUBLISHED</a></code> | <code><a href="SlidingNonce.md#0x1_SlidingNonce_ESLIDING_NONCE">SlidingNonce::ESLIDING_NONCE</a></code> | A <code><a href="SlidingNonce.md#0x1_SlidingNonce">SlidingNonce</a></code> resource is not published under <code>account</code>. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a></code> | <code><a href="SlidingNonce.md#0x1_SlidingNonce_ENONCE_TOO_OLD">SlidingNonce::ENONCE_TOO_OLD</a></code> | The <code>sliding_nonce</code> is too old and it's impossible to determine if it's duplicated or not. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a></code> | <code><a href="SlidingNonce.md#0x1_SlidingNonce_ENONCE_TOO_NEW">SlidingNonce::ENONCE_TOO_NEW</a></code> | The <code>sliding_nonce</code> is too far in the future. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a></code> | <code><a href="SlidingNonce.md#0x1_SlidingNonce_ENONCE_ALREADY_RECORDED">SlidingNonce::ENONCE_ALREADY_RECORDED</a></code> | The <code>sliding_nonce</code> has been previously recorded. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_STATE">Errors::INVALID_STATE</a></code> | <code><a href="DiemAccount.md#0x1_DiemAccount_EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED">DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED</a></code> | <code>account</code> has already delegated/extracted its <code><a href="DiemAccount.md#0x1_DiemAccount_KeyRotationCapability">DiemAccount::KeyRotationCapability</a></code>. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a></code> | <code><a href="DiemAccount.md#0x1_DiemAccount_EMALFORMED_AUTHENTICATION_KEY">DiemAccount::EMALFORMED_AUTHENTICATION_KEY</a></code> | <code>new_key</code> was an invalid length. |
<a name="@Related_Scripts_24"></a>
This rotates the authentication key of <code>account</code> to <code>new_key</code>
<pre><code><b>include</b> <a href="DiemAccount.md#0x1_DiemAccount_RotateAuthenticationKeyEnsures">DiemAccount::RotateAuthenticationKeyEnsures</a>{addr: account_addr, new_authentication_key: new_key}; <b>aborts_with</b> [check] <a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a>, <a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_STATE">Errors::INVALID_STATE</a>, <a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_NOT_PUBLISHED">Errors::NOT_PUBLISHED</a>; </code></pre>Access Control: The account can rotate its own authentication key unless it has delegrated the capability [H18][J18].
<pre><code><b>include</b> <a href="DiemAccount.md#0x1_DiemAccount_AbortsIfDelegatedKeyRotationCapability">DiemAccount::AbortsIfDelegatedKeyRotationCapability</a>; </code></pre> </details><a name="0x1_AccountAdministrationScripts_rotate_authentication_key_with_nonce_admin"></a>
rotate_authentication_key_with_nonce_admin<a name="@Summary_25"></a>
Rotates the specified account's authentication key to the supplied new authentication key. May only be sent by the Diem Root account as a write set transaction.
<a name="@Technical_Description_26"></a>
Rotate the <code>account</code>'s <code><a href="DiemAccount.md#0x1_DiemAccount_DiemAccount">DiemAccount::DiemAccount</a></code> <code>authentication_key</code> field to <code>new_key</code>. <code>new_key</code> must be a valid authentication key that corresponds to an ed25519 public key as described here, and <code>account</code> must not have previously delegated its <code><a href="DiemAccount.md#0x1_DiemAccount_KeyRotationCapability">DiemAccount::KeyRotationCapability</a></code>.
<a name="@Parameters_27"></a>
| Name | Type | Description |
|---|---|---|
| <code>dr_account</code> | <code>signer</code> | The signer of the sending account of the write set transaction. May only be the Diem Root signer. |
| <code>account</code> | <code>signer</code> | Signer of account specified in the <code>execute_as</code> field of the write set transaction. |
| <code>sliding_nonce</code> | <code>u64</code> | The <code>sliding_nonce</code> (see: <code><a href="SlidingNonce.md#0x1_SlidingNonce">SlidingNonce</a></code>) to be used for this transaction for Diem Root. |
| <code>new_key</code> | <code>vector<u8></code> | New authentication key to be used for <code>account</code>. |
<a name="@Common_Abort_Conditions_28"></a>
| Error Category | Error Reason | Description |
|---|---|---|
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_NOT_PUBLISHED">Errors::NOT_PUBLISHED</a></code> | <code><a href="SlidingNonce.md#0x1_SlidingNonce_ESLIDING_NONCE">SlidingNonce::ESLIDING_NONCE</a></code> | A <code><a href="SlidingNonce.md#0x1_SlidingNonce">SlidingNonce</a></code> resource is not published under <code>dr_account</code>. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a></code> | <code><a href="SlidingNonce.md#0x1_SlidingNonce_ENONCE_TOO_OLD">SlidingNonce::ENONCE_TOO_OLD</a></code> | The <code>sliding_nonce</code> in <code>dr_account</code> is too old and it's impossible to determine if it's duplicated or not. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a></code> | <code><a href="SlidingNonce.md#0x1_SlidingNonce_ENONCE_TOO_NEW">SlidingNonce::ENONCE_TOO_NEW</a></code> | The <code>sliding_nonce</code> in <code>dr_account</code> is too far in the future. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a></code> | <code><a href="SlidingNonce.md#0x1_SlidingNonce_ENONCE_ALREADY_RECORDED">SlidingNonce::ENONCE_ALREADY_RECORDED</a></code> | The <code>sliding_nonce</code> in<code> dr_account</code> has been previously recorded. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_STATE">Errors::INVALID_STATE</a></code> | <code><a href="DiemAccount.md#0x1_DiemAccount_EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED">DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED</a></code> | <code>account</code> has already delegated/extracted its <code><a href="DiemAccount.md#0x1_DiemAccount_KeyRotationCapability">DiemAccount::KeyRotationCapability</a></code>. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a></code> | <code><a href="DiemAccount.md#0x1_DiemAccount_EMALFORMED_AUTHENTICATION_KEY">DiemAccount::EMALFORMED_AUTHENTICATION_KEY</a></code> | <code>new_key</code> was an invalid length. |
<a name="@Related_Scripts_29"></a>
This rotates the authentication key of <code>account</code> to <code>new_key</code>
<pre><code><b>include</b> <a href="DiemAccount.md#0x1_DiemAccount_RotateAuthenticationKeyEnsures">DiemAccount::RotateAuthenticationKeyEnsures</a>{addr: account_addr, new_authentication_key: new_key}; <b>aborts_with</b> [check] <a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a>, <a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_STATE">Errors::INVALID_STATE</a>, <a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_NOT_PUBLISHED">Errors::NOT_PUBLISHED</a>; </code></pre>Access Control: Only the Diem Root account can process the admin scripts [H9].
<pre><code><b>requires</b> <a href="Roles.md#0x1_Roles_has_diem_root_role">Roles::has_diem_root_role</a>(dr_account); </code></pre>This is ensured by DiemAccount::writeset_prologue. The account can rotate its own authentication key unless it has delegrated the capability [H18][J18].
<pre><code><b>include</b> <a href="DiemAccount.md#0x1_DiemAccount_AbortsIfDelegatedKeyRotationCapability">DiemAccount::AbortsIfDelegatedKeyRotationCapability</a>{account: account}; </code></pre> </details><a name="0x1_AccountAdministrationScripts_rotate_authentication_key_with_recovery_address"></a>
rotate_authentication_key_with_recovery_address<a name="@Summary_30"></a>
Rotates the authentication key of a specified account that is part of a recovery address to a new authentication key. Only used for accounts that are part of a recovery address (see <code><a href="AccountAdministrationScripts.md#0x1_AccountAdministrationScripts_add_recovery_rotation_capability">AccountAdministrationScripts::add_recovery_rotation_capability</a></code> for account restrictions).
<a name="@Technical_Description_31"></a>
Rotates the authentication key of the <code>to_recover</code> account to <code>new_key</code> using the <code><a href="DiemAccount.md#0x1_DiemAccount_KeyRotationCapability">DiemAccount::KeyRotationCapability</a></code> stored in the <code><a href="RecoveryAddress.md#0x1_RecoveryAddress_RecoveryAddress">RecoveryAddress::RecoveryAddress</a></code> resource published under <code>recovery_address</code>. <code>new_key</code> must be a valide authentication key as described here. This transaction can be sent either by the <code>to_recover</code> account, or by the account where the <code><a href="RecoveryAddress.md#0x1_RecoveryAddress_RecoveryAddress">RecoveryAddress::RecoveryAddress</a></code> resource is published that contains <code>to_recover</code>'s <code><a href="DiemAccount.md#0x1_DiemAccount_KeyRotationCapability">DiemAccount::KeyRotationCapability</a></code>.
<a name="@Parameters_32"></a>
| Name | Type | Description |
|---|---|---|
| <code>account</code> | <code>signer</code> | Signer of the sending account of the transaction. |
| <code>recovery_address</code> | <code>address</code> | Address where <code><a href="RecoveryAddress.md#0x1_RecoveryAddress_RecoveryAddress">RecoveryAddress::RecoveryAddress</a></code> that holds <code>to_recover</code>'s <code><a href="DiemAccount.md#0x1_DiemAccount_KeyRotationCapability">DiemAccount::KeyRotationCapability</a></code> is published. |
| <code>to_recover</code> | <code>address</code> | The address of the account whose authentication key will be updated. |
| <code>new_key</code> | <code>vector<u8></code> | New authentication key to be used for the account at the <code>to_recover</code> address. |
<a name="@Common_Abort_Conditions_33"></a>
| Error Category | Error Reason | Description |
|---|---|---|
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_NOT_PUBLISHED">Errors::NOT_PUBLISHED</a></code> | <code><a href="RecoveryAddress.md#0x1_RecoveryAddress_ERECOVERY_ADDRESS">RecoveryAddress::ERECOVERY_ADDRESS</a></code> | <code>recovery_address</code> does not have a <code><a href="RecoveryAddress.md#0x1_RecoveryAddress_RecoveryAddress">RecoveryAddress::RecoveryAddress</a></code> resource published under it. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a></code> | <code><a href="RecoveryAddress.md#0x1_RecoveryAddress_ECANNOT_ROTATE_KEY">RecoveryAddress::ECANNOT_ROTATE_KEY</a></code> | The address of <code>account</code> is not <code>recovery_address</code> or <code>to_recover</code>. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a></code> | <code><a href="RecoveryAddress.md#0x1_RecoveryAddress_EACCOUNT_NOT_RECOVERABLE">RecoveryAddress::EACCOUNT_NOT_RECOVERABLE</a></code> | <code>to_recover</code>'s <code><a href="DiemAccount.md#0x1_DiemAccount_KeyRotationCapability">DiemAccount::KeyRotationCapability</a></code> is not in the <code><a href="RecoveryAddress.md#0x1_RecoveryAddress_RecoveryAddress">RecoveryAddress::RecoveryAddress</a></code> resource published under <code>recovery_address</code>. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a></code> | <code><a href="DiemAccount.md#0x1_DiemAccount_EMALFORMED_AUTHENTICATION_KEY">DiemAccount::EMALFORMED_AUTHENTICATION_KEY</a></code> | <code>new_key</code> was an invalid length. |
<a name="@Related_Scripts_34"></a>
Access Control: The delegatee at the recovery address has to hold the key rotation capability for the address to recover. The address of the transaction signer has to be either the delegatee's address or the address to recover [H18][J18].
<pre><code><b>let</b> account_addr = <a href="../../../../../../move-stdlib/docs/Signer.md#0x1_Signer_spec_address_of">Signer::spec_address_of</a>(account); <b>aborts_if</b> !<a href="RecoveryAddress.md#0x1_RecoveryAddress_spec_holds_key_rotation_cap_for">RecoveryAddress::spec_holds_key_rotation_cap_for</a>(recovery_address, to_recover) <b>with</b> <a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a>; <b>aborts_if</b> !(account_addr == recovery_address || account_addr == to_recover) <b>with</b> <a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a>; </code></pre> </details><a name="0x1_AccountAdministrationScripts_rotate_dual_attestation_info"></a>
rotate_dual_attestation_info<a name="@Summary_35"></a>
Updates the url used for off-chain communication, and the public key used to verify dual attestation on-chain. Transaction can be sent by any account that has dual attestation information published under it. In practice the only such accounts are Designated Dealers and Parent VASPs.
<a name="@Technical_Description_36"></a>
Updates the <code>base_url</code> and <code>compliance_public_key</code> fields of the <code><a href="DualAttestation.md#0x1_DualAttestation_Credential">DualAttestation::Credential</a></code> resource published under <code>account</code>. The <code>new_key</code> must be a valid ed25519 public key.
<a name="@Events_37"></a>
Successful execution of this transaction emits two events:
<a name="@Parameters_38"></a>
| Name | Type | Description |
|---|---|---|
| <code>account</code> | <code>signer</code> | Signer of the sending account of the transaction. |
| <code>new_url</code> | <code>vector<u8></code> | ASCII-encoded url to be used for off-chain communication with <code>account</code>. |
| <code>new_key</code> | <code>vector<u8></code> | New ed25519 public key to be used for on-chain dual attestation checking. |
<a name="@Common_Abort_Conditions_39"></a>
| Error Category | Error Reason | Description |
|---|---|---|
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_NOT_PUBLISHED">Errors::NOT_PUBLISHED</a></code> | <code><a href="DualAttestation.md#0x1_DualAttestation_ECREDENTIAL">DualAttestation::ECREDENTIAL</a></code> | A <code><a href="DualAttestation.md#0x1_DualAttestation_Credential">DualAttestation::Credential</a></code> resource is not published under <code>account</code>. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a></code> | <code><a href="DualAttestation.md#0x1_DualAttestation_EINVALID_PUBLIC_KEY">DualAttestation::EINVALID_PUBLIC_KEY</a></code> | <code>new_key</code> is not a valid ed25519 public key. |
<a name="@Related_Scripts_40"></a>
Access Control: Only the account having Credential can rotate the info. Credential is granted to either a Parent VASP or a designated dealer [H17].
<pre><code><b>include</b> <a href="DualAttestation.md#0x1_DualAttestation_AbortsIfNoCredential">DualAttestation::AbortsIfNoCredential</a>{addr: <a href="../../../../../../move-stdlib/docs/Signer.md#0x1_Signer_spec_address_of">Signer::spec_address_of</a>(account)}; </code></pre> </details><a name="0x1_AccountAdministrationScripts_rotate_shared_ed25519_public_key"></a>
rotate_shared_ed25519_public_key<a name="@Summary_41"></a>
Rotates the authentication key in a <code><a href="SharedEd25519PublicKey.md#0x1_SharedEd25519PublicKey">SharedEd25519PublicKey</a></code>. This transaction can be sent by any account that has previously published a shared ed25519 public key using <code><a href="AccountAdministrationScripts.md#0x1_AccountAdministrationScripts_publish_shared_ed25519_public_key">AccountAdministrationScripts::publish_shared_ed25519_public_key</a></code>.
<a name="@Technical_Description_42"></a>
<code>public_key</code> must be a valid ed25519 public key. This transaction first rotates the public key stored in <code>account</code>'s <code><a href="SharedEd25519PublicKey.md#0x1_SharedEd25519PublicKey_SharedEd25519PublicKey">SharedEd25519PublicKey::SharedEd25519PublicKey</a></code> resource to <code>public_key</code>, after which it rotates the <code>account</code>'s authentication key to the new authentication key derived from <code>public_key</code> as defined here using the <code><a href="DiemAccount.md#0x1_DiemAccount_KeyRotationCapability">DiemAccount::KeyRotationCapability</a></code> stored in <code>account</code>'s <code><a href="SharedEd25519PublicKey.md#0x1_SharedEd25519PublicKey_SharedEd25519PublicKey">SharedEd25519PublicKey::SharedEd25519PublicKey</a></code>.
<a name="@Parameters_43"></a>
| Name | Type | Description |
|---|---|---|
| <code>account</code> | <code>signer</code> | The signer of the sending account of the transaction. |
| <code>public_key</code> | <code>vector<u8></code> | 32-byte Ed25519 public key. |
<a name="@Common_Abort_Conditions_44"></a>
| Error Category | Error Reason | Description |
|---|---|---|
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_NOT_PUBLISHED">Errors::NOT_PUBLISHED</a></code> | <code><a href="SharedEd25519PublicKey.md#0x1_SharedEd25519PublicKey_ESHARED_KEY">SharedEd25519PublicKey::ESHARED_KEY</a></code> | A <code><a href="SharedEd25519PublicKey.md#0x1_SharedEd25519PublicKey_SharedEd25519PublicKey">SharedEd25519PublicKey::SharedEd25519PublicKey</a></code> resource is not published under <code>account</code>. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a></code> | <code><a href="SharedEd25519PublicKey.md#0x1_SharedEd25519PublicKey_EMALFORMED_PUBLIC_KEY">SharedEd25519PublicKey::EMALFORMED_PUBLIC_KEY</a></code> | <code>public_key</code> is an invalid ed25519 public key. |
<a name="@Related_Scripts_45"></a>
<a name="0x1_AccountAdministrationScripts_create_recovery_address"></a>
create_recovery_address<a name="@Summary_46"></a>
Initializes the sending account as a recovery address that may be used by other accounts belonging to the same VASP as <code>account</code>. The sending account must be a VASP account, and can be either a child or parent VASP account. Multiple recovery addresses can exist for a single VASP, but accounts in each must be disjoint.
<a name="@Technical_Description_47"></a>
Publishes a <code><a href="RecoveryAddress.md#0x1_RecoveryAddress_RecoveryAddress">RecoveryAddress::RecoveryAddress</a></code> resource under <code>account</code>. It then extracts the <code><a href="DiemAccount.md#0x1_DiemAccount_KeyRotationCapability">DiemAccount::KeyRotationCapability</a></code> for <code>account</code> and adds it to the resource. After the successful execution of this transaction other accounts may add their key rotation to this resource so that <code>account</code> may be used as a recovery account for those accounts.
<a name="@Parameters_48"></a>
| Name | Type | Description |
|---|---|---|
| <code>account</code> | <code>signer</code> | The signer of the sending account of the transaction. |
<a name="@Common_Abort_Conditions_49"></a>
| Error Category | Error Reason | Description |
|---|---|---|
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_STATE">Errors::INVALID_STATE</a></code> | <code><a href="DiemAccount.md#0x1_DiemAccount_EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED">DiemAccount::EKEY_ROTATION_CAPABILITY_ALREADY_EXTRACTED</a></code> | <code>account</code> has already delegated/extracted its <code><a href="DiemAccount.md#0x1_DiemAccount_KeyRotationCapability">DiemAccount::KeyRotationCapability</a></code>. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a></code> | <code><a href="RecoveryAddress.md#0x1_RecoveryAddress_ENOT_A_VASP">RecoveryAddress::ENOT_A_VASP</a></code> | <code>account</code> is not a VASP account. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a></code> | <code><a href="RecoveryAddress.md#0x1_RecoveryAddress_EKEY_ROTATION_DEPENDENCY_CYCLE">RecoveryAddress::EKEY_ROTATION_DEPENDENCY_CYCLE</a></code> | A key rotation recovery cycle would be created by adding <code>account</code>'s key rotation capability. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_ALREADY_PUBLISHED">Errors::ALREADY_PUBLISHED</a></code> | <code><a href="RecoveryAddress.md#0x1_RecoveryAddress_ERECOVERY_ADDRESS">RecoveryAddress::ERECOVERY_ADDRESS</a></code> | A <code><a href="RecoveryAddress.md#0x1_RecoveryAddress_RecoveryAddress">RecoveryAddress::RecoveryAddress</a></code> resource has already been published under <code>account</code>. |
<a name="@Related_Scripts_50"></a>
<a name="0x1_AccountAdministrationScripts_create_vasp_domains"></a>
create_vasp_domains<a name="@Summary_51"></a>
Publishes a <code><a href="VASPDomain.md#0x1_VASPDomain_VASPDomains">VASPDomain::VASPDomains</a></code> resource under a parent VASP account. The sending account must be a parent VASP account.
<a name="@Technical_Description_52"></a>
Publishes a <code><a href="VASPDomain.md#0x1_VASPDomain_VASPDomains">VASPDomain::VASPDomains</a></code> resource under <code>account</code>. The The <code><a href="VASPDomain.md#0x1_VASPDomain_VASPDomains">VASPDomain::VASPDomains</a></code> resource's <code>domains</code> field is a vector of VASPDomain, and will be empty on at the end of processing this transaction.
<a name="@Parameters_53"></a>
| Name | Type | Description |
|---|---|---|
| <code>account</code> | <code>signer</code> | The signer of the sending account of the transaction. |
<a name="@Common_Abort_Conditions_54"></a>
| Error Category | Error Reason | Description |
|---|---|---|
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_ALREADY_PUBLISHED">Errors::ALREADY_PUBLISHED</a></code> | <code><a href="VASPDomain.md#0x1_VASPDomain_EVASP_DOMAINS">VASPDomain::EVASP_DOMAINS</a></code> | A <code><a href="VASPDomain.md#0x1_VASPDomain_VASPDomains">VASPDomain::VASPDomains</a></code> resource has already been published under <code>account</code>. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_REQUIRES_ROLE">Errors::REQUIRES_ROLE</a></code> | <code><a href="Roles.md#0x1_Roles_EPARENT_VASP">Roles::EPARENT_VASP</a></code> | The sending <code>account</code> was not a parent VASP account. |
<a name="0x1_AccountAdministrationScripts_opt_in_to_crsn"></a>
opt_in_to_crsn<a name="@Summary_55"></a>
Publishes a CRSN resource under <code>account</code> and opts the account in to concurrent transaction processing. Upon successful execution of this script, all further transactions sent from this account will be ordered and processed according to DIP-168.
<a name="@Technical_Description_56"></a>
This publishes a <code><a href="CRSN.md#0x1_CRSN_CRSN">CRSN::CRSN</a></code> resource under <code>account</code> with <code>crsn_size</code> number of slots. All slots will be initialized to the empty (unused) state, and the CRSN resource's <code>min_nonce</code> field will be set to the transaction's sequence number + 1.
<a name="@Parameters_57"></a>
| Name | Type | Description |
|---|---|---|
| <code>account</code> | <code>signer</code> | The signer of the sending account of the transaction. |
| <code>crsn_size</code> | <code>u64</code> | The the number of slots the published CRSN will have. |
<a name="@Common_Abort_Conditions_58"></a>
| Error Category | Error Reason | Description |
|---|---|---|
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_STATE">Errors::INVALID_STATE</a></code> | <code><a href="CRSN.md#0x1_CRSN_EHAS_CRSN">CRSN::EHAS_CRSN</a></code> | A <code><a href="CRSN.md#0x1_CRSN_CRSN">CRSN::CRSN</a></code> resource was already published under <code>account</code>. |
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_ARGUMENT">Errors::INVALID_ARGUMENT</a></code> | <code><a href="CRSN.md#0x1_CRSN_EZERO_SIZE_CRSN">CRSN::EZERO_SIZE_CRSN</a></code> | The <code>crsn_size</code> was zero. |
<a name="0x1_AccountAdministrationScripts_force_expire"></a>
force_expire<a name="@Summary_59"></a>
Shifts the window held by the CRSN resource published under <code>account</code> by <code>shift_amount</code>. This will expire all unused slots in the CRSN at the time of processing that are less than <code>shift_amount</code>. The exact semantics are defined in DIP-168.
<a name="@Technical_Description_60"></a>
This shifts the slots in the published <code><a href="CRSN.md#0x1_CRSN_CRSN">CRSN::CRSN</a></code> resource under <code>account</code> by <code>shift_amount</code>, and increments the CRSN's <code>min_nonce</code> field by <code>shift_amount</code> as well. After this, it will shift the window over any set bits. It is important to note that the sequence nonce of the sending transaction must still lie within the range of the window in order for this transaction to be processed successfully.
<a name="@Parameters_61"></a>
| Name | Type | Description |
|---|---|---|
| <code>account</code> | <code>signer</code> | The signer of the sending account of the transaction. |
| <code>shift_amount</code> | <code>u64</code> | The amount to shift the window in the CRSN under <code>account</code>. |
<a name="@Common_Abort_Conditions_62"></a>
| Error Category | Error Reason | Description |
|---|---|---|
| <code><a href="../../../../../../move-stdlib/docs/Errors.md#0x1_Errors_INVALID_STATE">Errors::INVALID_STATE</a></code> | <code><a href="CRSN.md#0x1_CRSN_ENO_CRSN">CRSN::ENO_CRSN</a></code> | A <code><a href="CRSN.md#0x1_CRSN_CRSN">CRSN::CRSN</a></code> resource is not published under <code>account</code>. |