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:
- Every signer contributes one compressed public key. The wallet uses only its 32-byte x-only part. Keys are sorted in ascending order, so the order in which you list them does not matter.
- Each set of
mkeys becomes one leaf script. For a setk1 < ... < kmthe script isPUSH32 k1 CHECKSIGVERIFY ... PUSH32 km CHECKSIG. - The leaves are hashed with the branch domain and built into a tree with the compiler's
sorted-leaves-largest-power-split-v1recipe. The address is the type-0 (explicit root) native address of that tree's root. - A spend reveals one leaf, which means one signer set, plus its proof. Nothing else about the policy is revealed.
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:
address: the treasury address (xpi1...on mainnet).descriptor:xpimulti(2,<pubkeys>)#checksum, used for the watch-only wallet.root: the branch root the address commits to.xonly_keys: the sorted x-only keys.leaves: the number of signer sets.
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
- 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.
- 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).
- Anyone finalizes and broadcasts:
lotus-cli finalizepsbt <psbt> # complete: true, returns hex
lotus-cli sendrawtransaction <hex>
Limitations to know before the launch
- Signers sign on a synced node, not offline. A signer's wallet only signs after its node authenticates the spent coins against the node's own confirmed UTXO root. This is what the spec's coin-authentication rule requires. No coin-proof generator exists yet for air-gapped signing. A signer machine can stay off the public internet only if it syncs from a node the signer trusts.
- Only confirmed coins can be spent through a PSBT. The trusted lookup reads the confirmed state at the tip, not the mempool.
- Signatures are mode 0 (FULL) only. The wallet never makes partial-scope signatures on its own.
- Payout destinations. How miners, staking and the treasury payout choose native addresses is not in the spec (
addresses.md). A treasury payout to the type-0 address above can be spent with this procedure. - Keep wallet backups current. A signer key from
getnewaddresscomes from the wallet's HD seed. Back up the wallet after creating the key.