zcash-android-wallet-zcon1/zcash-android-wallet-app/app/src/main/java/cash/z/android/wallet/data/WalletTransactionEncoder.kt

16 lines
614 B
Kotlin

package cash.z.android.wallet.data
import cash.z.wallet.sdk.data.TransactionRepository
import cash.z.wallet.sdk.secure.Wallet
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.withContext
class WalletTransactionEncoder(
private val wallet: Wallet,
private val repository: TransactionRepository
) : RawTransactionEncoder {
override suspend fun create(zatoshi: Long, toAddress: String, memo: String): ByteArray = withContext(IO) {
val transactionId = wallet.createRawSendTransaction(zatoshi, toAddress, memo)
repository.findTransactionById(transactionId)?.raw!!
}
}