Skip to content

Commit ab671f2

Browse files
chore(utxo-coredao): apply changes
TICKET: BTC-1578
1 parent 774bcce commit ab671f2

File tree

2 files changed

+2
-79
lines changed

2 files changed

+2
-79
lines changed

modules/utxo-coredao/src/opReturn.ts

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ export function createCoreDaoOpReturnOutputScript({
5656
*
5757
* The OP_RETURN output should contain all staking information in order, and be composed in the following format:
5858
*
59-
* OP_RETURN: identifier 0x6a
60-
* LENGTH: which represents the total byte length after the OP_RETURN opcode. Note that all data has to be pushed with its appropriate size byte(s). [1]
6159
* Satoshi Plus Identifier: (SAT+) 4 bytes
6260
* Version: (0x01) 1 byte
6361
* Chain ID: (0x045b (1115) for Core Testnet and 0x045c (1116) for Core Mainnet) 2 bytes
@@ -67,13 +65,12 @@ export function createCoreDaoOpReturnOutputScript({
6765
* (Optional) RedeemScript
6866
* (Optional) Timelock: 4 bytes
6967
*
70-
* [1] Any bytes bigger than or equal to 0x4c is pushed by using 0x4c (ie. OP_PUSHDATA)
71-
* followed by the length followed by the data (byte[80] -> OP_PUSHDATA + 80 + byte[80])
72-
*
7368
* Either RedeemScript or Timelock must be available, the purpose is to allow relayer to
7469
* obtain the RedeemScript and submit transactions on Core. If a RedeemScript is provided,
7570
* relayer will use it directly. Otherwise, relayer will construct the redeem script based
7671
* on the timelock and the information in the transaction inputs.
72+
*
73+
* Note that any length > 80 bytes wont be relayed by nodes and therefore we will throw an error.
7774
*/
7875
if (version < 0 || version > 255) {
7976
throw new Error('Invalid version - out of range');
@@ -197,18 +194,3 @@ export function parseCoreDaoOpReturnOutputScript(script: Buffer): OpReturnParams
197194
return { ...baseParams, redeemScript: Buffer.from(dataBuffer.subarray(offset)) };
198195
}
199196
}
200-
201-
/**
202-
* Check that the params are valid and that they make the given script
203-
* @param script
204-
* @param params
205-
*/
206-
export function verifyCoreDaoOpReturnOutputScript(script: Buffer, params: OpReturnParams): boolean {
207-
try {
208-
parseCoreDaoOpReturnOutputScript(script);
209-
const inferredScript = createCoreDaoOpReturnOutputScript(params);
210-
return inferredScript.equals(script);
211-
} catch (e) {
212-
return false;
213-
}
214-
}

modules/utxo-coredao/test/unit/opReturn.ts

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ import * as assert from 'assert';
22
import {
33
CORE_DAO_MAINNET_CHAIN_ID,
44
CORE_DAO_SATOSHI_PLUS_IDENTIFIER,
5-
CORE_DAO_TESTNET_CHAIN_ID,
65
createCoreDaoOpReturnOutputScript,
76
decodeTimelock,
87
encodeTimelock,
98
parseCoreDaoOpReturnOutputScript,
10-
verifyCoreDaoOpReturnOutputScript,
119
} from '../../src';
1210
import { testutil } from '@bitgo/utxo-lib';
1311

@@ -268,61 +266,4 @@ describe('OP_RETURN', function () {
268266
assert.throws(() => parseCoreDaoOpReturnOutputScript(Buffer.from(script, 'hex')));
269267
});
270268
});
271-
272-
describe('verifyCoreDaoOpReturnOutputScript', function () {
273-
it('should return true for a valid script with a redeem script', function () {
274-
const params = {
275-
version: validVersion,
276-
chainId: validChainId,
277-
delegator: validDelegator,
278-
validator: validValidator,
279-
fee: validFee,
280-
redeemScript: validRedeemScript,
281-
};
282-
const script = createCoreDaoOpReturnOutputScript(params);
283-
assert.strictEqual(verifyCoreDaoOpReturnOutputScript(script, params), true);
284-
});
285-
286-
it('should return true for a valid script with a timelock', function () {
287-
const params = {
288-
version: validVersion,
289-
chainId: validChainId,
290-
delegator: validDelegator,
291-
validator: validValidator,
292-
fee: validFee,
293-
timelock: validTimelock,
294-
};
295-
const script = createCoreDaoOpReturnOutputScript(params);
296-
assert.strictEqual(verifyCoreDaoOpReturnOutputScript(script, params), true);
297-
});
298-
299-
it('should return false when they are not equivalent', function () {
300-
const params = {
301-
version: validVersion,
302-
chainId: validChainId,
303-
delegator: validDelegator,
304-
validator: validValidator,
305-
fee: validFee,
306-
redeemScript: validRedeemScript,
307-
};
308-
const script = createCoreDaoOpReturnOutputScript(params);
309-
// Change the version
310-
params.version = 3;
311-
assert.strictEqual(verifyCoreDaoOpReturnOutputScript(script, params), false);
312-
});
313-
314-
it('should fail if they one is mainnet and one is testnet', function () {
315-
const params = {
316-
version: validVersion,
317-
chainId: CORE_DAO_MAINNET_CHAIN_ID,
318-
delegator: validDelegator,
319-
validator: validValidator,
320-
fee: validFee,
321-
timelock: validTimelock,
322-
};
323-
const script = createCoreDaoOpReturnOutputScript(params);
324-
params.chainId = CORE_DAO_TESTNET_CHAIN_ID;
325-
assert.strictEqual(verifyCoreDaoOpReturnOutputScript(script, params), false);
326-
});
327-
});
328269
});

0 commit comments

Comments
 (0)