utxostack / rgbpp-sdk

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

feat(ckb|example): Export `buildRgbppTransferTx` from rgbpp package and update L1 transfer example #216

Closed duanyytop closed 5 months ago

duanyytop commented 5 months ago

Changes

Function Signature

const buildRgbppTransferTx = async ({
  ckb: {
    collector,
    xudtTypeArgs,
    rgbppLockArgsList,
    transferAmount,
    ckbFeeRate,
  },
  btc: {
    fromBtcAddress,
    toBtcAddress,
    btcDataSource,
    fromPubkey,
    feeRate
  },
  isMainnet,
}: RgbppTransferTxParams): Promise<RgbppTransferTxResult>

The collector and btcDataSource will be constructed in the rgbpp-sdk-service with some necessary variables from the environment. The necessary request and response for the L1 transfer in the rgbpp-sdk-service are as follows:

interface RgbppTransferReq {
  // The transferred RGB++ xUDT type script args
  xudtTypeArgs: string;           
  // The rgbpp assets cell lock script args array whose data structure is: out_index | btc_tx_id
  rgbppLockArgsList: string[];   
  // The xUDT amount to be transferred
  transferAmount: Hex;     
  // The sender BTC address       
  fromBtcAddress: string;     
  // The receiver BTC address
  toBtcAddress: string;     
}

interface RgbppTransferResp {
  // The JSON string for the `BtcTransferVirtualTxResult`
  ckbVirtualTxResult: string;    
  // The BTC PSBT hex string which can be used to construct Bitcoin PSBT
  btcPsbtHex: Hex;           
}

Related PR

duanyytop commented 5 months ago

I fixed the conflicts between this branch and develop branch and then it needs to be reviewed again.