atomicDEX-API icon indicating copy to clipboard operation
atomicDEX-API copied to clipboard

P2PK input cause taker fee validation to fail

Open Alrighttt opened this issue 11 months ago • 0 comments

Using a P2PK("pay to public key" or <pubkey> OP_CHECKSIG input for sending taker fee will result in maker validation of the taker fee to fail with the following error.

{
    "timestamp": 1738765718666,
    "event": {
        "type": "TakerFeeValidateFailed",
        "data": {
            "error": "maker_swap:777] utxo_common:2029] utxo_common:1970] None instruction 1 of script Script { data: 47304402200d8864318a9d6c1fcbfa1819010214c42dc1f9e82ca55059121e48f478f3e11c0220609552cf06cf55d767d92fefc0753fdde8b4924866034054bd38b081c6862fca01 }"
        }
    }
},

https://github.com/KomodoPlatform/komodo-defi-framework/blob/ff0eefcdccfa9b48161052ed95d8185220ba2cbd/mm2src/coins/utxo/utxo_common.rs#L1971

The taker fee validation is attempting to validate that all inputs have been signed by the taker's pubkey. If any of these inputs are P2PK(as opposed to P2PKH or P2WPKH), the validation will fail unexpectedly.

If this check will remain in place, the check_all_utxo_inputs_signed_by_pub function must account for P2PK inputs. This function should recalculate the sighash for this input and validate the provided signature against the expected public key.

Alrighttt avatar Feb 05 '25 15:02 Alrighttt