Pages:
Author

Topic: BitIDE - TapScript IDE with Local Testnet, Explorer and Custom Op Codes (P2TR) - page 2. (Read 502 times)

copper member
Activity: 33
Merit: 152
Just forgot  Tongue, For the curious, here are the promised polyfills for OP_XOR, OP_OR and OP_AND:

OP_XOR_POLYFILL
Code:
b.OP_0().tag("result");
b.OP_TOALTSTACK();
var numBits = 31;
for (let i = numBits-1; i >= 1; i--) {
  b.OP_DUP();
  b.constant(1 << i);
  b.OP_LESSTHAN();
  b.OP_IF();
    b.OP_0().tag("y_bit");
  b.OP_ELSE();
    b.constant(1 << i);
    b.OP_SUB().tag("y");
    b.OP_1().tag("y_bit");
  b.OP_ENDIF();

  b.OP_ROT();
  b.OP_DUP();

  b.constant(1 << i);
  b.OP_LESSTHAN();
  b.OP_IF();
    b.OP_0().tag("x_bit");
  b.OP_ELSE();
    b.constant(1 << i);
    b.OP_SUB().tag("x");
    b.OP_1().tag("x_bit");
  b.OP_ENDIF();
  b.OP_ROT();

  // xor
  b.OP_NUMEQUAL();
  b.OP_NOT();
  b.OP_IF();
    b.constant(1 << i);
    b.OP_FROMALTSTACK();
    b.OP_ADD();
    b.OP_TOALTSTACK();
  b.OP_ENDIF();
}

// xor
b.OP_NUMEQUAL();
b.OP_NOT();
b.OP_IF();
  b.OP_FROMALTSTACK();
  b.OP_1();
  b.OP_ADD();
b.OP_ELSE();
  b.OP_FROMALTSTACK();
b.OP_ENDIF();



OP_OR_POLYFILL
Code:
var numBits = 31;
b.OP_0().tag("result");
b.OP_TOALTSTACK();
for (let i = numBits - 1; i >= 1; i--) {
  tb.OP_DUP();
  tb.constant(1 << i);
  tb.OP_LESSTHAN();
  tb.OP_IF();
    tb.OP_0().tag("y_bit");
  tb.OP_ELSE();
    tb.constant(1 << i);
    tb.OP_SUB().tag("y");
    tb.OP_1().tag("y_bit");
  tb.OP_ENDIF();

  tb.OP_ROT();
  tb.OP_DUP();

  tb.constant(1 << i);
  tb.OP_LESSTHAN();
  tb.OP_IF();
    tb.OP_0().tag("x_bit");
  tb.OP_ELSE();
    tb.constant(1 << i);
    tb.OP_SUB().tag("x");
    tb.OP_1().tag("x_bit");
  tb.OP_ENDIF();
  tb.OP_ROT();

  // or
  b.OP_BOOLOR();
  b.OP_IF();
    b.constant(1 << i);
    b.OP_FROMALTSTACK();
    b.OP_ADD();
    b.OP_TOALTSTACK();
  b.OP_ENDIF();
}

//or
b.OP_BOOLOR();
b.OP_IF();
  b.OP_FROMALTSTACK();
  b.OP_1();
  b.OP_ADD();
b.OP_ELSE();
  b.OP_FROMALTSTACK();
b.OP_ENDIF();

OP_AND_POLYFILL
Code:
var numBits = 31;
b.OP_0().tag("result");
b.OP_TOALTSTACK();
for (let i = numBits - 1; i >= 1; i--) {
  tb.OP_DUP();
  tb.constant(1 << i);
  tb.OP_LESSTHAN();
  tb.OP_IF();
    tb.OP_0().tag("y_bit");
  tb.OP_ELSE();
    tb.constant(1 << i);
    tb.OP_SUB().tag("y");
    tb.OP_1().tag("y_bit");
  tb.OP_ENDIF();

  tb.OP_ROT();
  tb.OP_DUP();

  tb.constant(1 << i);
  tb.OP_LESSTHAN();
  tb.OP_IF();
    tb.OP_0().tag("x_bit");
  tb.OP_ELSE();
    tb.constant(1 << i);
    tb.OP_SUB().tag("x");
    tb.OP_1().tag("x_bit");
  tb.OP_ENDIF();
  tb.OP_ROT();

  // and
  b.OP_BOOLAND();
  b.OP_IF();
    b.constant(1 << i);
    b.OP_FROMALTSTACK();
    b.OP_ADD();
    b.OP_TOALTSTACK();
  b.OP_ENDIF();
}

