File tree Expand file tree Collapse file tree 1 file changed +1
-25
lines changed Expand file tree Collapse file tree 1 file changed +1
-25
lines changed Original file line number Diff line number Diff line change 88 generateSigningSerializationBch ,
99 utf8ToBin ,
1010 hexToBin ,
11- flattenBinArray ,
1211 LockingBytecodeType ,
1312 encodeTransactionOutput ,
1413 isHex ,
@@ -24,6 +23,7 @@ import {
2423 Op ,
2524 Script ,
2625 scriptToBytecode ,
26+ encodeNullDataScript ,
2727} from '@cashscript/utils' ;
2828import {
2929 Utxo ,
@@ -302,30 +302,6 @@ export function getNetworkPrefix(network: string): 'bitcoincash' | 'bchtest' | '
302302 }
303303}
304304
305- // ////////////////////////////////////////////////////////////////////////////
306- // For encoding OP_RETURN data (doesn't require BIP62.3 / MINIMALDATA)
307- function encodeNullDataScript ( chunks : ( number | Uint8Array ) [ ] ) : Uint8Array {
308- return flattenBinArray (
309- chunks . map ( ( chunk ) => {
310- if ( typeof chunk === 'number' ) {
311- return new Uint8Array ( [ chunk ] ) ;
312- }
313-
314- const pushdataOpcode = getPushDataOpcode ( chunk ) ;
315- return new Uint8Array ( [ ...pushdataOpcode , ...chunk ] ) ;
316- } ) ,
317- ) ;
318- }
319-
320- function getPushDataOpcode ( data : Uint8Array ) : Uint8Array {
321- const { byteLength } = data ;
322-
323- if ( byteLength === 0 ) return Uint8Array . from ( [ 0x4c , 0x00 ] ) ;
324- if ( byteLength < 76 ) return Uint8Array . from ( [ byteLength ] ) ;
325- if ( byteLength < 256 ) return Uint8Array . from ( [ 0x4c , byteLength ] ) ;
326- throw new Error ( 'Pushdata too large' ) ;
327- }
328-
329305const randomInt = ( ) : bigint => BigInt ( Math . floor ( Math . random ( ) * 10000 ) ) ;
330306
331307export const randomUtxo = ( defaults ?: Partial < Utxo > ) : Utxo => ( {
You can’t perform that action at this time.
0 commit comments