diff --git a/core/api/src/debug/settle-pending-onchain-payments.ts b/core/api/src/debug/settle-pending-onchain-payments.ts index 2035076435..28c8cbfb73 100644 --- a/core/api/src/debug/settle-pending-onchain-payments.ts +++ b/core/api/src/debug/settle-pending-onchain-payments.ts @@ -21,7 +21,7 @@ const processPayment = async (payment: LedgerTransaction) => { if (payout instanceof Error) { return new Error(`Failed to get payout: ${payout.name} - ${payout.message}`) } - if (!payout.batchId || !payout.txId || !payout.vout) { + if (!payout.batchId || !payout.txId || payout.vout === undefined) { return new Error("Missing required payout details") } diff --git a/core/api/src/services/bria/index.ts b/core/api/src/services/bria/index.ts index 129e2e9f60..7e061e4d45 100644 --- a/core/api/src/services/bria/index.ts +++ b/core/api/src/services/bria/index.ts @@ -235,13 +235,15 @@ export const OnChainService = (): IOnChainService => { const foundPayout = response.getPayout() if (foundPayout === undefined) return new PayoutNotFoundError() + //fix issue with proto gen default values + const txId = (foundPayout.getTxId() as OnChainTxHash) || undefined return { id: foundPayout.getId() as PayoutId, journalId: foundPayout.getExternalId() as LedgerJournalId, batchInclusionEstimatedAt: foundPayout.getBatchInclusionEstimatedAt(), batchId: foundPayout.getBatchId() as BatchId, - txId: foundPayout.getTxId() as OnChainTxHash, - vout: foundPayout.getVout() as OnChainTxVout, + txId, + vout: txId ? (foundPayout.getVout() as OnChainTxVout) : undefined, } } catch (err) { if ( diff --git a/core/api/src/services/ledger/index.ts b/core/api/src/services/ledger/index.ts index cf91b46f0f..5361d52852 100644 --- a/core/api/src/services/ledger/index.ts +++ b/core/api/src/services/ledger/index.ts @@ -497,10 +497,21 @@ export const LedgerService = (): ILedgerService => { | AsyncGenerator> | LedgerServiceError { try { + const bankOwnerWalletId = await caching.getBankOwnerWalletId() + const dealerUsdWalletId = await caching.getDealerUsdWalletId() + const dealerBtcWalletId = await caching.getDealerBtcWalletId() + + const excludedAccounts = [ + toLiabilitiesWalletId(bankOwnerWalletId), + toLiabilitiesWalletId(dealerUsdWalletId), + toLiabilitiesWalletId(dealerBtcWalletId), + ] + const transactions = Transaction.find({ type: LedgerTransactionType.OnchainPayment, pending: true, account_path: liabilitiesMainAccount, + accounts: { $nin: excludedAccounts }, }).cursor({ batchSize: 100 }) for await (const tx of transactions) {