4

My question is: I want to use ImportMulti to import a long list of watch-only addresses. However, unlike ImportAddress, I don't see any way to place these addresses into specific "accounts". Is this even possible?

UPDATE: After more research, it seems to me that the concept of "label" is basically the same thing as "account". Is this correct? Seems kind of confusing to me. If this is the case, then ImportMulti can work as I want, by using the "label" property.

| improve this question | | | | |
4

After doing some RPC function call tests with ImportMulti and ImportAddress, I feel confident answering my own question.

By way of example, suppose I want to import a watch-only address "1CxZZZREDACTEDYYYYREDACTEDxyzabcD1":

Using "ImportAddress":

bitcoin-cli importaddress  1CxZZZREDACTEDYYYYREDACTEDxyzabcD1 "Account XYZ" true

Using "ImportMulti":

bitcoin-cli importmulti '
  [
    {
      "scriptPubKey" : { "address": "1CxZZZREDACTEDYYYYREDACTEDxyzabcD1" },
      "timestamp" : 1510387200,
      "label" : "Account XYZ"
    }        
  ]' '{ "rescan": true }'

Lessons Learned:

Label vs Account: The "account" parameter in ImportAddress has the same effect as the "label" property in ImportMulti. They both just label the bitcoin address with friendly text (in my case, "Account XYZ").

Rescan and timestamp: If you set "rescan" to true in ImportAddress, then it will rescan the entire blockchain from the beginning. However, if you set "rescan" to true using ImportMulti, then it will only rescan as far back as the earliest "timestamp" value in your list of JSON-encoded address objects. Note that I used the following Linux command to generate my timestamp value of 1510387200:

$ date -d "Nov 11 2017" +%s
$ 1510387200

Summary:

You can use ImportMulti to perform the same operation as ImportAddress, knowing that in ImportMulti, the "label" property of each Import object means the same thing as the "account" parameter in ImportAddress. Further, ImportMulti is more powerful because you can specify each address's creation timestamp, which results in a much faster "rescan".

If anything I wrote here is wrong, please correct me.

| improve this answer | | | | |
  • 1
    Looks all correct to me. – Pieter Wuille Nov 19 '17 at 19:04
0

If you are using the getTime() method in Date objects in Javascript, this generates a timestamp that is the number of MILLISECONDS not SECONDS from the Unix Epoch. So for importmulti call to work, strip the last 3 numbers of the timestamp generated in Javascript, otherwise bitcoind will think is a future date and it will replace this timestamp with "now" which will only rescan 10 to 13 blocks from the current best blockchain height.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.