MCPcopy Create free account
hub / github.com/raiden-network/raiden / RaidenAPI

Class RaidenAPI

raiden/api/python.py:191–1443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189
190
191class RaidenAPI: # pragma: no unittest
192 # pylint: disable=too-many-public-methods
193
194 def __init__(self, raiden: "RaidenService"):
195 self.raiden = raiden
196
197 @property
198 def address(self) -> Address:
199 return self.raiden.address
200
201 @property
202 def notifications(self) -> Dict:
203 return self.raiden.notifications
204
205 @property
206 def config(self) -> PythonApiConfig:
207 return self.raiden.config.python_api
208
209 def _raise_for_invalid_channel_timeouts(
210 self, settle_timeout: BlockTimeout, reveal_timeout: BlockTimeout
211 ) -> None:
212 min_reveal_timeout = self.config.minimum_reveal_timeout
213 if reveal_timeout < min_reveal_timeout:
214 if reveal_timeout <= 0:
215 raise InvalidRevealTimeout("reveal_timeout should be larger than zero.")
216 else:
217 raise InvalidRevealTimeout(
218 "reveal_timeout is lower than the required minimum value of"
219 f" { min_reveal_timeout }"
220 )
221
222 if settle_timeout < reveal_timeout * 2:
223 raise InvalidSettleTimeout(
224 "`settle_timeout` can not be smaller than double the "
225 "`reveal_timeout`.\n "
226 "\n "
227 "The setting `reveal_timeout` determines the maximum number of "
228 "blocks it should take a transaction to be mined when the "
229 "blockchain is under congestion. This setting determines the "
230 "when a node must go on-chain to register a secret, and it is "
231 "therefore the lower bound of the lock expiration. The "
232 "`settle_timeout` determines when a channel can be settled "
233 "on-chain, for this operation to be safe all locks must have "
234 "been resolved, for this reason the `settle_timeout` has to be "
235 "larger than `reveal_timeout`."
236 )
237
238 def get_channel(
239 self,
240 registry_address: TokenNetworkRegistryAddress,
241 token_address: TokenAddress,
242 partner_address: Address,
243 ) -> NettingChannelState:
244 if not is_binary_address(token_address):
245 raise InvalidBinaryAddress("Expected binary address format for token in get_channel")
246
247 if not is_binary_address(partner_address):
248 raise InvalidBinaryAddress("Expected binary address format for partner in get_channel")

Calls

no outgoing calls