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

Address list #681

Closed
darosior opened this issue Sep 1, 2023 · 13 comments
Closed

Address list #681

darosior opened this issue Sep 1, 2023 · 13 comments
Labels
Daemon / Liana library This is about lianad or the liana library (not the GUI) Feature New feature or functionality.

Comments

@darosior
Copy link
Member

darosior commented Sep 1, 2023

It's useful to be able to verify a deposit address generated by your cosigner when using a multisig.

@darosior darosior added GUI gui related Feature New feature or functionality. labels Sep 1, 2023
@darosior
Copy link
Member Author

darosior commented Sep 9, 2023

While the OP was assuming we'd derive it directly from the descriptor, it could also be implemented as an RPC. Adding the daemon label.

@darosior darosior added the Daemon / Liana library This is about lianad or the liana library (not the GUI) label Sep 9, 2023
@pythcoiner
Copy link
Collaborator

I'm interested in working on this, what about an rpc method getaddresses that returns something like:

{
  "result": {
    "addresses": [
      {"index": 0, "receive": "bc1....", "change": "bc1..."},
      {"index": 1, "receive": "bc1....", "change": "bc1..."},
      {"index": 2, "receive": "bc1....", "change": "bc1..."},
      {"index": 3, "receive": "bc1....", "change": "bc1..."}
    ]
  }
}

@darosior
Copy link
Member Author

darosior commented Sep 9, 2023

I guess the complexity stems from deciding what addresses to return. Should we give a range? A number of addresses past the last one used? A number of addresses preceding the last one used?
I think a safe bet that could both be used from the command line or by the GUI would be to take two (mandatory) parameters:

  • The start_index, the index at which to start the listing
  • The count, how many addresses to include in the list

The JSON you suggest to be returned makes sense to me. Let's call the command listaddresses though. That would be:

listaddresses start_index count
{
  "result": {
    "addresses": [
      {"index": start_index + 0, "receive": "bc1....", "change": "bc1..."},
      {"index": start_index + 1, "receive": "bc1....", "change": "bc1..."},
      {"index": start_index + 2, "receive": "bc1....", "change": "bc1..."},
      {"index": start_index + 3, "receive": "bc1....", "change": "bc1..."}
    ]
  }
}

What do you think?


Besides i think it could be useful to return the derivation index in the result of getnewaddress.

@pythcoiner
Copy link
Collaborator

pythcoiner commented Sep 9, 2023

looks good to me

what about if user just want to get all generated addresses, he just passes startindex=0 and count=0, then we replace count=<actual_db_index> ?

@darosior
Copy link
Member Author

darosior commented Sep 9, 2023

Hmm it's more complicated to accomodate a usecase related to the addresses which have already been generated. Hence my suggestion above to add the derivation index to getnewaddress.

Also i'm not sure it makes a lot of sense. What usecase do you have in mind? This is just an ever-growing list which could be pretty bulky to return at once.

One possibility would be to make the two arguments, with default value 0 for start_index and default value max(last_change_index, last_receive_index) - start_index for count. Seems a bit intricate to sanitize but hey could be done if that's of any use.

@pythcoiner
Copy link
Collaborator

Usecase i have in mind is to display all addresses generated in the same way it's done in Sparrow wallet.

what i don't like with the mandatory value of count is we need to know that value but we don't have method to only get it, we can call getnewaddress but it will also increment index...

One possibility would be to make the two arguments, with default value 0 for start_index and default value max(last_change_index, last_receive_index) - start_index for count. Seems a bit intricate to sanitize but hey could be done if that's of any use.

agree with these default values

if we want to avoid huge amount of addresses to be returned by a rpc call, we can maybe define a max for count (100?), then the user can loop requesting until the returned length < 100?

@darosior
Copy link
Member Author

darosior commented Sep 9, 2023 via email

@pythcoiner
Copy link
Collaborator

The daemon have a track of indexes, but something external running only a lianad service and connecting it through rpc cannot retrieve these indexes, should we also implement a getaddressesindexes method?

@darosior
Copy link
Member Author

darosior commented Sep 9, 2023 via email

@pythcoiner
Copy link
Collaborator

What's wrong with my suggested command and default values from above? ------- Original Message -------

On Saturday, September 9th, 2023 at 5:23 PM, pythcoiner @.> wrote: The daemon have a track of indexes, but something external running only a lianad service and connecting it through rpc cannot retrieve these indexes, should we also implement a getaddressesindexes method? — Reply to this email directly, [view it on GitHub](#681 (comment)), or unsubscribe. You are receiving this because you authored the thread.Message ID: @.>

nothing wrong, just in case you prefer to stick to initial idea of mandatory count without default ;)

@pythcoiner
Copy link
Collaborator

I have no idea what Sparrow does, would be interested to learn more about the usecase for listing all addresses that have ever been generated is.

it just display a table of all adresses from index 0 to (max_index_received +20), allowing you to check:

  • if still a coin to this adress
  • if never received a coin
  • if have been reused (display history)
  • let you add/edit label

@pythcoiner pythcoiner mentioned this issue Sep 9, 2023
2 tasks
@pythcoiner
Copy link
Collaborator

Besides i think it could be useful to return the derivation index in the result of getnewaddress.

should I implement this in #709 or in a separated PR?

darosior added a commit that referenced this issue Nov 11, 2023
2660b77 implement listadresses (pythcoiner)

Pull request description:

  address #681

  todo:
  - [x]  implement tests
  - [x] update docs

  edit: i'm really new to rust, don't hesitate to kick my ass when i write stupid code

ACKs for top commit:
  darosior:
    ACK 2660b77 -- my requests are addressed in followup #808.

Tree-SHA512: a5fdfb4516dc0379bfec1be535e752795dec75d28cbc5b9fa4fe9898fa00b1cfaa9cee3b95f4dfd68365f4585426e1b4457a8366cc4f783600704994f879526f
@darosior
Copy link
Member Author

Now it was implemented on the daemon side, i'm going to close this in favour of #809 for the GUI integration.

@darosior darosior removed the GUI gui related label Nov 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Daemon / Liana library This is about lianad or the liana library (not the GUI) Feature New feature or functionality.
Projects
None yet
Development

No branches or pull requests

2 participants