stampchain-io / btc_stamps

Bitcoin Stamps Indexer
https://stampchain.io
GNU Affero General Public License v3.0
9 stars 2 forks source link

SRC-20 TOKEN LOCK - Lock user balances until given block height - #292

Open reinamora137 opened 1 month ago

reinamora137 commented 1 month ago

*Add the ability for transfers to send to an address that are locked until x block height

This is a consensus change that will need to be approved amongst all indexers. This will require a locked balance column in the src20valid table for each wallet, and an unlock block for each amount locked. We would need to consider multiple unlock heights for each amt, and multiple tokens that are locked in each wallet.

If a user has a locked balance they will be unable to transfer - any incoming transfers for that address would be invalidated by the indexer.

reinamora137 commented 2 weeks ago
{
 "p": "SRC-20",
 "op": "BULK_XFER",
 "tick": "LUFFY",
 "transactions": [
   {"amt": "1000", "dest": "dest1", "lock_amt": "10", "unlock_block": "899999"},
   {"amt": "100", "dest": "dest2", "lock_amt": "1", "unlock_block": "899999"}
 ]
}
reinamora137 commented 1 week ago

Perhaps unlocking could be accomplished at the BTC core transaction layer in a psbt transaction? Not 100% sure this is needed at the protocol level given future potential of using psbt..??

JavierCervilla commented 1 week ago

the point with bitcoin timelock is that as i have understanded the transaction cannot be mined until this specific block so the indexer doesn't know if the tx has been sent to the mempool and is waiting to be included in a block, so user can spend that tokens in other transaction and the locking has not any effect