Giveth / vaultcontroller

Vault Architecture
GNU General Public License v3.0
0 stars 3 forks source link

Cancelling the root vault causes founds to be lost #38

Open adria0 opened 7 years ago

adria0 commented 7 years ago

Since in root vault the parentVault is 0, cancelVault() will generate an primaryVault.authorizePayment and balance will be sent to 0 address

    function cancelVault() onlyOwnerOrParent returns (bool _finished) {

        // If ! initialized, just mark it as cancelled and return
        if (address(primaryVault) == 0) {
            canceled = true;
        }

        if (canceled) return true; //If it is already canceled, just return.

        cancelAllChildVaults();

        if (msg.gas < GAS_LIMIT) return false;

        uint vaultBalance = primaryVault.getBalance();

        canceled = true;
        highestAcceptableBalance = 0;
        lowestAcceptableBalance = 0;
        owner = parentVaultController;
        if (vaultBalance > 0) {
            primaryVault.authorizePayment(
              "CANCEL CHILD VAULT",
              bytes32(msg.sender),
              address(parentVault),
              vaultBalance,
              0
            );
            VaultCanceled(msg.sender);
        }

        // Be sure that there is nothing remaining in the vault
        if (primaryVault.getBalance() > 0) throw;

        return true;
    }