rooch-network / rooch

VApp Container with Move Language
https://rooch.network
Apache License 2.0
156 stars 81 forks source link

check invalid pubkey handle in utxo contract #2096

Closed popcnt1 closed 2 weeks ago

popcnt1 commented 3 weeks ago

for p2pk script we may have some invalid pubkey:

https://www.blockchain.com/explorer/transactions/btc/41a3e9ee1910a2d40dd217bbc9fd3638c40d13c8fdda8a0aa9d49a2b4a199422

In utxo import cmd, using default address:

https://github.com/rooch-network/rooch/pull/2094

popcnt1 commented 2 weeks ago

@jolestar

in rooch-types/src/bitcoin/types.rs:

impl From<bitcoin::TxOut> for TxOut {
    fn from(tx_out: bitcoin::TxOut) -> Self {
        let address_opt = bitcoin::address::Payload::from_script(&tx_out.script_pubkey).ok();
        Self {
            value: tx_out.value.to_sat(),
            script_pubkey: tx_out.script_pubkey.into(),
            recipient_address: address_opt
                .map(|address| address.into())
                .unwrap_or_default(),
        }
    }
}

If we cannot get the addresss will use default(empty vec) , in move contract:

image

empty address will be transfer to bitcoin_move_addresss, as same as new changes in import process #2094 when we meet invalid address