/// <summary> /// Internal implementation for Multi Account Transfer Crypto. /// Returns either a receipt or record or throws an exception. /// </summary> private async Task <TResult> TransferImplementationAsync <TResult>(Dictionary <Account, long> sendAccounts, Dictionary <Address, long> receiveAddresses, Action <IContext>?configure) where TResult : new() { var transferList = RequireInputParameter.MultiTransfers(sendAccounts, receiveAddresses); var context = CreateChildContext(configure); RequireInContext.Gateway(context); var payers = sendAccounts.Keys.ToArray <ISigner>().Append(RequireInContext.Payer(context)).ToArray(); var transfers = Transactions.CreateCryptoTransferList(transferList); var transactionId = Transactions.GetOrCreateTransactionID(context); var transactionBody = Transactions.CreateCryptoTransferTransactionBody(context, transfers, transactionId, "Transfer Crypto"); var request = Transactions.SignTransaction(transactionBody, payers); var precheck = await Transactions.ExecuteRequestWithRetryAsync(context, request, getRequestMethod, getResponseCode); ValidateResult.PreCheck(transactionId, precheck.NodeTransactionPrecheckCode); var receipt = await GetReceiptAsync(context, transactionId); if (receipt.Status != ResponseCodeEnum.Success) { throw new TransactionException($"Unable to execute crypto transfer, status: {receipt.Status}", Protobuf.FromTransactionId(transactionId), (ResponseCode)receipt.Status); } var result = new TResult(); if (result is TransferRecord rec) { var record = await GetTransactionRecordAsync(context, transactionId); Protobuf.FillRecordProperties(record, rec); rec.Transfers = Protobuf.FromTransferList(record.TransferList); } else if (result is TransactionReceipt rcpt) { Protobuf.FillReceiptProperties(transactionId, receipt, rcpt); } return(result);