Use PendingTransactionEntity.internalAccount for shielding.

This commit is contained in:
Kris Nuttycombe 2022-10-18 10:17:07 -06:00
parent f5d7aa0f17
commit 36932a21dd
3 changed files with 6 additions and 12 deletions

View File

@ -492,13 +492,7 @@ public class SDKSynchronizer: Synchronizer {
throw ShieldFundsError.insuficientTransparentFunds throw ShieldFundsError.insuficientTransparentFunds
} }
// FIXME: Define who's the recipient of a shielding transaction #521 let shieldingSpend = try transactionManager.initSpend(zatoshi: tBalance.verified, recipient: .internalAccount(spendingKey.account), memo: try memo.asMemoBytes(), from: accountIndex)
// https://github.com/zcash/ZcashLightClientKit/issues/521
guard let uAddr = self.getUnifiedAddress(accountIndex: accountIndex) else {
throw ShieldFundsError.shieldingFailed(underlyingError: KeyEncodingError.invalidEncoding)
}
let shieldingSpend = try transactionManager.initSpend(zatoshi: tBalance.verified, recipient: .unified(uAddr), memo: try memo.asMemoBytes(), from: accountIndex)
// TODO: Task will be removed when this method is changed to async, issue 487, https://github.com/zcash/ZcashLightClientKit/issues/487 // TODO: Task will be removed when this method is changed to async, issue 487, https://github.com/zcash/ZcashLightClientKit/issues/487
let transaction = try await transactionManager.encodeShieldingTransaction( let transaction = try await transactionManager.encodeShieldingTransaction(
@ -521,7 +515,7 @@ public class SDKSynchronizer: Synchronizer {
do { do {
let spend = try transactionManager.initSpend( let spend = try transactionManager.initSpend(
zatoshi: zatoshi, zatoshi: zatoshi,
recipient: recipient, recipient: .address(recipient),
memo: memo.asMemoBytes(), memo: memo.asMemoBytes(),
from: Int(spendingKey.account) from: Int(spendingKey.account)
) )

View File

@ -8,7 +8,7 @@
import Foundation import Foundation
enum TransactionManagerError: Error { enum TransactionManagerError: Error {
case couldNotCreateSpend(recipient: Recipient, account: Int, zatoshi: Zatoshi) case couldNotCreateSpend(recipient: PendingTransactionRecipient, account: Int, zatoshi: Zatoshi)
case encodingFailed(PendingTransactionEntity) case encodingFailed(PendingTransactionEntity)
case updateFailed(PendingTransactionEntity) case updateFailed(PendingTransactionEntity)
case notPending(PendingTransactionEntity) case notPending(PendingTransactionEntity)
@ -41,7 +41,7 @@ class PersistentTransactionManager: OutboundTransactionManager {
func initSpend( func initSpend(
zatoshi: Zatoshi, zatoshi: Zatoshi,
recipient: Recipient, recipient: PendingTransactionRecipient,
memo: MemoBytes, memo: MemoBytes,
from accountIndex: Int from accountIndex: Int
) throws -> PendingTransactionEntity { ) throws -> PendingTransactionEntity {
@ -49,7 +49,7 @@ class PersistentTransactionManager: OutboundTransactionManager {
by: try repository.create( by: try repository.create(
PendingTransaction( PendingTransaction(
value: zatoshi, value: zatoshi,
recipient: .address(recipient), recipient: recipient,
memo: memo, memo: memo,
account: accountIndex account: accountIndex
) )

View File

@ -16,7 +16,7 @@ transactions through to completion.
protocol OutboundTransactionManager { protocol OutboundTransactionManager {
func initSpend( func initSpend(
zatoshi: Zatoshi, zatoshi: Zatoshi,
recipient: Recipient, recipient: PendingTransactionRecipient,
memo: MemoBytes, memo: MemoBytes,
from accountIndex: Int from accountIndex: Int
) throws -> PendingTransactionEntity ) throws -> PendingTransactionEntity