|
@@ -200,8 +200,18 @@ use syn::parse_macro_input;
|
|
|
/// </td>
|
|
|
/// <td>
|
|
|
/// Exact same functionality as the <code>init</code> constraint but only runs if the account does not exist yet.<br>
|
|
|
-/// If it does exist, it still checks whether the given init constraints are correct,
|
|
|
-/// e.g. that the account has the expected amount of space and, if it's a PDA, the correct seeds etc.
|
|
|
+/// If the account does exist, it still checks whether the given init constraints are correct,
|
|
|
+/// e.g. that the account has the expected amount of space and, if it's a PDA, the correct seeds etc.<br><br>
|
|
|
+/// This feature should be used with care and is therefore behind a feature flag.
|
|
|
+/// You can enable it by importing <code>anchor-lang</code> with the <code>init-if-needed</code> cargo feature.<br>
|
|
|
+/// When using <code>init_if_needed</code>, you need to make sure you properly protect yourself
|
|
|
+/// against re-initialization attacks. You need to include checks in your code that check
|
|
|
+/// that the initialized account cannot be reset to its initial settings after the first time it was
|
|
|
+/// initialized (unless that it what you want).<br>
|
|
|
+/// Because of the possibility of re-initialization attacks and the general guideline that instructions
|
|
|
+/// should avoid having multiple execution flows (which is important so they remain easy to understand),
|
|
|
+/// consider breaking up your instruction into two instructions - one for initializing and one for using
|
|
|
+/// the account - unless you have a good reason not to do so.
|
|
|
/// <br><br>
|
|
|
/// Example:
|
|
|
/// <pre>
|