The Bitcoin Cash ecosystem is moving at light speed and the BITBOX team is working daily to keep up. BITBOX has now been downloaded 14,000+ times from 62 countries and the pace is accelerating. It’s clear that developers all over the EARTH are excited about Bitcoin Cash and are interested in leveraging it to build amazing applications.
May 15th
The next big milestone in the $BCH ecosystem is the network upgrade on May 15th. It’s bringing a larger 32MB block size limit, new or reenabled OP Codes and larger OP_RETURN
data. BITBOX will be ready for developers to take advantage of all of these features.
With that in mind we’re happy to release bitbox-cli
v0.7.0 which comes w/ a bunch of great features in the Script
class. Let’s dig in.
Script
OP Codes
BITBOX supports all of the existing Script OP Codes as well as the ones for May 15th: OP_CAT
, OP_AND
, OP_OR
, OP_XOR
, OP_DIV
, OP_MOD
, OP_SPLIT
, OP_NUM2BIN
, and OP_BIN2NUM
// list all op codes
BITBOX.Script.opcodes;
// { OP_FALSE: 0,
// OP_0: 0,
// OP_PUSHDATA1: 76,
// OP_PUSHDATA2: 77,
// OP_PUSHDATA4: 78,
// OP_1NEGATE: 79,
// OP_RESERVED: 80,
// OP_TRUE: 81,
// OP_1: 81,
// OP_2: 82,
// OP_3: 83,
// OP_4: 84,
// ...
// }
// get the op code for a word
BITBOX.Script.opcodes.OP_SPLIT
// 127
BITBOX.Script.opcodes.OP_NUM2BIN
// 128
BITBOX.Script.opcodes.OP_BIN2NUM
// 129
Full list of supported OP codes.
Templates
BITBOX now has templates for quickly encoding and decoding inputs or outputs in the following standard transaction types: P2PK, P2PKH, P2MS, P2SH and nulldata as well as checking their format.
nulldata
Encode Output
let data = "Satoshi Nakamoto";
let buf = BITBOX.Script.nullData.output.encode(Buffer.from(data, 'ascii'));
// <Buffer 6a 10 53 61 74 6f 73 68 69 20 4e 61 6b 61 6d 6f 74 6f>
BITBOX.Script.toASM(buf);
// OP_RETURN 5361746f736869204e616b616d6f746
Decode Output
// first encode
let data = "Satoshi Nakamoto";
let buffer = BITBOX.Script.nullData.output.encode(Buffer.from(data, 'ascii'));
let asm = BITBOX.Script.toASM(buffer);
// OP_RETURN 5361746f736869204e616b616d6f746
//decode
let buf = BITBOX.Script.fromASM(asm);
BITBOX.Script.nullData.output.decode(buf).toString('ascii');
// Satoshi Nakamoto
Check Output
let data = "Satoshi Nakamoto";
let buf = BITBOX.Script.nullData.output.encode(Buffer.from(data, 'ascii'));
BITBOX.Script.nullData.output.check(buf);
// true
check nulldata format more info
P2PK
Encode Input
let signature = '304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801';
let buf = BITBOX.Script.pubKey.input.encode(Buffer.from(signature, 'hex'));
// <Buffer 47 30 44 02 20 75 15 cf 14 7d 20 1f 41 10 92 e6 be 5a 64 a6 00 6f 93 08 fa d7 b2 a8 fd aa b2 2c d8 6c e7 64 c2 02 20 09 74 b8 ac a7 bf 51 db f5 41 50 ... >
BITBOX.Script.toASM(buf);
// 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801
Decode Input
let asm = '304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801';
let buf = BITBOX.Script.fromASM(asm);
BITBOX.Script.pubKey.input.decode(buf);
// <Buffer 30 44 02 20 75 15 cf 14 7d 20 1f 41 10 92 e6 be 5a 64 a6 00 6f 93 08 fa d7 b2 a8 fd aa b2 2c d8 6c e7 64 c2 02 20 09 74 b8 ac a7 bf 51 db f5 41 50 d3 ... >
Check Input
let signature = '304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801';
let input = BITBOX.Script.pubKey.input.encode(Buffer.from(signature, 'hex'));
BITBOX.Script.pubKey.input.check(input);
// true
check P2PK input format more info
Encode Output
let pubKey = '02d305772e0873fba6c1c7ff353ce374233316eb5820acd7ff3d7d9b82d514126b';
let buf = BITBOX.Script.pubKey.output.encode(Buffer.from(pubKey, 'hex'));
// <Buffer 21 02 d3 05 77 2e 08 73 fb a6 c1 c7 ff 35 3c e3 74 23 33 16 eb 58 20 ac d7 ff 3d 7d 9b 82 d5 14 12 6b ac>
BITBOX.Script.toASM(buf)
// 02d305772e0873fba6c1c7ff353ce374233316eb5820acd7ff3d7d9b82d514126b OP_CHECKSIG
Decode Output
let asm = '02d305772e0873fba6c1c7ff353ce374233316eb5820acd7ff3d7d9b82d514126b OP_CHECKSIG';
let buf = BITBOX.Script.fromASM(asm);
BITBOX.Script.pubKey.output.decode(buf);
// <Buffer 02 d3 05 77 2e 08 73 fb a6 c1 c7 ff 35 3c e3 74 23 33 16 eb 58 20 ac d7 ff 3d 7d 9b 82 d5 14 12 6b>
Check Output
// check p2pk output
let pubKey = '02d305772e0873fba6c1c7ff353ce374233316eb5820acd7ff3d7d9b82d514126b';
let buf = BITBOX.Script.pubKey.output.encode(Buffer.from(pubKey, 'hex'));
BITBOX.Script.pubKey.output.check(buf);
// true
check P2PK output format more info
P2PKH
Encode Input
let signature = '304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801';
let pubKey = '02d9bb8da1de26d390b6f3dcb4e589857730536b646995fa948a8319ede2ca1c15';
let buf = BITBOX.Script.pubKeyHash.input.encode(Buffer.from(signature, 'hex'), Buffer.from(pubKey, 'hex'));
// <Buffer 47 30 44 02 20 75 15 cf 14 7d 20 1f 41 10 92 e6 be 5a 64 a6 00 6f 93 08 fa d7 b2 a8 fd aa b2 2c d8 6c e7 64 c2 02 20 09 74 b8 ac a7 bf 51 db f5 41 50 ... >
BITBOX.Script.toASM(buf);
// 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 02d9bb8da1de26d390b6f3dcb4e589857730536b646995fa948a8319ede2ca1c15
Decode Input
let asm = '304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 02d9bb8da1de26d390b6f3dcb4e589857730536b646995fa948a8319ede2ca1c15';
let buf = BITBOX.Script.fromASM(asm);
BITBOX.Script.pubKeyHash.input.decode(buf);
// { signature: <Buffer 30 44 02 20 75 15 cf 14 7d 20 1f 41 10 92 e6 be 5a 64 a6 00 6f 93 08 fa d7 b2 a8 fd aa b2 2c d8 6c e7 64 c2 02 20 09 74 b8 ac a7 bf 51 db f5 41 50 d3 ... >,
// pubKey: <Buffer 02 d9 bb 8d a1 de 26 d3 90 b6 f3 dc b4 e5 89 85 77 30 53 6b 64 69 95 fa 94 8a 83 19 ed e2 ca 1c 15> }
Check Input
// check p2pkh input
let signature = '304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801';
let pubKey = '02d9bb8da1de26d390b6f3dcb4e589857730536b646995fa948a8319ede2ca1c15';
let buf = BITBOX.Script.pubKeyHash.input.encode(Buffer.from(signature, 'hex'), Buffer.from(pubKey, 'hex'));
BITBOX.Script.pubKeyHash.input.check(buf);
// true
check P2PKH input format more info
Encode Output
let node = BITBOX.HDNode.fromXPriv('xprv9xoxVbZ7L8jmvKx7e1hgd7muo8H35ysTx1LCKFey5nVHUkHSPBxpzBzt2HVK16hu4m6oN5vfaCWSZQvqtDhfJTCY3t9ocp7H7zcTZ2fVRwL');
let identifier = BITBOX.HDNode.toIdentifier(node);
let buf = BITBOX.Script.pubKeyHash.output.encode(identifier);
// <Buffer 76 a9 14 6e e7 de d4 f9 d0 de b6 f4 a6 3d 68 df 5c cc 4e 41 ad 89 67 88 ac>
BITBOX.Script.toASM(buf)
// OP_DUP OP_HASH160 6ee7ded4f9d0deb6f4a63d68df5ccc4e41ad8967 OP_EQUALVERIFY OP_CHECKSIG
Decode Output
let asm = 'OP_DUP OP_HASH160 6ee7ded4f9d0deb6f4a63d68df5ccc4e41ad8967 OP_EQUALVERIFY OP_CHECKSIG';
let buf = BITBOX.Script.fromASM(asm);
BITBOX.Script.pubKeyHash.output.decode(buf);
// <Buffer 6e e7 de d4 f9 d0 de b6 f4 a6 3d 68 df 5c cc 4e 41 ad 89 67>
Check Output
// check p2pkh output
let node = BITBOX.HDNode.fromXPriv('xprv9xoxVbZ7L8jmvKx7e1hgd7muo8H35ysTx1LCKFey5nVHUkHSPBxpzBzt2HVK16hu4m6oN5vfaCWSZQvqtDhfJTCY3t9ocp7H7zcTZ2fVRwL');
let identifier = BITBOX.HDNode.toIdentifier(node);
let buf = BITBOX.Script.pubKeyHash.output.encode(identifier);
BITBOX.Script.pubKeyHash.output.check(buf);
// true
check P2PKH output format more info
P2MS
Encode Input
let signatures = [
"304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801",
"3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501"
];
let sigs = signatures.map((signature) => {
return signature ? Buffer.from(signature, 'hex') : BITBOX.Script.opcodes.OP_0
})
let buf = BITBOX.Script.multisig.input.encode(sigs);
// <Buffer 00 47 30 44 02 20 75 15 cf 14 7d 20 1f 41 10 92 e6 be 5a 64 a6 00 6f 93 08 fa d7 b2 a8 fd aa b2 2c d8 6c e7 64 c2 02 20 09 74 b8 ac a7 bf 51 db f5 41 ... >
BITBOX.Script.toASM(buf);
// OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d14050
Decode Input
// first encode
let signatures = [
"304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801",
"3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501"
];
let sigs = signatures.map((signature) => {
return signature ? Buffer.from(signature, 'hex') : BITBOX.Script.opcodes.OP_0
})
let buffer = BITBOX.Script.multisig.input.encode(sigs);
// <Buffer 00 47 30 44 02 20 75 15 cf 14 7d 20 1f 41 10 92 e6 be 5a 64 a6 00 6f 93 08 fa d7 b2 a8 fd aa b2 2c d8 6c e7 64 c2 02 20 09 74 b8 ac a7 bf 51 db f5 41 ... >
let asm = BITBOX.Script.toASM(buffer);
// OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d14050
// decode
let buf = BITBOX.Script.fromASM(asm);
BITBOX.Script.multisig.input.decode(buf);
// [ <Buffer 30 44 02 20 75 15 cf 14 7d 20 1f 41 10 92 e6 be 5a 64 a6 00 6f 93 08 fa d7 b2 a8 fd aa b2 2c d8 6c e7 64 c2 02 20 09 74 b8 ac a7 bf 51 db f5 41 50 d3 ... >,
// <Buffer 30 45 02 21 00 ef 25 3c 1f aa 39 e6 51 15 87 25 19 e5 f0 a3 3b be cf 43 0c 0f 35 cf 56 2b ea bb ad 4d a2 4d 8d 02 20 17 42 be 8e e4 98 12 a7 3a de a3 ... > ]
Check Input
let signatures = [
"304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801",
"3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501"
];
let sigs = signatures.map((signature) => {
return signature ? Buffer.from(signature, 'hex') : BITBOX.Script.opcodes.OP_0
})
let buf = BITBOX.Script.multisig.input.encode(sigs);
BITBOX.Script.multisig.input.check(buf);
// true
check P2MS input format more info
Encode Output
let arr = [
"02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1",
"0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a"
];
let pubKeys = arr.map((p) => { return Buffer.from(p, 'hex') })
let m = pubKeys.length
let buf = BITBOX.Script.multisig.output.encode(m, pubKeys);
// <Buffer 52 21 02 35 9c 6e 3f 04 ce fb f0 89 cf 1d 66 70 dc 47 c3 fb 4d f6 8e 2b ad 1f a5 a3 69 f9 ce 4b 42 bb d1 21 03 95 a9 d8 4d 47 d5 24 54 8f 79 f4 35 75 ... >
BITBOX.Script.toASM(buf);
// OP_2 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a OP_2 OP_CHECKMULTISIG
Decode Output
let asm = 'OP_2 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a OP_2 OP_CHECKMULTISIG';
let buf = BITBOX.Script.fromASM(asm);
BITBOX.Script.multisig.output.decode(buf);
// { m: 2,
// pubKeys:
// [ <Buffer 02 35 9c 6e 3f 04 ce fb f0 89 cf 1d 66 70 dc 47 c3 fb 4d f6 8e 2b ad 1f a5 a3 69 f9 ce 4b 42 bb d1>,
// <Buffer 03 95 a9 d8 4d 47 d5 24 54 8f 79 f4 35 75 8c 01 fa ec 5d a2 b7 e5 51 d3 b8 c9 95 b7 e0 63 26 ae 4a> ] }
Check Output
let arr = [
"02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1",
"0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a"
];
let pubKeys = arr.map((p) => { return Buffer.from(p, 'hex') })
let m = pubKeys.length
let buf = BITBOX.Script.multisig.output.encode(m, pubKeys);
BITBOX.Script.multisig.output.check(buf);
// true
check P2MS output format more info
P2SH
Encode Input
let redeemScriptSig = BITBOX.Script.fromASM("OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501");
let redeemScript = BITBOX.Script.fromASM("OP_2 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a OP_2 OP_CHECKMULTISIG");
let buf = BITBOX.Script.scriptHash.input.encode(redeemScriptSig, redeemScript);
// <Buffer 52 21 02 35 9c 6e 3f 04 ce fb f0 89 cf 1d 66 70 dc 47 c3 fb 4d f6 8e 2b ad 1f a5 a3 69 f9 ce 4b 42 bb d1 21 03 95 a9 d8 4d 47 d5 24 54 8f 79 f4 35 75 ... >
BITBOX.Script.toASM(buf)
// OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501 522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae
Decode Input
let asm = 'OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501 522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae';
let buf = BITBOX.Script.fromASM(asm);
BITBOX.Script.scriptHash.input.decode(buf);
// { redeemScript: <Buffer 52 21 02 35 9c 6e 3f 04 ce fb f0 89 cf 1d 66 70 dc 47 c3 fb 4d f6 8e 2b ad 1f a5 a3 69 f9 ce 4b 42 bb d1 21 03 95 a9 d8 4d 47 d5 24 54 8f 79 f4 35 75 ... >,
// redeemScriptSig: <Buffer 00 47 30 44 02 20 75 15 cf 14 7d 20 1f 41 10 92 e6 be 5a 64 a6 00 6f 93 08 fa d7 b2 a8 fd aa b2 2c d8 6c e7 64 c2 02 20 09 74 b8 ac a7 bf 51 db f5 41 ... > }
Check Input
let redeemScriptSig = BITBOX.Script.fromASM("OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501");
let redeemScript = BITBOX.Script.fromASM("OP_2 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a OP_2 OP_CHECKMULTISIG");
let buf = BITBOX.Script.scriptHash.input.encode(redeemScriptSig, redeemScript);
BITBOX.Script.scriptHash.input.check(buf);
// true
check P2SH input format more info
Encode Output
let redeemScript = BITBOX.Script.fromASM("OP_DUP OP_HASH160 aa4d7985c57e011a8b3dd8e0e5a73aaef41629c5 OP_EQUALVERIFY OP_CHECKSIG");
let scriptHash = BITBOX.Crypto.hash160(redeemScript);
let buf = BITBOX.Script.scriptHash.output.encode(scriptHash);
// <Buffer a9 14 1b 61 eb ed 0c 2a 16 c6 99 a9 9c 3d 5e f4 d0 8d e7 fb 1c b8 87>
BITBOX.Script.toASM(buf)
// OP_HASH160 1b61ebed0c2a16c699a99c3d5ef4d08de7fb1cb8 OP_EQUAL
Decode Output
let asm = 'OP_HASH160 1b61ebed0c2a16c699a99c3d5ef4d08de7fb1cb8 OP_EQUAL';
let buf = BITBOX.Script.fromASM(asm);
BITBOX.Script.scriptHash.output.decode(buf);
// <Buffer 1b 61 eb ed 0c 2a 16 c6 99 a9 9c 3d 5e f4 d0 8d e7 fb 1c b8>
Check Output
let redeemScript = BITBOX.Script.fromASM("OP_DUP OP_HASH160 aa4d7985c57e011a8b3dd8e0e5a73aaef41629c5 OP_EQUALVERIFY OP_CHECKSIG");
let scriptHash = BITBOX.Crypto.hash160(redeemScript);
let buf = BITBOX.Script.scriptHash.output.encode(scriptHash);
BITBOX.Script.scriptHash.output.check(buf);
// true
check P2SH output format more info
Classify
In addition to encoding/decoding and checking the format of inputs and outputs Script
can now also classify inputs and outputs.
Inputs
let pubkeyInput = "3045022100ba2c3b717e023966cb16df65ca83f77029e2a5b80c47c47b6956474ac9ff281302201d48ee3292439e284a6654a0e79ac2b8f7fff5c6b0d715260aa296501a239c6441";
BITBOX.Script.classifyInput(BITBOX.Script.fromASM(pubkeyInput));
// pubkey
let pubkeyhashInput = "30440220280d4a9954c5afe24089bdd545466bd7a8caad8b295e30de9d3cb5e56fccf64e022036663b2c53b5fac674b4b935b53e2a4ea88dfc71c9b879870976d82887542ab441 02969479fa9bea3082697dce683ac05b13ae63016b41d5ca1a450ad40f6c543751";
BITBOX.Script.classifyInput(BITBOX.Script.fromASM(pubkeyhashInput));
// pubkeyhash
let multisigInput = "OP_0 3045022100fe324541215798b2df68cbd44039615e23c506d4ec1a05572064392a98196b82022068c849fa6699206da2fc6d7848efc1d3804a5816d6293615fe34c1a7f34e1c2f01 3044022001ab168e80b863fdec694350b587339bb72a37108ac3c989849251444d13ebba02201811272023e3c1038478eb972a82d3ad431bfc2408e88e4da990f1a7ecbb263901 3045022100aaeb7204c17eee2f2c4ff1c9f8b39b79e75e7fbf33e92cc67ac51be8f15b75f90220659eee314a4943a6384d2b154fa5821ef7a084814d7ee2c6f9f7f0ffb53be34b01";
BITBOX.Script.classifyInput(BITBOX.Script.fromASM(multisigInput));
// multisig
let scripthashInput = "OP_0 304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801 3045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d140501 522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae";
BITBOX.Script.classifyInput(BITBOX.Script.fromASM(scripthashInput));
// scripthash
Outputs
let nullDataOutput = "OP_RETURN 424348466f7245766572796f6e65";
BITBOX.Script.classifyOutput(BITBOX.Script.fromASM(nullDataOutput));
// nulldata
let pubkeyOutput = "02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 OP_CHECKSIG";
BITBOX.Script.classifyOutput(BITBOX.Script.fromASM(pubkeyOutput));
// pubkey
let pubkeyhashOutput = "OP_DUP OP_HASH160 aa4d7985c57e011a8b3dd8e0e5a73aaef41629c5 OP_EQUALVERIFY OP_CHECKSIG";
BITBOX.Script.classifyOutput(BITBOX.Script.fromASM(pubkeyhashOutput));
// pubkeyhash
let multisigOutput = "OP_2 02359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1 0395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a OP_2 OP_CHECKMULTISIG";
BITBOX.Script.classifyOutput(BITBOX.Script.fromASM(multisigOutput));
// multisig
let scripthashOutput = "OP_HASH160 722ff0bc2c3f47b35c20df646c395594da24e90e OP_EQUAL";
BITBOX.Script.classifyOutput(BITBOX.Script.fromASM(scripthashOutput));
// scripthash
Summary
BITBOX Script
can now encode/decode, check the format of and classify inputs/outputs for P2PK, P2PKH, P2MS, P2SH and nullData transactions as well as supporting all the new OP codes. Next stop May 15th!
Donations
As always donations are welcome at: bitcoincash:qr8zpz5nrw0laee42u3ce3tds8n9sgxdc5qrnzlx5a