Source: docs/lotus-v2/guides/treasury-multisig.md

Treasury multisig: creating keys and spending

On this page

Status: implemented on the local branch wallet/native-spend, which is not published. It has been tested on regtest only. This guide is for the owner and the treasury signers. It covers creating the signing keys on your own machines, building the treasury address, and spending from it.

What the treasury address is

Lotus has no CHECKMULTISIG opcode. A native m-of-n address uses the wallet convention xpimulti/1:

The convention allows at most 16 keys and 12,870 leaves. For a 2-of-3 or 3-of-5 treasury the count is tiny (3 or 10 leaves).

The signer set is fixed when the transaction is created. The chosen leaf is part of the TxID. Before you create a spend, decide which m signers will sign it, and pass their x-only keys as native_signers. If you leave them out, the wallet uses the m lowest keys.

1. Each signer creates a key (on their own machine)

Do this on a machine you control. Use the treasury branch build of lotusd, fully synced to the chain the treasury will live on.

lotus-cli createwallet "treasury-signer" false false "<strong passphrase>"
lotus-cli -rpcwallet=treasury-signer getnewaddress "treasury key" native
lotus-cli -rpcwallet=treasury-signer getaddressinfo <that address>

The address is only used to obtain a key. The treasury receives at the multisig address from step 2, never at this one.

Keep only the pubkey field (66 hex characters, starting 02 or 03). The public key is safe to send to the coordinator. Never send the private key, the wallet file or the passphrase to anyone.

Back up the signer wallet right away and keep the backup offline:

lotus-cli -rpcwallet=treasury-signer backupwallet /path/to/offline/treasury-signer.bak

The backup is encrypted with the passphrase. Store the passphrase separately from the backup. Losing more than n - m signer keys loses the treasury.

2. Build the treasury address (every signer checks it)

Anyone can run this. It needs no wallet and no private keys:

lotus-cli createmultisig 2 '["<pubkey1>","<pubkey2>","<pubkey3>"]' native

It returns:

Every signer must run createmultisig independently with the three public keys, and confirm they get the same address. A coordinator who substitutes a key can redirect the funds. Compare the keys over a second channel, for example by reading the first and last 8 hex characters aloud.

3. Watch-only treasury wallet (coordinator)

The coordinator keeps a wallet with no private keys. It tracks the balance and creates spends:

lotus-cli -named createwallet wallet_name=treasury-watch \
    disable_private_keys=true blank=true descriptors=true
lotus-cli -rpcwallet=treasury-watch importdescriptors \
    '[{"desc":"<descriptor from step 2>","timestamp":"now"}]'
lotus-cli -rpcwallet=treasury-watch getaddressinfo <treasury address>

getaddressinfo should show iswatchonly: true, solvable: true, threshold: 2 and the three xonly_keys. If funds arrived before the import, use a timestamp from before the first payment, or run rescanblockchain.

4. Spending

  1. The coordinator creates the PSBT, naming the signers:
   lotus-cli -rpcwallet=treasury-watch walletcreatefundedpsbt '[]' \
       '[{"<recipient xpi address>": 100}]' 0 \
       '{"include_watching": true, "change_address": "<treasury address>",
         "native_signers": ["<xonly of signer A>", "<xonly of signer B>"]}'

Change goes back to the treasury address, so name it explicitly. The wallet pays at least the C14b fee floor and refuses outputs below the C14c dust limit. It reads both values from the node's consensus profile, which on every V2 network is MIN_FEE_PER_KB = 1000 (1 atom per byte) and DUST_LIMIT = 546 atoms, as in the spec (C14b, C14c). If the node profile changes, the wallet follows it.

  1. Each named signer reviews and signs on their own synced node:
   lotus-cli decodepsbt <psbt>          # check every output and amount
   lotus-cli -rpcwallet=treasury-signer walletpassphrase "<passphrase>" 60
   lotus-cli -rpcwallet=treasury-signer walletprocesspsbt <psbt>

signed_slots should be 1 for a named signer and 0 for anyone else. Signers can sign one after another (pass the PSBT along) or in parallel (then combinepsbt the copies).

  1. Anyone finalizes and broadcasts:
   lotus-cli finalizepsbt <psbt>        # complete: true, returns hex
   lotus-cli sendrawtransaction <hex>

Limitations to know before the launch