<p>As @arubi's answer said, first I must decode the witness script (which I originally got from <code>addmultisigaddress</code>) to get the accompanying redeem script:</p>

<pre><code>bitcoin-cli -testnet -decodescript "5221029f531503facdac2496f50a446d9bd29846a06a04a45e3845b656bb471df422fc2102e30787703a990e4015a2cb9071fcfd1c7d4641fb294e4b4c3f5f6b450a1925132102da28088a8022651171c4f13429b98709dabe13bc6da526537fdd2d0730dd2dbb2103286c96ecaa850a6ba43cc45fbb539c1fb1d65c23cc0f3cd09fcf9765826ff9de54ae"
</code></pre>

<p>Get the redeemscript from the JSON <code>results["segwit"]["hex"]</code>, then provide both scripts to <code>importmulti</code>:</p>

<pre><code>bitcoin-cli -testnet importmulti \
    '[
      {
        "scriptPubKey": { "address": "2MzqiaZzpLT2SSBfsFqqo3FpZsP8g6WTvyC" },
        "timestamp":1545413762,
        "redeemscript":"0020dabea3445c14e4a08d6705db4373bef467d4c64e7c8ddf149be50670de6878ae",
        "witnessscript":"5221029f531503facdac2496f50a446d9bd29846a06a04a45e3845b656bb471df422fc2102e30787703a990e4015a2cb9071fcfd1c7d4641fb294e4b4c3f5f6b450a1925132102da28088a8022651171c4f13429b98709dabe13bc6da526537fdd2d0730dd2dbb2103286c96ecaa850a6ba43cc45fbb539c1fb1d65c23cc0f3cd09fcf9765826ff9de54ae",
        "watchonly":true
      }
    ]'
</code></pre>

<p>This works in Bitcoin Core v0.18. Importing this kind of address as watch-only was not officially supported in earlier versions.</p>

CC BY-SA 4.0
2019-05-04T06:23:18.760Z
2019-05-04T06:23:18.760Z
Bitcoin Hodler
<p>The issue here is that you've provided the <code>p2wsh</code> redeemscript as the script for the <code>p2sh</code> level of the nesting.  The redeemscript for the <code>p2sh</code> address is </p>

<pre><code>0020dabea3445c14e4a08d6705db4373bef467d4c64e7c8ddf149be50670de6878ae
</code></pre>

<p>This can be seen by running</p>

<pre><code>bitcoin-cli -testnet decodescript 5221029f531503facdac2496f50a446d9bd29846a06a04a45e3845b656bb471df422fc2102e30787703a990e4015a2cb9071fcfd1c7d4641fb294e4b4c3f5f6b450a1925132102da28088a8022651171c4f13429b98709dabe13bc6da526537fdd2d0730dd2dbb2103286c96ecaa850a6ba43cc45fbb539c1fb1d65c23cc0f3cd09fcf9765826ff9de54ae
</code></pre>

<p>With it, you can import the <code>p2sh-p2wsh</code> by setting the redeemscript for each level of the nesting :</p>

<pre><code>$ bitcoin-cli -testnet importmulti '[{ "scriptPubKey": { "address": "2MzqiaZzpLT2SSBfsFqqo3FpZsP8g6WTvyC" }, "timestamp":"now", "redeemscript":"0020DABEA3445C14E4A08D6705DB4373BEF467D4C64E7C8DDF149BE50670DE6878AE", "label":"Glacier 2012-12-21" }, {"scriptPubKey": { "address": "2MzqiaZzpLT2SSBfsFqqo3FpZsP8g6WTvyC" }, "redeemscript": "5221029f531503facdac2496f50a446d9bd29846a06a04a45e3845b656bb471df422fc2102e30787703a990e4015a2cb9071fcfd1c7d4641fb294e4b4c3f5f6b450a1925132102da28088a8022651171c4f13429b98709dabe13bc6da526537fdd2d0730dd2dbb2103286c96ecaa850a6ba43cc45fbb539c1fb1d65c23cc0f3cd09fcf9765826ff9de54ae", "label":"Glacier 2012-12-21", "timestamp":"now"}]'
[
  {
    "success": true
  },
  {
    "success": true
  }
]
</code></pre>

