/// <summary> Refund bitshares deposit. </summary> /// /// <remarks> Paul, 15/01/2015. </remarks> /// /// <param name="fromAccount"> from account. </param> /// <param name="deposit"> The deposit. </param> /// <param name="depositId"> Identifier for the deposit. </param> /// <param name="memo"> The memo. </param> protected virtual void RefundBitsharesDeposit(string fromAccount, ulong larimers, string depositId, string memo) { // make sure failures after this point don't result in multiple refunds MarkTransactionAsRefundedStart(depositId); BitsharesTransactionResponse response; decimal amount = m_asset.GetAmountFromLarimers(larimers); try { BitsharesAccount account = GetAccountFromLedger(fromAccount); response = m_bitshares.WalletTransfer(amount, m_asset.symbol, m_bitsharesAccount, fromAccount, memo); } catch (BitsharesRpcException) { BitsharesTransaction t = m_bitshares.BlockchainGetTransaction(depositId); // get the sender's address from the balance id BitsharesOperation op = t.trx.operations.First(o => o.type == BitsharesTransactionOp.withdraw_op_type); BitsharesBalanceRecord balance = m_bitshares.GetBalance(op.data.balance_id); string senderAddress = balance.condition.data.owner; response = m_bitshares.WalletTransferToAddress(amount, m_asset.symbol, m_bitsharesAccount, senderAddress, memo); } MarkTransactionAsRefundedEnd(depositId, response.record_id, amount, DaemonTransactionType.bitsharesRefund, memo); }
/// <summary> Sends bitAssets, either issue or transfer them </summary> /// /// <remarks> Paul, 18/03/2015. </remarks> /// /// <param name="amount"> The amount. </param> /// <param name="asset"> The asset. </param> /// <param name="sendTo"> to account. </param> /// /// <returns> A BitsharesTransactionResponse. </returns> protected BitsharesTransactionResponse SendBitAssets(decimal amount, BitsharesAsset asset, string sendTo, string memo = "", bool allowIssue = true) { BitsharesAccount account = m_bitshares.WalletGetAccount(m_bitsharesAccount); if (asset.issuer_id == account.id && allowIssue) { // issue it return(m_bitshares.WalletUiaIssue(amount, asset.symbol, sendTo, memo)); } else { // transfer it return(m_bitshares.WalletTransfer(amount, asset.symbol, m_bitsharesAccount, sendTo, memo)); } }