ckb-cell / rgbpp-sdk

Utilities for Bitcoin and RGB++ asset integration
ISC License
53 stars 16 forks source link

The default rgbpp lock cell may need to be larger #41

Closed Flouse closed 5 months ago

Flouse commented 5 months ago

context: https://github.com/ckb-cell/rgbpp-sdk/blob/de884dd31842f55a6b051e73b7765b8311f05f6a/packages/ckb/src/utils/ckb-tx.ts#L12-L27

// RGBPP lock args
struct RGBPPLock {
  out_index: Uint32,
  btc_txid: Byte32,
}

// BTCTimeLock args
table BTCTimeLock {
  lock_script: Script,
  after: Uint32,
  btc_txid: Byte32,
}

Discussion

The default rgbpp lock cell may need to be larger, or when jumping from BTC to CKB (a.k.a. L1 -> L2, rpbpp_lock -> btc_time_lock), a paymaster cell will always be required.

duanyytop commented 5 months ago

https://github.com/ckb-cell/rgbpp-sdk/blob/77a4788d396c2a31817755ee0df6ea070fab5a3c/packages/ckb/src/utils/ckb-tx.ts#L19-L34

As shown in the above code, we estimate the size of the BTC time cell using the commonly used lock scripts (JoyID, Secp256k1/blake160, etc.)as a reference and leave redundancy as the capacity of the RGBPP cell. Thus paymaster cells will be not required.

If someone tries to use a larger lock script as the receiver of the BTC time cell, the SDK will throw an exception.