<p>Then you'll see the expected result from <code>getaddressinfo</code> :</p>

<pre><code>bitcoin-cli -testnet getaddressinfo 2MzqiaZzpLT2SSBfsFqqo3FpZsP8g6WTvyC
{
  "address": "2MzqiaZzpLT2SSBfsFqqo3FpZsP8g6WTvyC",
  "scriptPubKey": "a914534ee3ce21b8f805128f76b9d977e351bbbea20d87",
  "ismine": false,
  "iswatchonly": true,
  "isscript": true,
  "iswitness": false,
  "script": "witness_v0_scripthash",
  "hex": "0020dabea3445c14e4a08d6705db4373bef467d4c64e7c8ddf149be50670de6878ae",
  "embedded": {
    "isscript": true,
    "iswitness": true,
    "witness_version": 0,
    "witness_program": "dabea3445c14e4a08d6705db4373bef467d4c64e7c8ddf149be50670de6878ae",
    "script": "multisig",
    "hex": "5221029f531503facdac2496f50a446d9bd29846a06a04a45e3845b656bb471df422fc2102e30787703a990e4015a2cb9071fcfd1c7d4641fb294e4b4c3f5f6b450a1925132102da28088a8022651171c4f13429b98709dabe13bc6da526537fdd2d0730dd2dbb2103286c96ecaa850a6ba43cc45fbb539c1fb1d65c23cc0f3cd09fcf9765826ff9de54ae",
    "sigsrequired": 2,
    "pubkeys": [
      "029f531503facdac2496f50a446d9bd29846a06a04a45e3845b656bb471df422fc",
      "02e30787703a990e4015a2cb9071fcfd1c7d4641fb294e4b4c3f5f6b450a192513",
      "02da28088a8022651171c4f13429b98709dabe13bc6da526537fdd2d0730dd2dbb",
      "03286c96ecaa850a6ba43cc45fbb539c1fb1d65c23cc0f3cd09fcf9765826ff9de"
    ],
    "address": "tb1qm2l2x3zuznj2prt8qhd5xua773naf3jw0jxa79ymu5r8phng0zhqrkkueu",
    "scriptPubKey": "0020dabea3445c14e4a08d6705db4373bef467d4c64e7c8ddf149be50670de6878ae"
  },
  "label": "Glacier 2012-12-21",
  "timestamp": 1296688602,
  "labels": [
    {
      "name": "Glacier 2012-12-21",
      "purpose": "receive"
    }
  ]
}
</code></pre>

<p>Note, <code>ismine</code> is never true for scripts\addresses for which you can't sign completely on your own.</p>

CC BY-SA 4.0
2018-12-22T23:43:50.503Z
This worked, but sure is ugly. I had the same problem with signrawtransaction at first, but they fixed it: https://github.com/bitcoin/bitcoin/issues/12418
Bitcoin Hodler
CC BY-SA 4.0
2019-02-12T20:31:50.587Z
Apparently this behavior is considered a bug by the core developers: https://github.com/bitcoin/bitcoin/issues/15392  There is no supported way to import this kind of address into Bitcoin Core v0.17.1. This will change in v0.18 and I'll come back here to add a new answer at that time.
Bitcoin Hodler
CC BY-SA 4.0
2019-02-13T21:16:51.683Z
@BitcoinHodler Interesting.  Thanks for the followup.
arubi
CC BY-SA 4.0
2018-12-22T06:50:07.603Z
2018-12-22T06:50:07.603Z
arubi
<p>I've created a p2wsh-in-p2sh multisig address using an offline node. I have the address and redeem script, as provided by <code>bitcoin-cli addmultisigaddress</code> on the offline node. How do I import this as a watch-only address on an online node, so I can use the online node to <a href="https://bitcoin.stackexchange.com/questions/83070/expected-use-model-for-psbt">create transactions</a>?</p>

