Skip to content
Merged
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
4 changes: 0 additions & 4 deletions raiden/blockchain/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,6 @@ def decode_event_to_internal(event):
data['deposit'] = data['args']['total_deposit']
data['participant'] = to_canonical_address(data['args']['participant'])

elif data['event'] == ChannelEvent.WITHDRAW:
data['withdrawn_amount'] = data['args']['withdrawn_amount']
data['participant'] = to_canonical_address(data['args']['participant'])

elif data['event'] == ChannelEvent.BALANCE_PROOF_UPDATED:
data['closing_participant'] = to_canonical_address(data['args']['closing_participant'])

Expand Down
4 changes: 0 additions & 4 deletions raiden/blockchain_events_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,6 @@ def on_blockchain_event(raiden: 'RaidenService', event: Event):
elif data['event'] == ChannelEvent.DEPOSIT:
handle_channel_new_balance(raiden, event)

elif data['event'] == ChannelEvent.WITHDRAW:
# handle_channel_withdraw(raiden, event)
raise NotImplementedError('handle_channel_withdraw not implemented yet')

elif data['event'] == ChannelEvent.BALANCE_PROOF_UPDATED:
handle_channel_update_transfer(raiden, event)

Expand Down
9 changes: 0 additions & 9 deletions raiden/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,6 @@ class DepositMismatch(RaidenRecoverableError):
pass


class WithdrawMismatch(RaidenRecoverableError):
""" Raised when the requested withdraw is lower than actual channel withdraw

Used when a *user* tries to withdraw a given amount of token from a channel,
but the on-chain amount is already higher.
"""
pass


class InvalidAddress(RaidenError):
""" Raised when the user provided value is not a valid address. """
pass
Expand Down
112 changes: 0 additions & 112 deletions raiden/network/proxies/token_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
RaidenUnrecoverableError,
SamePeerAddress,
TransactionThrew,
WithdrawMismatch,
)
from raiden.network.proxies import Token
from raiden.network.proxies.utils import compare_contract_versions
Expand Down Expand Up @@ -845,81 +844,6 @@ def update_transfer(

log.info('updateNonClosingBalanceProof successful', **log_details)

def withdraw(
self,
channel_identifier: typing.ChannelID,
partner: typing.Address,
total_withdraw: int,
partner_signature: typing.Address,
signature: typing.Signature,
):
log_details = {
'token_network': pex(self.address),
'node': pex(self.node_address),
'partner': pex(partner),
'total_withdraw': total_withdraw,
'partner_signature': encode_hex(partner_signature),
'signature': encode_hex(signature),
}
log.debug('setTotalWithdraw called', **log_details)

self._check_for_outdated_channel(
self.node_address,
partner,
channel_identifier,
)

current_withdraw = self.detail_participant(
channel_identifier,
self.node_address,
partner,
).withdrawn
amount_to_withdraw = total_withdraw - current_withdraw

if total_withdraw < current_withdraw:
msg = (
f'Current withdraw ({current_withdraw}) is already larger '
f'than the requested total withdraw amount ({total_withdraw})',
)
log.critical(f'setTotalWithdraw failed, {msg}', **log_details)
raise WithdrawMismatch(msg)

if amount_to_withdraw <= 0:
msg = f'withdraw {amount_to_withdraw} must be greater than 0.'
log.critical(f'setTotalWithdraw failed, {msg}', **log_details)
raise ValueError(msg)

with self.channel_operations_lock[partner]:
# gaslimit below must be defined
raise NotImplementedError('feature temporarily disabled')

gas_limit = None
transaction_hash = self.proxy.transact(
'setTotalWithdraw',
gas_limit,
channel_identifier,
self.node_address,
total_withdraw,
partner_signature,
signature,
)
self.client.poll(transaction_hash)

receipt_or_none = check_transaction_threw(self.client, transaction_hash)
if receipt_or_none:
log.critical('setTotalWithdraw failed', **log_details)

self._check_channel_state_for_withdraw(
self.node_address,
partner,
channel_identifier,
total_withdraw,
)

raise TransactionThrew('Withdraw', receipt_or_none)

log.info('setTotalWithdraw successful', **log_details)

def unlock(
self,
channel_identifier: typing.ChannelID,
Expand Down Expand Up @@ -1224,42 +1148,6 @@ def _check_channel_state_for_deposit(
elif participant_details.our_details.deposit < deposit_amount:
raise RaidenUnrecoverableError('Deposit amount decreased')

def _check_channel_state_for_withdraw(
self,
participant1,
participant2,
channel_identifier,
withdraw_amount,
):
participant_details = self.detail_participants(
participant1,
participant2,
channel_identifier,
)

if participant_details.our_details.withdrawn > withdraw_amount:
raise WithdrawMismatch('Withdraw amount decreased')

channel_state = self._get_channel_state(
participant1=participant1,
participant2=participant2,
channel_identifier=channel_identifier,
)

if channel_state in (ChannelState.NONEXISTENT, ChannelState.REMOVED):
raise RaidenUnrecoverableError(
f'Channel between participant {participant1} '
f'and {participant2} does not exist',
)
elif channel_state == ChannelState.SETTLED:
raise RaidenUnrecoverableError(
'A settled channel cannot be closed',
)
elif channel_state == ChannelState.CLOSED:
raise RaidenRecoverableError(
'Channel is already closed',
)

def _check_channel_state_for_settle(self, participant1, participant2, channel_identifier):
channel_data = self.detail_channel(participant1, participant2, channel_identifier)
if channel_data.state == ChannelState.SETTLED:
Expand Down
44 changes: 0 additions & 44 deletions raiden/tests/integration/contracts/test_token_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,6 @@ def test_token_network_proxy_basics(

assert 'does not exist' in str(exc)

# Channel is not open yet
# with pytest.raises(RaidenUnrecoverableError) as exc:
# c1_token_network_proxy.withdraw(
# 1,
# c2_client.address,
# 1,
# EMPTY_HASH,
# EMPTY_HASH,
# )

# assert 'does not exist' in str(exc)

# actually create a channel
channel_identifier = c1_token_network_proxy.new_netting_channel(
c2_client.address,
Expand Down Expand Up @@ -203,16 +191,6 @@ def test_token_network_proxy_basics(
c2_client.address,
)

# no negative deposit
# with pytest.raises(WithdrawMismatch):
# c1_token_network_proxy.withdraw(
# channel_identifier,
# c2_client.address,
# -1,
# EMPTY_HASH,
# EMPTY_HASH,
# )

# balance proof by c2
transferred_amount = 3
balance_proof = BalanceProof(
Expand Down Expand Up @@ -332,28 +310,6 @@ def test_token_network_proxy_basics(
# No channel exists
assert 'getChannelIdentifier returned 0' in str(exc)

# with pytest.raises(RaidenUnrecoverableError) as exc:
# c1_token_network_proxy.withdraw(
# channel_identifier,
# c2_client.address,
# 5,
# decode_hex(balance_proof.signature),
# decode_hex(balance_proof.signature),
# )
# # No channel exists
# assert 'getChannelIdentifier returned 0' in str(exc)

# with pytest.raises(RaidenUnrecoverableError) as exc:
# c1_token_network_proxy.withdraw(
# channel_identifier,
# c2_client.address,
# 5,
# decode_hex(balance_proof.signature),
# decode_hex(balance_proof.signature),
# )
# # No channel exists
# assert 'getChannelIdentifier returned 0' in str(exc)


def test_token_network_proxy_update_transfer(
token_network_proxy,
Expand Down