// and
b.OP_BOOLAND();
b.OP_IF();
  b.OP_FROMALTSTACK();
  b.OP_1();
  b.OP_ADD();
b.OP_ELSE();
  b.OP_FROMALTSTACK();
b.OP_ENDIF();


OP_NAND
Code:
var numBits = 31;
b.OP_0().tag("result");
b.OP_TOALTSTACK();
for (let i = numBits - 1; i >= 1; i--) {
  tb.OP_DUP();
  tb.constant(1 << i);
  tb.OP_LESSTHAN();
  tb.OP_IF();
    tb.OP_0().tag("y_bit");
  tb.OP_ELSE();
    tb.constant(1 << i);
    tb.OP_SUB().tag("y");
    tb.OP_1().tag("y_bit");
  tb.OP_ENDIF();

  tb.OP_ROT();
  tb.OP_DUP();

  tb.constant(1 << i);
  tb.OP_LESSTHAN();
  tb.OP_IF();
    tb.OP_0().tag("x_bit");
  tb.OP_ELSE();
    tb.constant(1 << i);
    tb.OP_SUB().tag("x");
    tb.OP_1().tag("x_bit");
  tb.OP_ENDIF();
  tb.OP_ROT();

  // nand
  b.OP_BOOLAND();
  b.OP_NOT();
  b.OP_IF();
    b.constant(1 << i);
    b.OP_FROMALTSTACK();
    b.OP_ADD();
    b.OP_TOALTSTACK();
  b.OP_ENDIF();
}

// nand
b.OP_BOOLAND();
b.OP_NOT();
b.OP_IF();
  b.OP_FROMALTSTACK();
  b.OP_1();
  b.OP_ADD();
b.OP_ELSE();
  b.OP_FROMALTSTACK();
b.OP_ENDIF();
copper member
Activity: 33
Merit: 152



BitIDE - The Bitcoin TapScript IDE


Quick Links
>> Open BitIDE Web <<
(*NEW*) Setup Local Testnet + Block Explorer + Deploy your first TapScript

BTCitcoin Script on Steroids
Custom OpCodes for Code Reuse
Meta Programming and JavaScript Macros
Symbol/Tag Based Stack Management
Integrated Local Block Explorer + Local RegTest Testnet

Developer First
Full trace debugger with human readable symbol tagging
Polyfills for disabled op codes
Transpile to Bitcoin Mainnet compatible TapScript with the press of a button
Install and start a fresh testnet environment with a single command
Cross platform: Browser based and local docker versions


Install and Start Local Environment
(Includes Testnet, BitIDE and Block Explorer)
Code:
docker run -p 1337:1337 -it --rm qedprotocol/bitide:latest


*NEW* Install and Start Local Environment for Elements/Liquid
(Includes Elements 23.3.1 Local Testnet, BitIDE and Block Explorer)
Code:
docker run -p 1337:1337 -it --rm qedprotocol/bitide-liquid:latest

(Docker pull to update to the latest version)





Watch the Pay to Script Path Tutorial






Watch the Getting Started Tutorial








Release Notes
Code:

===== Release 0.7.0 =====
- Added support for elements/liquid + partial support for elements op codes (OP_MUL64, OP_SUB64, OP_ADD64, OP_DIV64, OP_CAT, etc.)
===================

===== Release 0.6.0 =====
- Bug fixes
- Fixed file explorer resizing issue
===================

===== Release 0.5.3 =====
- Added local testnet, block explorer and electrs API
- Added TapScript deployment tool and test unlocker
===================


More to come, would appreciate any feedback/feature requests!

Hope this helps encorage more innovation within the framework of the features Bitcoin has already enabled and spur on debates for future BIPs.

Pages:
Jump to: