@@ -133,6 +133,7 @@ import {
133133 bytesToHex ,
134134 bytesToIntLE ,
135135 bytesToUIntLE ,
136+ concatBytes ,
136137 intLEToBytes ,
137138 uint8ArrayEqual ,
138139} from '$lib/utils/uintarray'
@@ -188,6 +189,7 @@ enum ScriptWarning {
188189 codeseparator ,
189190 mixedCheckMultisigAndCheckSigAdd ,
190191 nonMinimalIf ,
192+ cat ,
191193}
192194
193195const warningMessageMap : Record < ScriptWarning , string > = {
@@ -201,6 +203,7 @@ const warningMessageMap: Record<ScriptWarning, string> = {
201203 [ ScriptWarning . mixedCheckMultisigAndCheckSigAdd ] :
202204 'OP_CHECKMULTISIG and OP_CHECKSIGADD cannot be used in the same script' ,
203205 [ ScriptWarning . nonMinimalIf ] : 'argument of OP_IF/NOTIF is not minimal' ,
206+ [ ScriptWarning . cat ] : 'OP_CAT is only available on signet' ,
204207}
205208
206209type ScriptErrorCode = keyof typeof errorMessageMap
@@ -417,7 +420,7 @@ export const evalScript = (
417420 const opcode = reader . readByte ( )
418421
419422 if (
420- opcode === OP_CAT ||
423+ // opcode === OP_CAT ||
421424 opcode === OP_SUBSTR ||
422425 opcode === OP_LEFT ||
423426 opcode === OP_RIGHT ||
@@ -823,6 +826,23 @@ export const evalScript = (
823826 }
824827 break
825828
829+ case OP_CAT :
830+ {
831+ if ( stack . length < 2 ) {
832+ return setStackSizeError ( 2 )
833+ }
834+ const vch1 = stacktop ( - 2 ) !
835+ const vch2 = stacktop ( - 1 ) !
836+ if ( vch1 . length + vch2 . length > MAX_SCRIPT_ELEMENT_SIZE ) {
837+ return setError ( SCRIPT_ERR_PUSH_SIZE )
838+ }
839+ popstack ( )
840+ popstack ( )
841+ stack . push ( concatBytes ( [ vch1 , vch2 ] ) )
842+ loopHighlight = { count : 1 , color : 'success' }
843+ }
844+ break
845+
826846 case OP_SIZE :
827847 // (in -- in size)
828848 if ( stack . length === 0 ) {
0 commit comments