This will be mostly possible in the upcoming Bitcoin Core 0.18 release.
First you need to understand that the sequence of such paired multisig addresses (with public keys generated from 2 xpubs in lockstep) can be described in the new descriptor language.
The syntax is sh(multi(2,XPUB/*,XPUB/*))
. The sh
indicates P2SH embedding, multi
refers to multisig, the 2
means 2 signatures are required, and the two XPUB arguments are what the public keys are drawn from.
As descriptors are intended to be safe for human communication, they need a checksum in some cases. This checksum can be computed using the getdescriptorinfo
RPC command, which will append a #CHECKSUM
suffix.
Once you have the descriptor, you can do multiple things with it. One is determining the corresponding addresses using deriveaddresses
.
bitcoin-cli deriveaddresses "DESC" [0,1000]
Will give you the first 1001 addresses (using keys with indexed 0 through 1000) for your descriptor.
You can also import them into a wallet, all at once using the flexible importmulti
RPC, which in 0.18 is extended to support descriptors.
bitcoin-cli importmulti [{"desc" : "DESC", "range" : [0, 1000], "watchonly" : true, "timestamp" : "now"}]
Will import the first 1000 addresses, together will all information necessary to recognize payments to them, and sign for spending them (excluding the private keys, of course).
- The
watchonly
indicates you’re aware private keys are missing, but want to import as watched anyway. - The
timestamp
indicates the first time these keys may have been used."now"
means you know the keys haven’t been used yet (or you don’t care about their history); alternatively you can give a timestamp as the number of seconds since UNIX epoch to specify a birth time.
Note that this will not automatically watch for more than the first 1000 addresses as they get consumed – you’ll need a new import command for that (for now).