Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show tlv records in transaction popup #365

Merged
merged 23 commits into from
Aug 9, 2024
Merged

Conversation

im-adithya
Copy link
Member

@im-adithya im-adithya commented Jul 29, 2024

Fixes #31
Fixes #372
Adds custom record info in the transaction popup

Screenshot

Screenshot 2024-07-29 at 8 47 18 PM

@im-adithya im-adithya requested a review from rolznz July 29, 2024 15:20
@bumi
Copy link
Contributor

bumi commented Jul 30, 2024

I am not sure how the data processing works there. can we get that message on the transaction list? where we have the "description" ? cc @rolznz

@im-adithya
Copy link
Member Author

Yes we can, but we have to discuss on the priority order
For example boostagram > keysend message > description

frontend/src/types.ts Outdated Show resolved Hide resolved
@rolznz
Copy link
Contributor

rolznz commented Jul 30, 2024

Yes we can, but we have to discuss on the priority order
For example boostagram > keysend message > description

Sounds good (and the description would be empty in this case I think anyway)

@bumi
Copy link
Contributor

bumi commented Jul 30, 2024

but we would need to persist that data in the DB. we should not on the fly always decode those keysends.

that's why we have the DB. prepare the data as our app needs it.

@bumi bumi requested a review from rolznz August 2, 2024 15:32
@rolznz
Copy link
Contributor

rolznz commented Aug 2, 2024

@bumi @im-adithya I think we should go with Bumi's recommendation, right?

@im-adithya would you like to propose the changes you would make? or how should we proceed here?

@im-adithya
Copy link
Member Author

im-adithya commented Aug 6, 2024

TODOs

  • Fix/Add tests
  • Store proper description (boostagram > keysend message > description) in db

api/models.go Outdated Show resolved Hide resolved
frontend/src/types.ts Outdated Show resolved Hide resolved
frontend/src/types.ts Outdated Show resolved Hide resolved
@@ -607,14 +620,19 @@ func (svc *transactionsService) ConsumeEvent(ctx context.Context, event *events.

if result.RowsAffected == 0 {
// Note: brand new payments cannot be associated with an app
var metadata string
var metadataBytes []byte
Copy link
Contributor

Choose a reason for hiding this comment

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

I actually don't think we should do this on nwc_payment_sent because we already save the metadata when we initiate the payment

Copy link
Member Author

Choose a reason for hiding this comment

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

Not that important but what if payments happen outside (they don't have metadata since it is a payment, atleast in LND but still I thought it was good to have if we are anyways adding metadata)

Also we should DRY up the "brand new" lnClient.Transaction processing because it is almost the same in both sent/received

Copy link
Contributor

Choose a reason for hiding this comment

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

I decided to remove it for now - we need to confirm if we want to add this support and if so, also import transactions from LND (all this is a lot of extra work and code to do properly)

@rolznz rolznz added this to the v1.5.0 milestone Aug 7, 2024
@im-adithya im-adithya requested review from bumi and rolznz August 8, 2024 09:16
@rolznz
Copy link
Contributor

rolznz commented Aug 9, 2024

Example queries:

SELECT *
FROM transactions
WHERE EXISTS (
    SELECT 1
    FROM json_each(metadata, '$.tlv_records') AS records
    WHERE json_extract(records.value, '$.type') = 7629169
);
SELECT *
FROM transactions
WHERE json_extract(boostagram, '$.value_msat') > 1000;

@rolznz
Copy link
Contributor

rolznz commented Aug 9, 2024

Roland's tests (WIP):

  • migration with transactions with both metadata and no metadata
  • query of metadata from migrated transactions
  • query of metadata from new transactions
  • querying boostagrams
  • send boostagram
  • receive boostagram
  • view boostagram info - sent
  • view boostagram info - receive
  • NIP-47 lookup invoice / list transactions / notifications returns correct content

api/models.go Outdated Show resolved Hide resolved
api/transactions.go Outdated Show resolved Hide resolved
frontend/src/types.ts Outdated Show resolved Hide resolved
api/transactions.go Outdated Show resolved Hide resolved
Name string `json:"name"`
Podcast string `json:"podcast"`
URL string `json:"url"`
Episode string `json:"episode,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

@im-adithya why do some have omitempty others not? is it required?

Copy link
Member Author

Choose a reason for hiding this comment

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

I took this from LBE repo here, whereever we have ?: in the Boostagram type there, I've omitted

Copy link
Contributor

Choose a reason for hiding this comment

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

but it looks completely arbitrary and doesn't seem to follow the spec - https://github.com/lightning/blips/blob/master/blip-0010.md#fields

Copy link
Contributor

@rolznz rolznz left a comment

Choose a reason for hiding this comment

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

tACK

@rolznz rolznz merged commit 67ca173 into master Aug 9, 2024
8 checks passed
@rolznz rolznz deleted the task-tlv-records branch August 9, 2024 15:30
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.

Change transactions table metadata column to JSON type instead of string Improve transaction lists
3 participants