If beneficiaryList
is an array or addresses, and you're looping through the array, you'd simply check it against msg.sender
and skip it if it matches. So something like:
uint splitValue = uint(msg.value/beneficiaryList.length);
uint l = beneficiaryList.length;
for (uint index = 0; index < l; index++) {
address b = beneficiaryList[index];
if (b != msg.sender) {
b.transfer(splitValue);
}
}
I can't help with the final two lines as I can't tell what they're supposed to do.
BTW, be aware that there are a few code smells in what you're doing that may indicate that you should change your approach. Unless you know that beneficiaryList
will have a limited length, your code may run out of gas, and you may never be able to run it because it exceeds the block gas limit. Also, since the beneficiary address may be the address of a contract and transfer
will call the default payment function it, it could throw an exception or cause you to run out of gas, and which will also prevent anybody from using the function. Depending on the other code it may also have reentrancy issues. Consider using the withdrawal pattern instead.