/// <summary> /// Creates a new wallet. /// </summary> /// <remarks> /// <para>Each created wallet is given a name which is then subsequently used to open it /// with the <see cref="OpenWalletAsync(string, string, string)"/> or delete it using the /// <see cref="DeleteWalletAsync(string, string)"/> static methods. /// <note type="note">Wallet names must be unique within a pool.</note> /// </para> /// <para> /// When creating a new Wallet the <paramref name="type"/> parameter can be null or "default" to /// use the default wallet implementation, or a type name specified in an earlier call to the /// <see cref="RegisterWalletTypeAsync(string, WalletType)"/> method to use a custom wallet implementation. /// Attempting to use a wallet type that hasn't previously been registered will result in an error. /// </para> /// <para>The <paramref name="config"/> parameter allows configuration values to be passed to the wallet /// when it is created. When using the default wallet this value can be null to use the default /// wallet configuration or a JSON string with the following format can be used: /// <code> /// { /// "freshness_time": int /// } /// </code> /// The value of the <c>freshness_time</c> key is an integer representing the number of seconds /// a value in the wallet will remain valid before expiring. If not specified the default value /// for <c>freshness_time</c> is 24 * 60 seconds. /// </para> /// <para>If using a custom wallet type the content of the <paramref name="config"/> parameter can /// be any string value; it is up to the custom wallet type implementer to interpret the value. /// </para> /// <para>The <paramref name="credentials"/> parameter is unused in the default wallet at present, /// however the value can be used by custom wallet implementations; it is up to the custom wallet /// type implementer to interpret the value.</para> /// </remarks> /// <param name="poolName">The name of the pool the wallet is associated with.</param> /// <param name="name">The name of the wallet.</param> /// <param name="type">The type of the wallet. </param> /// <param name="config">The wallet configuration JSON.</param> /// <param name="credentials">The wallet credentials JSON or null to use the default credentials.</param> /// <returns>An asynchronous <see cref="Task"/> with no return value the completes when the operation has finished.</returns> public static Task CreateWalletAsync(string poolName, string name, string type, string config, string credentials) { var taskCompletionSource = new TaskCompletionSource <bool>(); var commandHandle = PendingCommands.Add(taskCompletionSource); var result = IndyNativeMethods.indy_create_wallet( commandHandle, poolName, name, type, config, credentials, CallbackHelper.TaskCompletingNoValueCallback); CallbackHelper.CheckResult(result); return(taskCompletionSource.Task); }