diff --git a/blockchain/README.md b/blockchain/README.md index 60ea87b..0cc75d5 100644 --- a/blockchain/README.md +++ b/blockchain/README.md @@ -7,8 +7,8 @@ ## What we measurement? -- Count step/effort to complete suspend all relevant fund/transaction. -- TBD +- Meantime to response. After the alert system triggers, how much time to freeze the fund that is relative to the fraudulent. +- Meantime to resolve. After the alert system triggers, how much time to freeze the fund that is relative to the fraudulent and funds are retrieved. diff --git a/contracts/libraries/Forest.sol b/contracts/libraries/Forest.sol index 9e8dc19..1171eb8 100644 --- a/contracts/libraries/Forest.sol +++ b/contracts/libraries/Forest.sol @@ -7,8 +7,6 @@ pragma solidity >=0.8.0 <0.9.0; * @author Sirawit Techavanitch (sirawit_tec@live4.utcc.ac.th) */ -// @TODO merging Tx (allowing only same root). - library Forest { /** * @dev Structure representing a transaction. @@ -139,4 +137,11 @@ library Forest { emit TransactionSpent(id, value); } + + /** + * @notice not suitable for use in production. + */ + function mergeTx(DAG storage self, bytes32 [] memory ids) internal { + // @TODO + } } diff --git a/contracts/libraries/UTXO.sol b/contracts/libraries/UTXO.sol index a930c80..c860589 100644 --- a/contracts/libraries/UTXO.sol +++ b/contracts/libraries/UTXO.sol @@ -4,13 +4,16 @@ pragma solidity >=0.8.0 <0.9.0; /** * @title Unspent Transaction Output Model (UTXO) * @notice This library implements the UTXO model for managing transactions on the blockchain. + * inspired from: + * https://gist.github.com/alex-miller-0/a5f4de3f811872b7272e66a3697f88de + * https://github.com/ProjectWyvern/wyvern-ethereum/blob/master/contracts/token/UTXORedeemableToken.sol + * https://github.com/olegfomenko/utxo * @author Sirawit Techavanitch (sirawit_tec@live4.utcc.ac.th) */ + import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol"; -// @TODO merging UTXO. - library UnspentTransactionOutput { using ECDSA for bytes32; using MessageHashUtils for bytes32; @@ -188,6 +191,15 @@ library UnspentTransactionOutput { emit TransactionConsumed(id); } + /** + * @notice merge multiple transaction into single transaction. + * @param self The UTXO storage. + * @param ids The array of the identifiers of the transaction to merge. + */ + function mergeTx(UTXO storage self, bytes32 [] memory ids) internal { + // @TODO + } + /** * @notice Retrieves the details of a transaction from the UTXO. * @param self The UTXO storage.