Bitcoin Forum
April 26, 2024, 10:08:13 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Working on a language and compiler for Bitcoin scripts  (Read 774 times)
olalonde (OP)
Newbie
*
Offline Offline

Activity: 25
Merit: 0


View Profile
March 03, 2014, 11:01:14 AM
 #1

I've never written a compiler before and wanted to give it a shot so I decided to write a high level language and compiler for Bitcoin's stack based script
language. So far, the parser kind of works but the compilation step is still work in progress. The language (bitscript) uses a Javascript like syntax.

The following script should compile to a standard transaction script (eventually):

Code:
// standardtransaction.bitscript
function main(sig, pubKey) {
  pubKeyHash = '1eHhgW6vquBYhwMPhQ668HPjxTtpvZGPC';
  pubKeyHashA = hash160(pubKey);

  // should be optimized to OP_EQUALVERIFY
  assert(pubKeyHash == pubKeyHashA);

  // should be optimized to OP_CHECKSIGVERIFY
  assert(checksig(sig, pubkey));
}

I'm posting this here mainly to keep me motivated and in case anyone wants to participate. I'm writing the compiler using Node.js + Jison. https://github.com/olalonde/compiler/
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!