<p>I have tried the following:</p>

<pre><code>$ bitcoin-cli -testnet -rpcwallet=glacier importmulti '[{ "scriptPubKey": { "address": "2MzqiaZzpLT2SSBfsFqqo3FpZsP8g6WTvyC" }, "timestamp":"now", "redeemscript":"5221029f531503facdac2496f50a446d9bd29846a06a04a45e3845b656bb471df422fc2102e30787703a990e4015a2cb9071fcfd1c7d4641fb294e4b4c3f5f6b450a1925132102da28088a8022651171c4f13429b98709dabe13bc6da526537fdd2d0730dd2dbb2103286c96ecaa850a6ba43cc45fbb539c1fb1d65c23cc0f3cd09fcf9765826ff9de54ae", "watchonly":true, "label":"Glacier 2012-12-21" }]'
[
  {
    "success": true
  }
]
</code></pre>

<p>That seemed to work, but <code>getaddressinfo</code> doesn't look correct:</p>

<pre><code>$ bitcoin-cli -testnet -rpcwallet=glacier getaddressinfo "2MzqiaZzpLT2SSBfsFqqo3FpZsP8g6WTvyC"
{
    "address": "2MzqiaZzpLT2SSBfsFqqo3FpZsP8g6WTvyC",
    "scriptPubKey": "a914534ee3ce21b8f805128f76b9d977e351bbbea20d87",
    "ismine": false,
    "iswatchonly": false,
    "isscript": true,
    "iswitness": false,
    "label": "Glacier 2012-12-21",
    "labels": [
       {
           "name": "Glacier 2012-12-21",
           "purpose": "receive"
       }
    ]
}
</code></pre>

<p>Shouldn't <code>ismine</code> and <code>iswatchonly</code> be true, and more details appear, such as <code>hex</code> and <code>script</code>?</p>

<p>Note that the <code>glacier</code> wallet was created with <code>disable_private_keys=true</code>. I'm running Bitcoin Core v0.17.0.1.</p>

CC BY-SA 4.0
2018-12-22T03:46:25.740Z
I had a similar problem with p2sh-segwit before, and I wonder if this is a similar kind of issue: https://github.com/bitcoin/bitcoin/issues/12418
Bitcoin Hodler
<bitcoin-core>
How to import p2wsh-in-p2sh multisig as watch-only?
Bitcoin Hodler
# How to import p2wsh-in-p2sh multisig as watch-only?

(Asked by: username_0 on 2018-12-22)

I've created a p2wsh-in-p2sh multisig address using an offline node. I have the address and redeem script, as provided by bitcoin-cli addmultisigaddress on the offline node. How do I import this as a watch-only address on an online node, so I can use the online node to create transactions?
I have tried the following:
$ bitcoin-cli -testnet -rpcwallet=glacier importmulti '[{ "scriptPubKey": { "address": "2MzqiaZzpLT2SSBfsFqqo3FpZsP8g6WTvyC" }, "timestamp":"now", "redeemscript":"5221029f531503facdac2496f50a446d9bd29846a06a04a45e3845b656bb471df422fc2102e30787703a990e4015a2cb9071fcfd1c7d4641fb294e4b4c3f5f6b450a1925132102da28088a8022651171c4f13429b98709dabe13bc6da526537fdd2d0730dd2dbb2103286c96ecaa850a6ba43cc45fbb539c1fb1d65c23cc0f3cd09fcf9765826ff9de54ae", "watchonly":true, "label":"Glacier 2012-12-21" }]'
[
  {
    "success": true
  }
]

