Skip to content

Commit

Permalink
feat(cardano): add key hash stake credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmisiak committed Nov 22, 2021
1 parent 733dc7b commit fae1459
Show file tree
Hide file tree
Showing 12 changed files with 723 additions and 55 deletions.
2 changes: 2 additions & 0 deletions common/protob/messages-cardano.proto
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ message CardanoPoolParametersType {
optional bytes pool = 3; // pool hash
optional CardanoPoolParametersType pool_parameters = 4; // used for stake pool registration certificate
optional bytes script_hash = 5; // stake credential script hash
optional bytes key_hash = 6; // stake credential key hash
}

/**
Expand All @@ -320,6 +321,7 @@ message CardanoTxWithdrawal {
repeated uint32 path = 1; // stake credential key path
required uint64 amount = 2;
optional bytes script_hash = 3; // stake credential script hash
optional bytes key_hash = 4; // stake credential key hash
}

/**
Expand Down
158 changes: 158 additions & 0 deletions common/tests/fixtures/cardano/sign_tx.failed.json
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,45 @@
"error_message": "Invalid certificate"
}
},
{
"description": "Certificate has key hash",
"parameters": {
"protocol_magic": 764824073,
"network_id": 1,
"fee": 42,
"ttl": 10,
"certificates": [
{
"type": 0,
"key_hash": "29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd"
}
],
"withdrawals": [],
"auxiliary_data": null,
"inputs": [
{
"path": "m/1852'/1815'/0'/0/0",
"prev_hash": "3b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b7",
"prev_index": 0
}
],
"outputs": [
{
"address": "Ae2tdPwUPEZCanmBz5g2GEwFqKTKpNJcGYPKfDxoNeKZ8bRHr8366kseiK2",
"amount": "3003112"
}
],
"mint": [],
"script_data_hash": null,
"collateral_inputs": [],
"required_signers": [],
"signing_mode": "ORDINARY_TRANSACTION",
"additional_witness_requests": []
},
"result": {
"error_message": "Invalid certificate"
}
},
{
"description": "Certificate has both path and script_hash",
"parameters": {
Expand Down Expand Up @@ -713,6 +752,46 @@
"error_message": "Invalid certificate"
}
},
{
"description": "Certificate has both path and key_hash",
"parameters": {
"protocol_magic": 764824073,
"network_id": 1,
"fee": 42,
"ttl": 10,
"certificates": [
{
"type": 0,
"path": "m/1852'/1815'/0'/0/0",
"key_hash": "29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd"
}
],
"withdrawals": [],
"auxiliary_data": null,
"inputs": [
{
"path": "m/1852'/1815'/0'/0/0",
"prev_hash": "3b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b7",
"prev_index": 0
}
],
"outputs": [
{
"address": "Ae2tdPwUPEZCanmBz5g2GEwFqKTKpNJcGYPKfDxoNeKZ8bRHr8366kseiK2",
"amount": "3003112"
}
],
"mint": [],
"script_data_hash": null,
"collateral_inputs": [],
"required_signers": [],
"signing_mode": "ORDINARY_TRANSACTION",
"additional_witness_requests": []
},
"result": {
"error_message": "Invalid certificate"
}
},
{
"description": "Certificate has invalid pool size",
"parameters": {
Expand Down Expand Up @@ -870,6 +949,45 @@
"error_message": "Invalid withdrawal"
}
},
{
"description": "Withdrawal has key hash",
"parameters": {
"protocol_magic": 764824073,
"network_id": 1,
"fee": 42,
"ttl": 10,
"certificates": [],
"withdrawals": [
{
"key_hash": "29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd",
"amount": "1000"
}
],
"auxiliary_data": null,
"inputs": [
{
"path": "m/1852'/1815'/0'/0/0",
"prev_hash": "3b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b7",
"prev_index": 0
}
],
"outputs": [
{
"address": "Ae2tdPwUPEZCanmBz5g2GEwFqKTKpNJcGYPKfDxoNeKZ8bRHr8366kseiK2",
"amount": "3003112"
}
],
"mint": [],
"script_data_hash": null,
"collateral_inputs": [],
"required_signers": [],
"signing_mode": "ORDINARY_TRANSACTION",
"additional_witness_requests": []
},
"result": {
"error_message": "Invalid withdrawal"
}
},
{
"description": "Withdrawal amount is too large",
"parameters": {
Expand Down Expand Up @@ -949,6 +1067,46 @@
"error_message": "Invalid withdrawal"
}
},
{
"description": "Withdrawal contains both path and key_hash",
"parameters": {
"protocol_magic": 764824073,
"network_id": 1,
"fee": 42,
"ttl": 10,
"certificates": [],
"withdrawals": [
{
"path": "m/1852'/1815'/0'/2/0",
"amount": "1000",
"key_hash": "29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd"
}
],
"auxiliary_data": null,
"inputs": [
{
"path": "m/1852'/1815'/0'/0/0",
"prev_hash": "3b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b7",
"prev_index": 0
}
],
"outputs": [
{
"address": "Ae2tdPwUPEZCanmBz5g2GEwFqKTKpNJcGYPKfDxoNeKZ8bRHr8366kseiK2",
"amount": "3003112"
}
],
"mint": [],
"script_data_hash": null,
"collateral_inputs": [],
"required_signers": [],
"signing_mode": "ORDINARY_TRANSACTION",
"additional_witness_requests": []
},
"result": {
"error_message": "Invalid withdrawal"
}
},
{
"description": "Auxiliary data hash has incorrect length",
"parameters": {
Expand Down
Loading

0 comments on commit fae1459

Please sign in to comment.