Check Kaspa address network and script version before payout

A syntactically valid address can still point to the wrong Kaspa network or use an address version unsupported by the payout system.

Decode the entire address

Use the address library to parse the complete string and verify its checksum. Compare the parsed prefix with the configured network, then dispatch script construction according to the decoded version. Kaspa distinguishes public-key, ECDSA public-key and script-hash address versions. Treating each payload as a raw public key can produce an incorrect output.

expected network: mainnet
parsed prefix: kaspatest
payment decision: reject before constructing an output

Reject a valid testnet recipient

A kaspatest address entered into a mainnet invoice is a configuration mismatch. Return a specific error and keep the original input for the user to correct. Replacing the prefix as text does not validate the user's ownership or establish an intended mainnet destination.

Sources