Fix bug where mempool submission errors were being ignored

This commit is contained in:
Jack Grigg 2024-02-19 20:45:49 +00:00 committed by Honza
parent 41bb83cb5e
commit 04f1f47957
2 changed files with 17 additions and 3 deletions

View File

@ -6,6 +6,11 @@ and this library adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Fixed
- `Synchronizer.sendToAddress` and `Synchronizer.shieldFunds` now throw an
exception if the created transaction successfully reaches `lightwalletd` but
fails to reach its backing full node's mempool.
### Changed
- `WalletBalance` now contains new fields `changePending` and `valuePending`. Fields `total` and `pending` are
still provided. See more in the class documentation

View File

@ -1,6 +1,7 @@
package cash.z.ecc.android.sdk.internal.transaction
import cash.z.ecc.android.sdk.internal.Twig
import cash.z.ecc.android.sdk.internal.ext.toHexReversed
import cash.z.ecc.android.sdk.internal.model.EncodedTransaction
import cash.z.ecc.android.sdk.model.Account
import cash.z.ecc.android.sdk.model.TransactionRecipient
@ -43,13 +44,21 @@ internal class OutboundTransactionManagerImpl(
override suspend fun submit(encodedTransaction: EncodedTransaction): Boolean {
return when (val response = service.submitTransaction(encodedTransaction.raw.byteArray)) {
is Response.Success -> {
Twig.debug { "SUCCESS: submit transaction completed with response: ${response.result}" }
true
if (response.result.code == 0) {
Twig.debug { "SUCCESS: submit transaction completed" }
true
} else {
Twig.debug {
"FAILURE! submit transaction ${encodedTransaction.txId.byteArray.toHexReversed()} " +
"completed with response: ${response.result.code}: ${response.result.message}"
}
false
}
}
is Response.Failure -> {
Twig.debug {
"FAILURE! submit transaction completed with response: ${response.code}: ${
"FAILURE! submit transaction failed with gRPC response: ${response.code}: ${
response.description
}"
}