Skip to content

Commit 91a363b

Browse files
authored
feat: Multisig commands with HS support (#60)
* poc: Multisig commands - basic flows * feat: Multisig - two command types * feat: Consistent execution with all existing features * fix: Clippy warns in examples * fix: Library perspective * feat: Multisig - validation * poc: HS in multisic working commands * fix: --predict removed * feat: Deterministic address generation * feat: Multisig + HS with the best possible UX * feat: Multisig+HS - tested * fix: Clippy * fix: README
1 parent ccd535c commit 91a363b

9 files changed

Lines changed: 4274 additions & 13 deletions

File tree

LIBRARY_USAGE.md

Lines changed: 444 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,215 @@ The CLI provides a comprehensive set of commands for blockchain interaction. Sta
476476

477477
The CLI supports both simple commands and complex workflows, with built-in help and error recovery at every level.
478478

479+
## 🔐 Multisig Wallets
480+
481+
The Quantus CLI provides comprehensive support for multi-signature wallets, allowing you to create shared accounts that require multiple approvals before executing transactions.
482+
483+
### Key Features
484+
485+
- **Deterministic Address Generation**: Multisig addresses are derived from signers + threshold + nonce
486+
- **Flexible Threshold**: Configure how many approvals are needed (e.g., 2-of-3, 5-of-7)
487+
- **Full Call Transparency**: Complete transaction data stored on-chain (no blind signing)
488+
- **Auto-Execution**: Proposals execute automatically when threshold is reached
489+
- **Human-Readable Amounts**: Use simple formats like `10` instead of `10000000000000`
490+
- **Smart Address Display**: Automatic SS58 formatting with proper network prefix (`qz...`)
491+
- **Balance Tracking**: View multisig balance directly in `info` command
492+
- **Expiry Validation**: Client-side checks prevent expired proposals
493+
- **Deposit Management**: Refundable deposits incentivize cleanup
494+
- **Query Support**: Inspect multisig configuration, proposals, and balances
495+
496+
### Quick Start Example
497+
498+
```bash
499+
# 1. Create a 2-of-3 multisig (waits for confirmation by default)
500+
quantus multisig create \
501+
--signers "alice,bob,charlie" \
502+
--threshold 2 \
503+
--from alice \
504+
--wait-for-transaction
505+
506+
# Output: 📍 Multisig address: qz... (with proper network prefix)
507+
508+
# 2. Fund the multisig (anyone can send funds)
509+
quantus send \
510+
--from alice \
511+
--to qz... \
512+
--amount 1000
513+
514+
# 3. Create a transfer proposal (human-readable amount)
515+
quantus multisig propose transfer \
516+
--address qz... \
517+
--to dave \
518+
--amount 10 \
519+
--expiry 1500 \
520+
--from alice
521+
522+
# Note: Expiry is BLOCK NUMBER (e.g., current block + 1000)
523+
524+
# 4. Check proposal details (shows current block + blocks remaining)
525+
quantus multisig info --address qz... --proposal-id 0
526+
527+
# Output shows:
528+
# Current Block: 450
529+
# Expiry: block 1500 (1050 blocks remaining)
530+
531+
# 5. Second signer approves (auto-executes at threshold)
532+
quantus multisig approve \
533+
--address qz... \
534+
--proposal-id 0 \
535+
--from bob
536+
```
537+
538+
### Available Commands
539+
540+
#### Create Multisig
541+
```bash
542+
# Default: Wait for transaction and extract address from event
543+
quantus multisig create \
544+
--signers "addr1,addr2,addr3" \
545+
--threshold 2 \
546+
--from creator_wallet
547+
548+
# Fast mode: Predict address immediately (may be wrong if concurrent creation)
549+
quantus multisig create \
550+
--signers "addr1,addr2,addr3" \
551+
--threshold 2 \
552+
--from creator_wallet \
553+
--predict
554+
```
555+
556+
#### Propose Transfer (Recommended for simple transfers)
557+
```bash
558+
quantus multisig propose transfer \
559+
--address <multisig_address> \
560+
--to <recipient> \
561+
--amount 10 \
562+
--expiry <future_block_number> \
563+
--from signer_wallet
564+
565+
# Amount formats supported:
566+
# 10 → 10 QUAN
567+
# 10.5 → 10.5 QUAN
568+
# 0.001 → 0.001 QUAN
569+
# 10000000000000 → raw format (auto-detected)
570+
```
571+
572+
#### Propose Custom Transaction (Full flexibility)
573+
```bash
574+
quantus multisig propose custom \
575+
--address <multisig_address> \
576+
--pallet System \
577+
--call remark \
578+
--args '["Hello from multisig"]' \
579+
--expiry <future_block_number> \
580+
--from signer_wallet
581+
```
582+
583+
#### Approve Proposal
584+
```bash
585+
quantus multisig approve \
586+
--address <multisig_address> \
587+
--proposal-id <id> \
588+
--from signer_wallet
589+
```
590+
591+
#### Cancel Proposal (proposer only)
592+
```bash
593+
quantus multisig cancel \
594+
--address <multisig_address> \
595+
--proposal-id <id> \
596+
--from proposer_wallet
597+
```
598+
599+
#### Query Multisig Info
600+
```bash
601+
# Show multisig details (signers, threshold, balance, etc.)
602+
quantus multisig info --address <multisig_address>
603+
604+
# Show specific proposal details (includes current block + time remaining)
605+
quantus multisig info --address <multisig_address> --proposal-id <id>
606+
```
607+
608+
#### List All Proposals
609+
```bash
610+
quantus multisig list-proposals --address <multisig_address>
611+
```
612+
613+
#### Cleanup (Recover Deposits)
614+
```bash
615+
# Remove single expired proposal
616+
quantus multisig remove-expired \
617+
--address <multisig_address> \
618+
--proposal-id <id> \
619+
--from signer_wallet
620+
621+
# Batch cleanup all expired proposals
622+
quantus multisig claim-deposits \
623+
--address <multisig_address> \
624+
--from any_signer_wallet
625+
```
626+
627+
#### Dissolve Multisig
628+
```bash
629+
# Requires: no proposals exist, zero balance
630+
quantus multisig dissolve \
631+
--address <multisig_address> \
632+
--from creator_or_signer_wallet
633+
```
634+
635+
### Economics
636+
637+
The multisig pallet uses an economic model to prevent spam and incentivize cleanup:
638+
639+
- **MultisigFee**: Non-refundable fee paid to treasury on creation
640+
- **MultisigDeposit**: Refundable deposit (locked, returned on dissolution)
641+
- **ProposalFee**: Non-refundable fee per proposal (scales with signer count)
642+
- **ProposalDeposit**: Refundable deposit per proposal (locked, returned after cleanup)
643+
644+
**Deposits are visible in `multisig info` output:**
645+
```
646+
Balance: 1000 QUAN ← Spendable balance
647+
Deposit: 0.5 QUAN (locked) ← Refundable creation deposit
648+
```
649+
650+
### Best Practices
651+
652+
1. **Use Descriptive Names**: Use wallet names instead of raw addresses for better readability
653+
2. **Set Reasonable Expiry**: Use future block numbers (current + 1000 for ~3.3 hours at 12s/block)
654+
3. **Verify Proposals**: Use `info --proposal-id` to decode and verify proposal contents before approving
655+
4. **Cleanup Regularly**: Use `claim-deposits` to recover deposits from expired proposals
656+
5. **Monitor Balances**: Check multisig balance with `info --address` command
657+
6. **High Security**: For high-value multisigs, use higher thresholds (e.g., 5-of-7 or 4-of-6)
658+
659+
### Security Considerations
660+
661+
- **Immutable Configuration**: Signers and threshold cannot be changed after creation
662+
- **Full Transparency**: All call data is stored and decoded on-chain (no blind signing)
663+
- **Auto-Execution**: Proposals execute automatically when threshold is reached
664+
- **Access Control**: Only signers can propose/approve, only proposer can cancel
665+
- **Expiry Protection**: Client validates expiry before submission to prevent wasted fees
666+
- **Deterministic Addresses**: Multisig addresses are derived from signers + threshold + nonce and are verifiable
667+
668+
### Advanced Features
669+
670+
**Decoding Proposals**: The CLI automatically decodes common call types:
671+
```bash
672+
$ quantus multisig info --address qz... --proposal-id 0
673+
674+
📝 PROPOSAL Information:
675+
Current Block: 450
676+
Call: Balances::transfer_allow_death
677+
To: qzmqr...
678+
Amount: 10 QUAN
679+
Expiry: block 1500 (1050 blocks remaining)
680+
```
681+
682+
**SS58 Address Format**: All addresses use the Quantus network prefix (`qz...` for prefix 189) automatically.
683+
684+
**Password Convenience**: Omit `--password ""` for wallets with no password.
685+
686+
For more details, see `quantus multisig --help` and explore subcommands with `--help`.
687+
479688
## 🏗️ Architecture
480689

481690
### Quantum-Safe Cryptography

0 commit comments

Comments
 (0)