Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.

Commit 25aea1e

Browse files
authored
refactor(ckb): Remove 1CKB from BTC time cell capacity (#263)
* refactor: Remove 1CKB from btc time cell capacity * chore: Add changeset
1 parent a73806c commit 25aea1e

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

.changeset/sharp-wasps-punch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@rgbpp-sdk/ckb': minor
3+
---
4+
5+
refactor: Remove 1CKB from btc time cell capacity

packages/ckb/src/utils/ckb-tx.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ describe('ckb tx utils', () => {
4343
args: '0x06ec22c2def100bba3e295a1ff279c490d227151bf3166a4f3f008906c849399',
4444
};
4545
const capacity = calculateRgbppCellCapacity(xudtType);
46-
expect(BigInt(254_0000_0000)).toBe(capacity);
46+
expect(BigInt(253_0000_0000)).toBe(capacity);
4747

4848
const actual = calculateRgbppCellCapacity();
49-
expect(actual).toBe(BigInt(254_0000_0000));
49+
expect(actual).toBe(BigInt(253_0000_0000));
5050
});
5151

5252
it('isClusterSporeTypeSupported', () => {
@@ -109,7 +109,7 @@ describe('ckb tx utils', () => {
109109
expect(isTypeAssetSupported(xudtMainnetErrorType, true)).toBe(false);
110110
});
111111

112-
it('calculateRgbppCellCapacity', () => {
112+
it('generateUniqueTypeArgs', () => {
113113
const firstInput = {
114114
previousOutput: {
115115
txHash: '0x047b6894a0b7a4d7a73b1503d1ae35c51fc5fa6306776dcf22b1fb3daaa32a29',

packages/ckb/src/utils/ckb-tx.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const isLockArgsSizeExceeded = (args: Hex) => remove0x(args).length > LOC
6363
const BTC_TIME_CELL_INCREASED_SIZE = 95;
6464

6565
// For simplicity, we keep the capacity of the RGBPP cell the same as the BTC time cell
66-
// minimum occupied capacity and 1 ckb for transaction fee and assume UDT cell data size is 16bytes
66+
// minimum occupied capacity and assume UDT cell data size is 16bytes
6767
/**
6868
* RGB_lock:
6969
code_hash:
@@ -77,7 +77,7 @@ export const calculateRgbppCellCapacity = (xudtType?: CKBComponents.Script): big
7777
const udtTypeSize = 33 + typeArgsSize;
7878
const cellSize =
7979
RGBPP_LOCK_SIZE + udtTypeSize + CELL_CAPACITY_SIZE + UDT_CELL_DATA_SIZE + BTC_TIME_CELL_INCREASED_SIZE;
80-
return BigInt(cellSize + 1) * CKB_UNIT;
80+
return BigInt(cellSize) * CKB_UNIT;
8181
};
8282

8383
// Minimum occupied capacity and 1 ckb for transaction fee

packages/ckb/src/utils/rgbpp.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { BTCTestnetType, Hex, IndexerCell, RgbppCkbVirtualTx, RgbppTokenInfo, Sp
33
import { append0x, remove0x, reverseHex, u32ToLe, u8ToHex, utf8ToHex } from './hex';
44
import {
55
BTC_JUMP_CONFIRMATION_BLOCKS,
6-
CKB_UNIT,
76
RGBPP_TX_ID_PLACEHOLDER,
87
RGBPP_TX_INPUTS_MAX_LENGTH,
98
RGBPP_TX_WITNESS_MAX_SIZE,
@@ -286,6 +285,6 @@ export const isRgbppCapacitySufficientForChange = (
286285
sumUdtInputsCapacity: bigint,
287286
receiverOutputCapacity: bigint,
288287
): boolean => {
289-
const rgbppOccupiedCapacity = calculateRgbppCellCapacity() - CKB_UNIT;
288+
const rgbppOccupiedCapacity = calculateRgbppCellCapacity();
290289
return sumUdtInputsCapacity > receiverOutputCapacity + rgbppOccupiedCapacity;
291290
};

0 commit comments

Comments
 (0)