Skip to content

[5/?] StaticAddr: Deposit summary RPC #721

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

Merged
merged 3 commits into from
Jun 24, 2024

Conversation

hieblmi
Copy link
Collaborator

@hieblmi hieblmi commented Mar 19, 2024

This PR introduces an api to query static address related info like unconfirmed/confirmed deposits, loop-ins, summaries.

Sample output:

{
    "static_address": "bcrt1p0wgm20fyeh5aalpv2gm0thgy3wf0f05fsq0w4npvkunnyu9tkg5sduhzh0",
    "total_num_deposits": 3,
    "value_unconfirmed": "9999999",
    "value_deposited": "9999999",
    "value_expired": "0",
    "value_withdrawn": "9999999",
    "filtered_deposits": [
        {
            "id": "c1e51a42ad431d1d6c3123e3eb42512294b36d0959cb639fe4a7d5ce080d62f6",
            "state": "DEPOSITED",
            "outpoint": "afeacda95937f3a10a85efb6182125beff8dc3d14bd5c389d25384cc4418fe10:0",
            "value": "9999999",
            "confirmation_height": "120"
        },
        {
            "id": "c62da3abd89124db632fe3f39369a5341cc6e6d9d4ef94388ca76e7e3288ba44",
            "state": "WITHDRAWING",
            "outpoint": "939da29e0e4131019190b98a5b778ecd9fb8b620cd7e2999b3ef80d07fef7298:0",
            "value": "9999999",
            "confirmation_height": "120"
        },
        {
            "id": "59aefc7fe123616b2342cdb3e69ce67cf1fa087fa51029e3e92adbf35cfc153c",
            "state": "WITHDRAWN",
            "outpoint": "8e8679f925a656bc0f2762ee5af17ea109bbac99b0763f57184217f47541d899:0",
            "value": "9999999",
            "confirmation_height": "120"
        }
    ]
}

@hieblmi hieblmi self-assigned this Mar 19, 2024
@hieblmi hieblmi changed the base branch from master to static-addr-staging March 19, 2024 00:07
@hieblmi hieblmi marked this pull request as draft March 19, 2024 00:08
@hieblmi hieblmi force-pushed the static-addr-5 branch 5 times, most recently from 802f510 to de23774 Compare March 20, 2024 04:14
@hieblmi hieblmi changed the title [5/?] StaticAddr: Static address info and stats [5/?] StaticAddr: Deposit summary RPC Mar 21, 2024
@hieblmi hieblmi force-pushed the static-addr-5 branch 4 times, most recently from 2b1aa55 to 6672a00 Compare March 22, 2024 01:04
@hieblmi hieblmi force-pushed the static-addr-5 branch 3 times, most recently from 0065101 to 4629a74 Compare April 16, 2024 14:38
@hieblmi hieblmi force-pushed the static-addr-5 branch 3 times, most recently from 7750c43 to 2b9c71f Compare April 24, 2024 08:56
@hieblmi hieblmi force-pushed the static-addr-5 branch 9 times, most recently from 2d83df6 to b3f8669 Compare April 26, 2024 14:18
@hieblmi hieblmi force-pushed the static-addr-5 branch 3 times, most recently from 872c6ff to 0245989 Compare June 5, 2024 11:48
@hieblmi hieblmi marked this pull request as ready for review June 5, 2024 11:50
@hieblmi hieblmi requested review from bhandras, starius and sputn1ck June 5, 2024 12:06
@hieblmi hieblmi force-pushed the static-addr-5 branch 5 times, most recently from d5ac415 to c660129 Compare June 6, 2024 10:02
@hieblmi hieblmi force-pushed the static-addr-staging branch from 385f3ea to 17618f2 Compare June 6, 2024 11:48
}
return false
}
clientDeposits = filter(deposits, f)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I guess we could also filter in the DB but since this is running on the client its not a performance concern. Other thoughts?

@hieblmi hieblmi mentioned this pull request Jun 6, 2024
@lightninglabs-deploy
Copy link

@bhandras: review reminder
@starius: review reminder
@sputn1ck: review reminder

@hieblmi hieblmi force-pushed the static-addr-staging branch 2 times, most recently from 6f9539b to add5263 Compare June 20, 2024 08:18
Copy link
Member

@bhandras bhandras left a comment

Choose a reason for hiding this comment

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

LGTM 💯

func filter(deposits []*deposit.Deposit, f filterFunc) []*clientrpc.Deposit {
var clientDeposits []*clientrpc.Deposit
for _, d := range deposits {
if f(d) {
Copy link
Member

Choose a reason for hiding this comment

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

style+nit: if !f(d) { continue }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

var summaryCommand = cli.Command{
Name: "summary",
ShortName: "s",
Usage: "Display a summary of static address related data.",
Copy link
Member

Choose a reason for hiding this comment

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

nit: i'd suggest using "information" instead of "data"

Copy link
Member

@sputn1ck sputn1ck left a comment

Choose a reason for hiding this comment

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

LGTM!

@hieblmi hieblmi force-pushed the static-addr-staging branch from add5263 to 48cc041 Compare June 24, 2024 17:00
@hieblmi hieblmi merged commit b3b9176 into lightninglabs:static-addr-staging Jun 24, 2024
4 checks passed
@hieblmi hieblmi deleted the static-addr-5 branch June 24, 2024 17:09
@hieblmi hieblmi mentioned this pull request Jun 28, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants