The custom transaction serialization presented is for Kaspa.
The base unit in Kaspa is the KAS and the smallest unit used in raw transaction is the sompi: 1 KAS = 100000000 sompi.
Kaspa addresses begin with kaspa: followed by 61 base32 characters for a total of 67 bytes for Schnorr-signed and P2SH addresses. P2SH addresses are supported only as a send address by this app.
For ECDSA-signed addresses (supported by this app only as a send address), it begins with kaspa: followed by 63 bytes for a total of 69 bytes.
| Field | Size (bytes) | Description |
|---|---|---|
version |
2 | The version of the transaction being signed |
n_inputs |
1 | The number of inputs. Max 255. |
n_outputs |
1 | The number of outputs. Exactly 1 or 2. |
change_address_type |
1 | 0 if RECEIVE or 1 if CHANGE* |
change_address_index |
4 | 0x00000000 to 0xFFFFFFFF** |
account |
4 | 0x80000000 to 0xFFFFFFFF, normally should use 0x80000000 (the default account)*** |
* While this will be used for the change, the path may be either RECEIVE or CHANGE.
This is necessary in case the user wants to send the change back to the same address.
In this case, the change_address_type has to be set to RECEIVE.
** change_address_type and change_address_index are ignored if n_outputs == 1. If n_outputs == 2 then the path defined here must resolve to the same script_public_key in outputs[1].
*** account is the BIP44 account. A transaction can only come from a single account. Current Kaspa ecosystem only uses 0' (or 0x80000000) but support this is in anticipation of wider account-based support.
Total bytes: 46
| Field | Size (bytes) | Description |
|---|---|---|
address_type |
1 | 0x00 for RECEIVE or 0x01 for CHANGE address |
address_index |
4 | The index of this address in the derivation path |
value |
8 | The amount of KAS in sompi in this input |
index |
1 | The index of this outpoint |
prev_tx_id |
32 | The transaction ID in bytes |
Total bytes: 43 (max)
| Field | Size (bytes) | Description |
|---|---|---|
value |
8 | The amount of KAS in sompi that will go send to the address |
script_public_key |
35 | Schnorr: 0x20 + public_key (32 bytes) + 0xac ECDSA: 0x20 + public_key (33 bytes) + 0xab P2SH: 0xaa, 0x20 + script_hash (32 bytes) + 0x87 |
- Fee = (total inputs amount) - (total outputs amount)
- (total inputs amount) > (total outputs amount)
- There must be at least 1 input
- There must be exactly 1 or 2 outputs
- If there is only 1 output, it is assumed to be the
sendaddress - If there are 2 outputs, the first output is assumed to be the
sendaddress and the second output is where thechangewill go- The
script_public_keyfor the change must resolve to the same value that the change address type and index resolve to. This is validated in the ledger device.
- The
- If there is only 1 output, it is assumed to be the
Schnorr is used to sign transaction on the SECP-256k1 curve.
It is used to sign the SigHash.
The fee is the difference between the sum of input values and the sum of the output values.
- Kaspa Transaction: https://kaspa-mdbook.aspectron.com/transactions.html