That seemed to work, but getaddressinfo doesn't look correct:
$ bitcoin-cli -testnet -rpcwallet=glacier getaddressinfo "2MzqiaZzpLT2SSBfsFqqo3FpZsP8g6WTvyC"
{
    "address": "2MzqiaZzpLT2SSBfsFqqo3FpZsP8g6WTvyC",
    "scriptPubKey": "a914534ee3ce21b8f805128f76b9d977e351bbbea20d87",
    "ismine": false,
    "iswatchonly": false,
    "isscript": true,
    "iswitness": false,
    "label": "Glacier 2012-12-21",
    "labels": [
       {
           "name": "Glacier 2012-12-21",
           "purpose": "receive"
       }
    ]
}

Shouldn't ismine and iswatchonly be true, and more details appear, such as hex and script?
Note that the glacier wallet was created with disable_private_keys=true. I'm running Bitcoin Core v0.17.0.1.

**Tags:** bitcoin-core

> **Comments:**
> **username_0**: I had a similar problem with p2sh-segwit before, and I wonder if this is a similar kind of issue: https://github.com/bitcoin/bitcoin/issues/12418  

---

## 2 answers

### Answer by username_0 on 2019-05-04. Score: 0 | Accepted answer

As @username_1's answer said, first I must decode the witness script (which I originally got from addmultisigaddress) to get the accompanying redeem script:
bitcoin-cli -testnet -decodescript "5221029f531503facdac2496f50a446d9bd29846a06a04a45e3845b656bb471df422fc2102e30787703a990e4015a2cb9071fcfd1c7d4641fb294e4b4c3f5f6b450a1925132102da28088a8022651171c4f13429b98709dabe13bc6da526537fdd2d0730dd2dbb2103286c96ecaa850a6ba43cc45fbb539c1fb1d65c23cc0f3cd09fcf9765826ff9de54ae"

Get the redeemscript from the JSON results["segwit"]["hex"], then provide both scripts to importmulti:
bitcoin-cli -testnet importmulti \
    '[
      {
        "scriptPubKey": { "address": "2MzqiaZzpLT2SSBfsFqqo3FpZsP8g6WTvyC" },
        "timestamp":1545413762,
        "redeemscript":"0020dabea3445c14e4a08d6705db4373bef467d4c64e7c8ddf149be50670de6878ae",
        "witnessscript":"5221029f531503facdac2496f50a446d9bd29846a06a04a45e3845b656bb471df422fc2102e30787703a990e4015a2cb9071fcfd1c7d4641fb294e4b4c3f5f6b450a1925132102da28088a8022651171c4f13429b98709dabe13bc6da526537fdd2d0730dd2dbb2103286c96ecaa850a6ba43cc45fbb539c1fb1d65c23cc0f3cd09fcf9765826ff9de54ae",
        "watchonly":true
      }
    ]'

This works in Bitcoin Core v0.18. Importing this kind of address as watch-only was not officially supported in earlier versions.


---

### Answer by username_1 on 2018-12-22. Score: 2

The issue here is that you've provided the p2wsh redeemscript as the script for the p2sh level of the nesting.  The redeemscript for the p2sh address is 
0020dabea3445c14e4a08d6705db4373bef467d4c64e7c8ddf149be50670de6878ae

This can be seen by running
bitcoin-cli -testnet decodescript 5221029f531503facdac2496f50a446d9bd29846a06a04a45e3845b656bb471df422fc2102e30787703a990e4015a2cb9071fcfd1c7d4641fb294e4b4c3f5f6b450a1925132102da28088a8022651171c4f13429b98709dabe13bc6da526537fdd2d0730dd2dbb2103286c96ecaa850a6ba43cc45fbb539c1fb1d65c23cc0f3cd09fcf9765826ff9de54ae

