Skip to content

Conversation

@jvsena42
Copy link
Member

@jvsena42 jvsena42 commented Aug 25, 2025

Closes #322

Description

Currently, the app only tries to attach pending tags when the event is received, so it may fail if the activity takes to long to be added.
This implementation syncs the pending tags on every activity sync

  • Check pending tags every time the balance changes
  • Fix receive onChain flow
    • Save the on-chain address and transaction direction in the tags MetaData
    • Migrations
    • on balance changes, check for pending on-chain receive tags

Preview

onchain-receive.mp4
onchain-send.mp4
ln-receive.mp4
ln-send.mp4

QA Notes

Tests

  • OnChain

    • Add tags before sending -> send -> check if tags were attached in activity details
    • Create an invoice -> add tags -> receive -> check if tags were attached in activity details
  • Lightning

    • Add tags before sending -> send -> check if tags were attached in activity details
    • Create an invoice -> add tags -> receive -> check if tags were attached in activity details

@jvsena42 jvsena42 self-assigned this Aug 25, 2025
@jvsena42 jvsena42 marked this pull request as draft August 25, 2025 13:05
@jvsena42 jvsena42 marked this pull request as ready for review August 27, 2025 14:17
@jvsena42 jvsena42 requested a review from ovitrif September 1, 2025 09:39
Base automatically changed from fix/get-detail-by-tx-id to master September 1, 2025 15:24
@jvsena42 jvsena42 enabled auto-merge September 1, 2025 15:25
Copy link
Collaborator

@ovitrif ovitrif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

Added a few remarks but nothing blocking.

Tested

  • the 2 onchain test cases 🟢

return@withContext Result.failure(e)
}
updateActivitiesMetadata()
syncTagsMetaData()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: MetaData caps NOK, should be Metadata

if (db.tagMetadataDao().getAll().isEmpty()) return@withContext
val lastActivities = getActivities(limit = 10u).getOrNull() ?: return@withContext
Logger.debug("syncTagsMetaData called")
lastActivities.forEach { activity ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Computation inside forEach block should be parallelized later, when optimising for performance.

): Result<Unit> = withContext(bgDispatcher) {
return@withContext runCatching {

if (tags.isEmpty()) throw InvalidParameterException("tags must not be empty")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InvalidParameterException is not intended for such uses, apparently.
Should be replaced by IllegalArgumentException

Copy link
Member Author

@jvsena42 jvsena42 Sep 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intended to implement IllegalArgumentException. It was probably the autocomplemente, thanks!

@jvsena42 jvsena42 merged commit 6d971a7 into master Sep 1, 2025
2 checks passed
@jvsena42 jvsena42 deleted the fix/tag-syncing branch September 1, 2025 15:46
@jvsena42 jvsena42 mentioned this pull request Sep 2, 2025
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tag set upfront on the receive BTC invoice is not displayed on incoming transaction

3 participants