A powerful desktop application for developing, executing, and debugging Bitcoin Script with visual stack inspection. Built with Electron and Monaco Editor.
- Monaco Editor Integration: Professional code editor with Bitcoin Script syntax highlighting
- Step-Through Debugger: Execute scripts line-by-line or instruction-by-instruction (F10)
- Visual Line Indicators: Green glyph shows current execution position
- Error Highlighting: Red markers and persistent error toasts with helpful messages
- Initial Stack Input: Space-separated values with live preview
- Stack-Based Execution: Real-time visualization of main and alternate stacks
- Execution History: Complete log of all executed opcodes with descriptions
- 76 Implemented Opcodes: Full BSV opcode set including restored opcodes (CAT, SPLIT, MUL, etc.)
- Real Cryptographic Hashing: SHA256, SHA1, RIPEMD160, HASH256, HASH160 via BSV SDK
- Simulated Signatures: checkSig opcodes for testing script logic without transaction context
- Macro System: xSwap_n, xDrop_n, xRot_n, hashCat, LOOP[n]{body}
- Import System: Modular scripts with named and wildcard imports
- Example Library: Pre-built scripts and importable macro libraries
- Native Menus: Platform-specific File/Edit/View/Run/Help menus
- Recent Files: Quick access to recently opened scripts
- Autosave Warnings: Prompts before losing unsaved work
- Smart Defaults: File dialogs open to examples folder
- Comprehensive Documentation: Searchable help panel with all opcode references
- Keyboard Shortcuts: Quick access guide
- Example Files: Click-to-open examples
- Settings Panel: Toggle signature verification mode
- Network Selection: Choose mainnet/testnet/regtest
- Persistent Preferences: Settings saved across sessions
- Electron Security Best Practices: Context isolation, sandboxing, no node integration
- Secure IPC: All main process communication via contextBridge
# Install dependencies
npm install
# Run the application
npm start
# Run in development mode (with DevTools)
npm run devSVSCRIPT uses camelCase keywords for opcodes instead of the traditional OP_CODE format:
Traditional Bitcoin Script:
OP_DUP OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG
SVSCRIPT Syntax:
dup hash160 equalVerify checkSig
false,true,0,1
nop,if,notIf,else,endIf,verify,return
toAltStack,fromAltStack,ifDup,depth,drop,dupnip,over,pick,roll,rot,swap,tuck2drop,2dup,3dup,2over,2rot,2swap
add,sub,mul,div,mod,negate,abs,not0notEqual,1add,1sub,min,max,within
and,or,xor,invert,lShift,rShift
equal,equalVerify,lessThan,greaterThanlessThanOrEqual,greaterThanOrEqualnumEqual,numEqualVerify,numNotEqual
cat,split,num2bin,bin2num,size
ripemd160,sha1,sha256,hash160,hash256checkSig,checkSigVerify,checkMultiSig,checkMultiSigVerifycheckDataSig,checkDataSigVerify(BSV)
// Push two numbers and add them
5 10 add
// Duplicate the result
dup
// Swap and multiply
15 swap mul
// Result: 225// Check if a number is positive
42
dup 0 greaterThan
if
100 add
else
100 sub
endIf
// Result: 142// Demonstrate stack operations
1 2 3
// Stack: [1, 2, 3]
dup
// Stack: [1, 2, 3, 3]
swap
// Stack: [1, 2, 3, 3]
over
// Stack: [1, 2, 3, 3, 3]// Move values to alternate stack
10 20 30
toAltStack
// Main: [10, 20], Alt: [30]
toAltStack
// Main: [10], Alt: [20, 30]
fromAltStack
// Main: [10, 20], Alt: [30]- Ctrl/Cmd + Enter: Run entire script
- F10: Step through script (one instruction at a time)
The debugger provides:
- Main Stack: Shows all values on the main execution stack (top to bottom)
- Alternate Stack: Shows values moved to the alternate stack
- Execution History: Complete log of executed opcodes with descriptions
- Execution State:
- Current instruction pointer
- Total instructions
- Number of executed instructions
- Console Output: Logs, errors, and execution results
- Executes the entire script at once
- Shows final stack state and any errors
- Highlights the error location if execution fails
- Press F10 to start stepping
- Each F10 press executes one instruction
- Watch stack changes in real-time
- Perfect for understanding complex scripts
- Context Isolation: Renderer process isolated from main process
- Node Integration Disabled: No direct Node.js access in renderer
- Preload Scripts: Secure IPC bridge using contextBridge
- Content Security Policy: Strict CSP headers
- 32-bit signed integer arithmetic
- Non-recursive execution model
- Static branching only (IF/ELSE/ENDIF)
- No dynamic looping
svscript/
├── src/
│ ├── main/
│ │ └── main.js # Electron main process
│ ├── preload/
│ │ └── preload.js # Secure IPC bridge
│ └── renderer/
│ ├── index.html # Application UI
│ ├── styles.css # Application styles
│ ├── app.js # Main application logic
│ ├── interpreter.js # Bitcoin Script interpreter engine
│ └── syntax.js # Monaco Editor language definition
├── package.json
└── README.md
- Add opcode to
interpreter.jsin theopcodeMapobject - Implement the opcode method (e.g.,
op_newopcode()) - Add opcode to syntax highlighting in
syntax.jskeywords array - Test with example scripts
Monaco Editor configuration can be modified in app.js:
editor = monaco.editor.create(document.getElementById('editor-container'), {
// Your custom settings here
fontSize: 14,
theme: 'bitcoinscript-dark',
// ... more options
});Bitcoin Script is a stack-based, Forth-like language with these characteristics:
- Stack-based: All operations work with a stack (LIFO data structure)
- No loops: Only static branching with IF/ELSE/ENDIF
- Integer arithmetic: 32-bit signed integers
- Two stacks: Main stack and alternate stack for temporary storage
- Deterministic: Same script always produces same result
- Non-Turing complete: Intentionally limited for security
The stack display shows:
- Index position (0 = bottom, top = highest index)
- Value (with type information)
- Values are displayed top-to-bottom for intuitive understanding
Each entry shows:
- Instruction pointer position
- Opcode executed
- Human-readable description
- Stack snapshot at that point (available in code)
- Stack underflow detection
- Division by zero prevention
- Invalid opcode detection
- Type conversion errors
- Verification failures
MIT
This is a development tool for Bitcoin Script. Contributions welcome for:
- Additional opcode implementations
- Improved error messages
- Enhanced visualization features
- Performance optimizations
- Documentation improvements
Built with:
- Electron - Desktop application framework
- Monaco Editor - Code editor
- Bitcoin SV opcode specification