With it, you can import the p2sh-p2wsh by setting the redeemscript for each level of the nesting :
$ bitcoin-cli -testnet importmulti '[{ "scriptPubKey": { "address": "2MzqiaZzpLT2SSBfsFqqo3FpZsP8g6WTvyC" }, "timestamp":"now", "redeemscript":"0020DABEA3445C14E4A08D6705DB4373BEF467D4C64E7C8DDF149BE50670DE6878AE", "label":"Glacier 2012-12-21" }, {"scriptPubKey": { "address": "2MzqiaZzpLT2SSBfsFqqo3FpZsP8g6WTvyC" }, "redeemscript": "5221029f531503facdac2496f50a446d9bd29846a06a04a45e3845b656bb471df422fc2102e30787703a990e4015a2cb9071fcfd1c7d4641fb294e4b4c3f5f6b450a1925132102da28088a8022651171c4f13429b98709dabe13bc6da526537fdd2d0730dd2dbb2103286c96ecaa850a6ba43cc45fbb539c1fb1d65c23cc0f3cd09fcf9765826ff9de54ae", "label":"Glacier 2012-12-21", "timestamp":"now"}]'
[
  {
    "success": true
  },
  {
    "success": true
  }
]

Then you'll see the expected result from getaddressinfo :
bitcoin-cli -testnet getaddressinfo 2MzqiaZzpLT2SSBfsFqqo3FpZsP8g6WTvyC
{
  "address": "2MzqiaZzpLT2SSBfsFqqo3FpZsP8g6WTvyC",
  "scriptPubKey": "a914534ee3ce21b8f805128f76b9d977e351bbbea20d87",
  "ismine": false,
  "iswatchonly": true,
  "isscript": true,
  "iswitness": false,
  "script": "witness_v0_scripthash",
  "hex": "0020dabea3445c14e4a08d6705db4373bef467d4c64e7c8ddf149be50670de6878ae",
  "embedded": {
    "isscript": true,
    "iswitness": true,
    "witness_version": 0,
    "witness_program": "dabea3445c14e4a08d6705db4373bef467d4c64e7c8ddf149be50670de6878ae",
    "script": "multisig",
    "hex": "5221029f531503facdac2496f50a446d9bd29846a06a04a45e3845b656bb471df422fc2102e30787703a990e4015a2cb9071fcfd1c7d4641fb294e4b4c3f5f6b450a1925132102da28088a8022651171c4f13429b98709dabe13bc6da526537fdd2d0730dd2dbb2103286c96ecaa850a6ba43cc45fbb539c1fb1d65c23cc0f3cd09fcf9765826ff9de54ae",
    "sigsrequired": 2,
    "pubkeys": [
      "029f531503facdac2496f50a446d9bd29846a06a04a45e3845b656bb471df422fc",
      "02e30787703a990e4015a2cb9071fcfd1c7d4641fb294e4b4c3f5f6b450a192513",
      "02da28088a8022651171c4f13429b98709dabe13bc6da526537fdd2d0730dd2dbb",
      "03286c96ecaa850a6ba43cc45fbb539c1fb1d65c23cc0f3cd09fcf9765826ff9de"
    ],
    "address": "tb1qm2l2x3zuznj2prt8qhd5xua773naf3jw0jxa79ymu5r8phng0zhqrkkueu",
    "scriptPubKey": "0020dabea3445c14e4a08d6705db4373bef467d4c64e7c8ddf149be50670de6878ae"
  },
  "label": "Glacier 2012-12-21",
  "timestamp": 1296688602,
  "labels": [
    {
      "name": "Glacier 2012-12-21",
      "purpose": "receive"
    }
  ]
}

Note, ismine is never true for scripts\addresses for which you can't sign completely on your own.

> **Comments:**
> **username_0**: This worked, but sure is ugly. I had the same problem with signrawtransaction at first, but they fixed it: https://github.com/bitcoin/bitcoin/issues/12418  
> **username_0**: Apparently this behavior is considered a bug by the core developers: https://github.com/bitcoin/bitcoin/issues/15392  There is no supported way to import this kind of address into Bitcoin Core v0.17.1. This will change in v0.18 and I'll come back here to add a new answer at that time.  
> **username_1**: @BitcoinHodler Interesting.  Thanks for the followup.  

---

