-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(rgbpp-sdk/btc): btc rgbpp transactions #26
Conversation
I found that the constructor of |
You're right, the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other codes LGTM.
3199c74
to
06c4eb1
Compare
48e265b
to
b93177b
Compare
|
||
const liveCell = await props.ckbCollector.getLiveCell(input.previousOutput); | ||
const isRgbppLock = isRgbppLockCell(liveCell.output, isCkbMainnet); | ||
const isRgbppTimeLock = isBtcTimeLockCell(liveCell.output, isCkbMainnet); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this line unused?
Main changes
networkType
prop from BTC APIsNext
Details
The sendUtxos() API
The sendRgbppUtxos() API
Here's a L1 -> L1 example transaction, showing how A transfers 400 RGBPP to B:
Since A is transferring some RGBPP assets to B, when building the BtcVirtualTx, you should specify the
address
forRGBPP_UTXO_2
, otherwise by default the address of the RGBPP_UTXO_2 will be set to A (as thefrom
prop specified):Output markers
This output with the
fixed
mark will NOT be deducted for satoshi/fee collection:This output is marked as
protected
, so the free satoshi in this output can be deducted (but this output cannot be removed):This output without any marker can be deducted during the satoshi/fee collection process, and this output can be removed from the transaction if necessary:
Satoshi/fee collection
The satoshi/fee collection process has been rewritten for comlex situations like in a RGBPP transaction:
(output.protected == true && output.fixed == false)
condition, the collection process will try to collect free satoshi from those outputs. An output's free satoshi isoutput.value - output.minUtxoSatoshi
.(sum(inputs) > sum(outputs))
, then the change satoshi can be returned in the first output that matches the(output.fixed == false && output.address == changeAddress)
condition.BTW, since the entire collection process has been rewritten, I believe we need to conduct thorough tests on the fee estimation part. Although I have added many tests to cover various scenarios, there may still be additional issues that need to be discovered. Therefore, we could greatly benefit from more tests and reviews. cc @Dawn-github.