Skip to content

Conversation

@bhandras
Copy link
Member

With this change we allow "upserting" an address. This is useful in the case when a tapd user might not know if they've created a specific address already (as there's no easy way to look it up).

@coveralls
Copy link

coveralls commented May 20, 2025

Pull Request Test Coverage Report for Build 15166568904

Details

  • 23 of 23 (100.0%) changed or added relevant lines in 2 files are covered.
  • 39 unchanged lines in 7 files lost coverage.
  • Overall coverage decreased (-0.04%) to 37.126%

Files with Coverage Reduction New Missed Lines %
asset/group_key.go 2 57.89%
asset/asset.go 3 45.46%
asset/mock.go 4 64.71%
tapdb/universe.go 4 80.4%
tapgarden/caretaker.go 4 68.31%
address/address.go 6 67.47%
address/mock.go 16 88.24%
Totals Coverage Status
Change from base Build 15160950886: -0.04%
Covered Lines: 26973
Relevant Lines: 72652

💛 - Coveralls

@guggero guggero self-requested a review May 20, 2025 14:50
Copy link
Contributor

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Nice! One request and a nit, otherwise LGTM.

-- RETURNING id to work on the existing row.
taproot_output_key = excluded.taproot_output_key
WHERE
addrs.version = excluded.version
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, interesting approach.

So this now returns unable to insert addr: sql: no rows in result set if some fields mismatch. Sounds good to me, but I think we should catch that on the RPC server and return a more user friendly error. Otherwise it's hard to understand what's wrong.

Copy link
Member Author

Choose a reason for hiding this comment

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

ptal


// Now change the amount, which upon upsert should trigger an error.
addrs[0].Amount += 1
require.Error(t, addrBook.InsertAddrs(ctx, addrs[0]))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: require.ErrorIs(t, addrBook.InsertAddrs(ctx, addrs[0]), sql.ErrNoRows)?

Copy link
Member Author

Choose a reason for hiding this comment

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

ptal

bhandras added 2 commits May 21, 2025 17:40
With this change we allow "upserting" an address. This is useful in the
case when a tapd user might not know if they've created a specific
address already (as there's no easy way to look it up).
@bhandras bhandras requested a review from guggero May 21, 2025 15:41
Copy link
Contributor

@guggero guggero left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM 🎉

@bhandras bhandras changed the title tapdb: allow reinsertion of an existing address the the book tapdb: allow reinsertion of an existing address to the book May 21, 2025
@ffranr ffranr added this pull request to the merge queue May 22, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 22, 2025
@guggero guggero merged commit 99df66f into lightninglabs:main May 22, 2025
18 checks passed
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.

4 participants