Conversation
thepiwo
left a comment
There was a problem hiding this comment.
looks good to me, didn't check in detail
| """ | ||
| @spec our_offchain_account_balance(ChannelStatePeer.t()) :: non_neg_integer() | ||
| def our_offchain_account_balance(%ChannelStatePeer{role: :delegate}) do | ||
| throw({:error, "#{__MODULE__}: Delagate doesn't have a balance"}) |
There was a problem hiding this comment.
Are the throws handled anywhere and can they be replaced with regular {:error, _} returns?
There was a problem hiding this comment.
This should only throw due to programmer error. It doesn't make sense to take a balance of delegate. It makes even less sens to get foreign_offchain_account_balance when ChannelStatePeer is for delegate.
There was a problem hiding this comment.
We use this functions only in places where it's know the ChannelStatePeer.role is not delegate.
gorbak25
left a comment
There was a problem hiding this comment.
Good code, some small typos.
| def receive_half_signed_tx(_, _, _, _opts \\ %{}) | ||
|
|
||
| def receive_half_signed_tx(%ChannelStatePeer{role: :delegate}, _, _, _) do | ||
| {:error, "#{__MODULE__}: Deleagte can't handle half_signed_txs"} |
| tx, | ||
| privkey, | ||
| opts \\ %{} | ||
| opts |
There was a problem hiding this comment.
By default no additional options should be passed for update validation.
| Keys.sign_priv_key() | ||
| ) :: {:ok, ChannelStatePeer.t(), SignedTx.t()} | error() | ||
| def receive_close_tx(%ChannelStatePeer{role: :delegate}, _, _, _, _) do | ||
| {:error, "#{__MODULE__}: Deleagte can't receive close tx"} |
| Keys.sign_priv_key() | ||
| ) :: {:ok, ChannelStatePeer.t(), SignedTx.t()} | error() | ||
| def solo_close(%ChannelStatePeer{role: :delegate}, _, _, _) do | ||
| {:error, "#{__MODULE__}: Delagate can't solo close"} |
| offchain_tx: ChannelTransaction.dispute_payload(most_recent_tx) | ||
| }, | ||
| our_pubkey(peer_state), | ||
| pubkey, |
There was a problem hiding this comment.
If the role is :initiator or :responder we should check that pubkey == our_pubkey(peer_state)
| }, | ||
| fee, | ||
| nonce, | ||
| pubkey, |
| @spec settle(ChannelStatePeer.t(), non_neg_integer(), non_neg_integer(), Keys.sign_priv_key()) :: | ||
| {:ok, SignedTx.t()} | error() | ||
| def settle(%ChannelStatePeer{role: :delegate}, _, _, _) do | ||
| {:error, "#{__MODULE__}: Deleagte can't settle"} |
Resolves #757