1What "decompose" means
Someone hands you a vault encoding, a funding txid, or a script hex, and you want to answer three questions: who owns it, who manages it, and is either key in my wallet? No single command is called decompose. You use validateaddress, getrawtransaction and decodescript, all of which exist on IronDivi and Divi Core with the same arguments. Everything on this page is read-only.
2Split the encoding into its two addresses
The encoding is owner:manager. Everything before the colon is the owner address, everything after is the manager address. No tool is needed:
y8PL1RQSCWYPnJAvhvs6ZwkxfwuB5Ut5Aj:yF5g4mEraodvfjdRE5VrWum9pSF9gMdssc
owner = y8PL1RQSCWYPnJAvhvs6ZwkxfwuB5Ut5Aj
manager = yF5g4mEraodvfjdRE5VrWum9pSF9gMdssc
3Find out which half your wallet holds
validateaddress says whether the address is valid on this network and whether its private key is in this wallet (ismine). Run it on each half.
IronDivi
irondivi-cli --testnet validateaddress y8PL1RQSCWYPnJAvhvs6ZwkxfwuB5Ut5Aj
divi-cli
divi-cli -testnet validateaddress y8PL1RQSCWYPnJAvhvs6ZwkxfwuB5Ut5Aj
{
"isvalid" : true,
"address" : "y8PL1RQSCWYPnJAvhvs6ZwkxfwuB5Ut5Aj",
"scriptPubKey" : "76a9147d1a719db27730a9d2a65a6035ced8090db15cd988ac",
"ismine" : true,
"iswatchonly" : false,
"isscript" : false,
"pubkey" : "03a9e6…6e7f",
"iscompressed" : true,
"account" : "vaultowner",
"hdkeypath" : "m/44'/1'/0'/0/16"
}
Divi Desktop debug console
validateaddress y8PL1RQSCWYPnJAvhvs6ZwkxfwuB5Ut5Aj
"ismine": true on the owner half means you can reclaim. "ismine": true on the manager half means this wallet can stake it once addvault has been run. Both false means you can only watch. Note the 20-byte hash inside scriptPubKey (7d1a…5cd9): it reappears in the vault script in step 5.
4Read the vault output from the funding transaction
With a txid, ask the node for the decoded transaction (the trailing 1 means "decode"). This works on any node, even one without the keys; a pruned node may not have old transactions, in which case use the explorer in step 6.
divi-cli -testnet getrawtransaction 4fdd0defe9560a7d8cb9444be9a7dd839ef962d18703a5825a2021c05d9c1645 1
… "vout" : [
{ "value" : 4899.99997490, "n" : 0, "scriptPubKey" : { "type" : "pubkeyhash", "addresses" : [ "y6GmT2wFG2XeNzEMvDdiY5zwYoNsV63QfP" ] } },
{ "value" : 100.00000000, "n" : 1,
"scriptPubKey" : {
"asm" : "OP_IF 7d1a719db27730a9d2a65a6035ced8090db15cd9 OP_ELSE OP_REQUIRE_COINSTAKE c68c948af03b0e2a1443a22da33e35293ee87da1 OP_ENDIF OP_OVER OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG",
"hex" : "63147d1a719db27730a9d2a65a6035ced8090db15cd967b914c68c948af03b0e2a1443a22da33e35293ee87da16878a988ac",
"type" : "vault",
"addresses" : [ "y8PL1RQSCWYPnJAvhvs6ZwkxfwuB5Ut5Aj", "yF5g4mEraodvfjdRE5VrWum9pSF9gMdssc" ]
},
"spentTxId" : "2dea1206cdf3c82156f72a3f92cca80b0baa0d274d6f8ef06c9fadaef10ef72f" } ] …
The output with "type": "vault" is the vault. Its addresses list is always owner first, manager second, so this is the encoding again. If a spentTxId is present, as here, the output has already been spent (reclaimed, debited, or staked) and that txid tells you where it went.
IronDivi's output has the same fields with slightly different ordering: irondivi-cli --testnet getrawtransaction <txid> 1.
5Decode the script itself
If all you have is the script hex (from an explorer or a raw transaction), decodescript turns it back into the two addresses:
divi-cli -testnet decodescript 63147d1a719db27730a9d2a65a6035ced8090db15cd967b914c68c948af03b0e2a1443a22da33e35293ee87da16878a988ac
{
"asm" : "OP_IF 7d1a719db27730a9d2a65a6035ced8090db15cd9 OP_ELSE OP_REQUIRE_COINSTAKE c68c948af03b0e2a1443a22da33e35293ee87da1 OP_ENDIF OP_OVER OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG",
"reqSigs" : 1,
"type" : "vault",
"addresses" : [ "y8PL1RQSCWYPnJAvhvs6ZwkxfwuB5Ut5Aj", "yF5g4mEraodvfjdRE5VrWum9pSF9gMdssc" ],
"p2sh" : "8eZtFiwyMg8MZZsYEfTCAVide6G6GpgHUg"
}
Reading the hex by hand, for the curious:
| Bytes | Meaning |
|---|---|
| 63 | OP_IF |
| 14 7d1a…5cd9 | push 20 bytes: the owner's key hash (matches the owner's scriptPubKey in step 3) |
| 67 | OP_ELSE |
| b9 | OP_REQUIRE_COINSTAKE (Divi-specific: this branch is only valid inside a staking transaction) |
| 14 c68c…7da1 | push 20 bytes: the manager's key hash |
| 68 | OP_ENDIF |
| 78 a9 88 ac | OP_OVER OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG: prove you hold the chosen key |
Ignore the p2sh line: it is the address this script would have if wrapped in pay-to-script-hash, which vaults do not use.
6Do it in the explorer
Explorer 2.0 decodes vault outputs for you. Open the funding transaction ↗ and look at output 1: it is labelled as a vault with both addresses. The older chainz explorer (mainnet only ↗) shows the raw script without the vault label.
Trouble
| You see | Means | Do |
|---|---|---|
"isvalid": false | Not an address on this network, or a typo | Check testnet (x/y) vs mainnet (D) |
No information available about transaction | Your node has not indexed or no longer has that transaction | Use the explorer, or a node with txindex=1 |
Output type is pubkeyhash, not vault | That output is the change, not the vault | Look at the other outputs |
Still stuck? Ask the Divi chatbot.