private static async Task <SubmitTransactionResponse> SendAllowKinTrustOperation(KeyPair account, AccountResponse accountResponse) { ChangeTrustOperation.Builder changeTrustOperationBuilder = new ChangeTrustOperation.Builder((AssetTypeCreditAlphaNum)KinAsset, TRUST_NO_LIMIT_VALUE).SetSourceAccount(account); ChangeTrustOperation changeTrustOperation = changeTrustOperationBuilder.Build(); Transaction.Builder allowKinTrustTransaction = new Transaction.Builder(new Account(account, accountResponse.SequenceNumber)).AddOperation(changeTrustOperation); Transaction transaction = allowKinTrustTransaction.Build(); transaction.Sign(account); return(await Server.SubmitTransaction(transaction).ConfigureAwait(false)); }
public Transaction Build() { foreach (Operation operation in _operations) { _transactionBuilder.AddOperation(operation); } Transaction transaction = _transactionBuilder.Build(); transaction.Sign(_baseKeyPair); if (_channelKeyPair != null) { transaction.Sign(_channelKeyPair); } return(transaction); }
public Transaction BuildTransaction() { var source = KeyPair.FromSecretSeed("SCH27VUZZ6UAKB67BDNF6FA42YMBMQCBKXWGMFD5TZ6S5ZZCZFLRXKHS"); var destination = KeyPair.FromAccountId("GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR"); var account = new Account(source, 2908908335136768L); var builder = new Transaction.Builder(account) .AddOperation(new CreateAccountOperation.Builder(destination, "2000").Build()) .AddMemo(Memo.Text("Hello world!")); Assert.AreEqual(1, builder.OperationsCount); var transaction = builder.Build(); Assert.AreEqual(2908908335136769L, transaction.SequenceNumber); Assert.AreEqual(2908908335136769L, account.SequenceNumber); transaction.Sign(source); return(transaction); }
static async Task <Transaction> BuildTransaction(KeyPair keyPair, double amount, string appendedMemo = "") { amount = amount / 100; var destinationKeyPair = KeyPair.FromAccountId("GDL6CWJER7TOXIWMFTOLVUZU4GKT547OCTNPOTXISJGI4SSOPEQTC3HT"); PaymentOperation.Builder paymentOperationBuilder = new PaymentOperation.Builder(destinationKeyPair, _asset, amount.ToString(CultureInfo.InvariantCulture)) .SetSourceAccount(keyPair); PaymentOperation paymentOperation = paymentOperationBuilder.Build(); var accountResponse = await _server.Accounts.Account(keyPair); Transaction.Builder paymentTransaction = new Transaction.Builder(new Account(keyPair, accountResponse.SequenceNumber)).AddOperation(paymentOperation); paymentTransaction.AddMemo(new MemoText($"1-rced-{appendedMemo}")); var transaction = paymentTransaction.Build(); transaction.Sign(keyPair); return(transaction); }
private async Task <SubmitTransactionResponse> GetCreateAccountTransaction(string destinationAddress) { KeyPair destinationKeyPair = KeyPair.FromAccountId(destinationAddress); AccountResponse sourceAccount = null; AccountResponse destinationAccount = null; try { sourceAccount = await GetAccount(_keyPair).ConfigureAwait(false); destinationAccount = await GetAccount(destinationKeyPair).ConfigureAwait(false); } catch (Exception ex) {} if (sourceAccount == null) { throw new Exception("Source account doesn't exists"); } if (destinationAccount != null) { throw new Exception("Account already exists"); } CreateAccountOperation.Builder createAccountOperationBuilder = new CreateAccountOperation.Builder(destinationKeyPair, "0"); createAccountOperationBuilder.SetSourceAccount(_keyPair); Transaction.Builder transactionBuilder = new Transaction.Builder(new Account(_keyPair, sourceAccount.SequenceNumber)); transactionBuilder.AddOperation(createAccountOperationBuilder.Build()); transactionBuilder.AddMemo(new MemoText($"1-{_app_id}")); Transaction transaction = transactionBuilder.Build(); transaction.Sign(_keyPair); return(await _server.SubmitTransaction(transaction).ConfigureAwait(false)); }
private async Task <SubmitTransactionResponse> SendPaymentOperation(KeyPair sourceKeyPair, KeyPair destinationKeyPair, AccountResponse sourceAccount, double amount, string marketPlaceOrderId = null) { PaymentOperation.Builder paymentOperationBuilder = new PaymentOperation.Builder(destinationKeyPair, _kinAsset, amount.ToString(CultureInfo.InvariantCulture)) .SetSourceAccount(sourceKeyPair); PaymentOperation paymentOperation = paymentOperationBuilder.Build(); Transaction.Builder paymentTransaction = new Transaction.Builder(new Account(sourceKeyPair, sourceAccount.SequenceNumber)).AddOperation( paymentOperation); string toAppend = string.IsNullOrEmpty(marketPlaceOrderId) ? "p2p" : marketPlaceOrderId; paymentTransaction.AddMemo(new MemoText($"1-test-{toAppend}")); Transaction transaction = paymentTransaction.Build(); transaction.Sign(sourceKeyPair); return(await _server.SubmitTransaction(transaction).ConfigureAwait(false)); }