Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Enable Node's Withdrawal Address to Withdraw RPL #282

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions contracts/contract/RocketBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,13 @@ abstract contract RocketBase {
_;
}



/**
* @dev Throws if called by any sender that isn't a registered node or the their respective withdrawal address
*/
modifier onlyRegisteredNodeOrWithdrawalAddress(address _nodeAddress) {
require(getBool(keccak256(abi.encodePacked("node.exists", _nodeAddress))) || _nodeAddress == rocketStorage.getNodeWithdrawalAddress(_nodeAddress), "Invalid minipool owner");
_;
}

/*** Methods **********************************************************/

Expand Down
4 changes: 2 additions & 2 deletions contracts/contract/node/RocketNodeStaking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,10 @@ contract RocketNodeStaking is RocketBase, RocketNodeStakingInterface {
}

/// @notice Withdraw staked RPL back to the node account
/// Only accepts calls from registered nodes
/// Only accepts calls from registered nodes or their respective withdrawal addresses
/// Withdraws to withdrawal address if set, otherwise defaults to node address
/// @param _amount The amount of RPL to withdraw
function withdrawRPL(uint256 _amount) override external onlyLatestContract("rocketNodeStaking", address(this)) onlyRegisteredNode(msg.sender) {
function withdrawRPL(uint256 _amount) override external onlyLatestContract("rocketNodeStaking", address(this)) onlyRegisteredNodeOrWithdrawalAddress(msg.sender) {
// Load contracts
RocketDAOProtocolSettingsRewardsInterface rocketDAOProtocolSettingsRewards = RocketDAOProtocolSettingsRewardsInterface(getContractAddress("rocketDAOProtocolSettingsRewards"));
RocketVaultInterface rocketVault = RocketVaultInterface(getContractAddress("rocketVault"));
Expand Down