8

With the importaddress RPC command it is possible to import one watch-only address. But how can I do that with, let's say, 100?

2 Answers 2

7

There is an alternate command importmulti to be used as follows:

bitcoin-cli importmulti '[
{
  "scriptPubKey" : { "address": "mxbvcPj7cnbxPP6oqpHJxxNb4xC8QoLquG" },
  "timestamp" : 0,
  "label" : "mxbvcPj7cnbxPP6oqpHJxxNb4xC8QoLquG"
},
{
  "scriptPubKey" : { "address": "n1iNb8XafoJTrCBBcGSSEZ6YNd6EWYo8PU" },
  "timestamp" : 0,
  "label" : "n1iNb8XafoJTrCBBcGSSEZ6YNd6EWYo8PU"
},
{
  "scriptPubKey" : { "address": "mgLs7quWwYBJa7jkZyebAec7RNXQtwaerK" },
  "timestamp" : 0,
  "label" : "mgLs7quWwYBJa7jkZyebAec7RNXQtwaerK"
}]' '{"rescan":false}'

Response is as follows:

[
  {
    "success": true
  }, 
  {
    "success": true
  }, 
  {
    "success": true
  }
]
1
  • 1
    No need for the labels. Dec 6, 2017 at 22:07
4

The RPC interface doesn't generally provide any "batch mode" functionality. If you want to import 100 addresses, call importaddress 100 times. You might like to write a short script with a loop in some other language.

You should set the rescan parameter to false for all but the last address, so that you don't trigger rescanning 100 times.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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