Skip to content

Latest commit

 

History

History
305 lines (227 loc) · 8.62 KB

File metadata and controls

305 lines (227 loc) · 8.62 KB

Multi-Signature Transaction Builder - Acceptance Criteria

✅ 1. Interactive Multi-Sig Builder Works

  • CLI commands for full workflow
  • Step-by-step proposal creation
  • Signer management (add/remove)
  • Interactive signing process
  • Clear error messages
  • Graceful handling of edge cases

Test:

starforge multisig create --threshold 2 --signers "alice,bob,charlie"
starforge multisig view proposal_*.json
starforge multisig sign proposal_*.json --wallet alice

✅ 2. Visual Progress Tracking

  • Progress bar display
    [████████░░] 50%
    
  • Signature count display (1/2)
  • Status indicators (✓/✗)
  • Pending signers list
  • Color-coded output
  • Real-time updates

Test:

starforge multisig status proposal_*.json
# Should show progress bar + pending list

✅ 3. Transaction Proposal Export/Import

  • Export to JSON format
  • Import from JSON
  • Preserve all data
  • Configurable output path
  • Timestamp in filename
  • Backup capability

Test:

starforge multisig export proposal.json
starforge multisig import proposal_export_*.json --output imported.json
starforge multisig view imported.json
# Should show identical proposal

✅ 4. Signature Verification

  • Validate signature format
  • Verify signer identity
  • Check threshold met
  • Detect tampering
  • Expiration checks
  • Clear validation errors

Test:

# In multisig_builder.rs
starforge multisig sign proposal.json --wallet alice
# Verifies signature format and adds to proposal
starforge multisig submit proposal.json
# Validates all signatures before submission

✅ 5. Common Multi-Sig Templates

  • Escrow (2-of-3) - buyer, seller, arbiter
  • Company (3-of-5) - CEO, CFO, 3 board members
  • DAO (5-of-9) - 9 members
  • Vault (2-of-2) - cold storage
  • Payment (1-of-2) - flexible approval

Test:

starforge multisig templates
# Lists all templates

starforge multisig from-template escrow --output escrow.json
# Creates pre-configured proposal

✅ 6. Notification System

  • Email notifications
  • Slack integration
  • Discord integration
  • Webhook support
  • Custom messages
  • Recipient list from proposal

Test:

starforge multisig notify proposal.json --channel email
starforge multisig notify proposal.json --channel slack --webhook https://...

Implementation Checklist

Code Files

  • src/commands/multisig_builder.rs - CLI commands (500 LOC)
  • src/utils/multisig_builder.rs - Core logic + tests (300 LOC)
  • src/main.rs - Integration
  • src/commands/mod.rs - Module export
  • src/utils/mod.rs - Module export

Documentation

  • MULTISIG_BUILDER_GUIDE.md - Complete guide
  • MULTISIG_ACCEPTANCE.md - Acceptance criteria
  • Code comments & examples
  • Workflow examples
  • API reference

Tests

  • Unit tests for core logic
  • Integration tests for CLI
  • Manual testing workflows
  • Edge case handling

Features Implemented

Commands

  • multisig create - New proposal
  • multisig add-signer - Add signer
  • multisig sign - Sign proposal
  • multisig view - Show details
  • multisig status - Check progress
  • multisig submit - Submit to network
  • multisig export - Export JSON
  • multisig import - Import JSON
  • multisig templates - List templates
  • multisig from-template - Create from template

Workflows

  • ✅ Escrow workflow
  • ✅ Company payment workflow
  • ✅ DAO treasury workflow
  • ✅ Cold storage vault workflow
  • ✅ Flexible payment workflow

Visual Elements

  • ✅ Progress bars
  • ✅ Status indicators
  • ✅ Color-coded output
  • ✅ Formatted tables
  • ✅ Real-time updates

Data Handling

  • ✅ Proposal creation
  • ✅ Signature tracking
  • ✅ JSON serialization
  • ✅ Export/import
  • ✅ Metadata storage
  • ✅ Expiration support

Testing Checklist

Manual Testing

  • Create proposal with CLI
  • Add multiple signers
  • Sign with different wallets
  • Check progress visualization
  • Export proposal
  • Import proposal
  • Create from each template
  • Submit completed proposal
  • Handle error cases

Workflows

  • Complete escrow scenario
  • Complete company payment
  • Complete DAO voting
  • Complete vault operation
  • Partial signatures (not ready yet)

Performance

  • Proposal creation <10ms
  • Signature addition <50ms
  • Status display <5ms
  • Export <100ms

Audit Log Format (Signer/Threshold Change Detection)

Every detected change to an account's signer set (additions, removals, weight edits, threshold changes, or a master-weight change) is recorded into a local append-only, integrity-protected audit log for operators. The implementation lives in src/utils/multisig_audit.rs.

Log location

The log is a newline-delimited JSON (.jsonl) file at:

<home>/.starforge/audit/multisig_signer_changes.jsonl

<home> resolves to $USERPROFILE / $HOME when set, otherwise the OS home directory (dirs::home_dir). Supporting snapshots used for diffing are kept in <home>/.starforge/audit/multisig_state/. The file is only ever opened in append mode; existing records are never rewritten or deleted.

Record fields

Each line is a single JSON object with these fields:

Field Type Description
seq u64 Monotonically increasing record sequence number
at string RFC3339 UTC timestamp of the observation
account_id string Multisig account being observed
network string Network the account lives on (e.g. testnet, mainnet)
kind string baseline, add_signer, remove_signer, weight_change, threshold_change, master_weight_change
added array Signers added since the previous snapshot
removed array Signers removed since the previous snapshot
weights_changed array Weight edits (public_key, old_weight, new_weight)
thresholds_changed array Threshold edits (level low/medium/high, old_value, new_value)
master_weight_changed [u8, u8] | null Master-weight change as (old, new), or null
alert bool true when flagged unexpected while monitoring is enabled
note string | null Optional alert / context message
prev_hash string SHA-256 of the preceding record; "0" for the first record
hash string SHA-256 of this record's canonical payload (excludes hash)

Integrity model (hash chain)

Each record's hash is the SHA-256 digest of its canonical payload (seq, at, account_id, network, kind, the change vectors, alert, note, and prev_hash). The prev_hash of every record equals the hash of the record that immediately precedes it; the first record's prev_hash is "0". This chaining means that rewriting, deleting, reordering, or inserting any record breaks the chain and is detectable.

Verification

multisig_audit::verify_audit_log(&records) returns every integrity violation:

  • the stored hash does not match the recomputed digest over the record's audit payload, or
  • the record's prev_hash does not match the previous record's hash (i.e. a broken chain link).

The signer-change feature is covered by the unit tests in src/utils/multisig_audit.rs (diff, alerting, hash-chain/verify) and the integration tests in tests/multisig_signer_audit.rs, including an audit-log tamper test that confirms modifications are detected.


Acceptance Sign-Off

  • All commands functional
  • Visual progress working
  • Export/import verified
  • Signatures validate
  • All templates available
  • Notifications send
  • Documentation complete
  • Tests passing
  • Performance acceptable
  • Production ready

Status: ✅ COMPLETE

All acceptance criteria implemented, tested, and documented.