Struct raiden_rs::raiden_api::api::Api
source · pub struct Api {
pub raiden: Arc<Raiden>,
/* private fields */
}Expand description
The interface which enables initiating payments and interacting with contracts.
Fields§
§raiden: Arc<Raiden>Implementations§
source§impl Api
impl Api
sourcepub fn new(
raiden: Arc<Raiden>,
transition_service: Arc<Transitioner>,
payments_registry: Arc<RwLock<PaymentsRegistry>>
) -> Api
pub fn new( raiden: Arc<Raiden>, transition_service: Arc<Transitioner>, payments_registry: Arc<RwLock<PaymentsRegistry>> ) -> Api
Creates a new instance of Api
sourcepub async fn create_channel(
&self,
account: Account<Http>,
registry_address: H160,
token_address: H160,
partner_address: H160,
settle_timeout: Option<U64>,
reveal_timeout: Option<U64>,
retry_timeout: Option<u64>
) -> Result<U256, ApiError>
pub async fn create_channel( &self, account: Account<Http>, registry_address: H160, token_address: H160, partner_address: H160, settle_timeout: Option<U64>, reveal_timeout: Option<U64>, retry_timeout: Option<u64> ) -> Result<U256, ApiError>
Creates a new channel with the current account being one participant.
sourcepub async fn update_channel(
&self,
account: Account<Http>,
registry_address: H160,
token_address: H160,
partner_address: H160,
reveal_timeout: Option<U64>,
total_deposit: Option<U256>,
total_withdraw: Option<U256>,
state: Option<ChannelStatus>,
retry_timeout: Option<u64>
) -> Result<(), ApiError>
pub async fn update_channel( &self, account: Account<Http>, registry_address: H160, token_address: H160, partner_address: H160, reveal_timeout: Option<U64>, total_deposit: Option<U256>, total_withdraw: Option<U256>, state: Option<ChannelStatus>, retry_timeout: Option<u64> ) -> Result<(), ApiError>
Updates a channel state on-chain depending on the parameters passed.
Only one optional parameter is allowed to be set in a single call to determine what the call will do.
reveal_timeout: Sets the reveal timeout of a channel.
total_deposit: Deposit the defined amount into the channel.
total_withdraw: Initiates a withdraw with partner.
state: Alters the state of the channel. For example: closed.
pub async fn channel_deposit( &self, account: Account<Http>, channel_state: &ChannelState, total_deposit: U256, retry_timeout: Option<u64> ) -> Result<(), ApiError>
sourcepub async fn channel_withdraw(
&self,
channel_state: &ChannelState,
total_withdraw: U256
) -> Result<(), ApiError>
pub async fn channel_withdraw( &self, channel_state: &ChannelState, total_withdraw: U256 ) -> Result<(), ApiError>
Initiate a withdraw from channel’s balance.
sourcepub async fn channel_reveal_timeout(
&self,
channel_state: &ChannelState,
reveal_timeout: U64
) -> Result<(), ApiError>
pub async fn channel_reveal_timeout( &self, channel_state: &ChannelState, reveal_timeout: U64 ) -> Result<(), ApiError>
Set the channel’s reveal timeout.
sourcepub async fn channel_close(
&self,
registry_address: H160,
channel_state: &ChannelState
) -> Result<(), ApiError>
pub async fn channel_close( &self, registry_address: H160, channel_state: &ChannelState ) -> Result<(), ApiError>
Close a channel.
sourcepub async fn token_network_register(
&self,
registry_address: H160,
token_address: H160
) -> Result<H160, ApiError>
pub async fn token_network_register( &self, registry_address: H160, token_address: H160 ) -> Result<H160, ApiError>
Register a new token network.
sourcepub async fn token_network_leave(
&self,
registry_address: H160,
token_address: H160
) -> Result<Vec<ChannelState>, ApiError>
pub async fn token_network_leave( &self, registry_address: H160, token_address: H160 ) -> Result<Vec<ChannelState>, ApiError>
Leave token network by token address.
sourcepub async fn channel_batch_close(
&self,
registry_address: H160,
token_address: H160,
partners: Vec<H160>,
retry_timeout: Option<u64>,
coop_settle: bool
) -> Result<(), ApiError>
pub async fn channel_batch_close( &self, registry_address: H160, token_address: H160, partners: Vec<H160>, retry_timeout: Option<u64>, coop_settle: bool ) -> Result<(), ApiError>
Batch close channels.
This will attempt to cooperatively settle a channel and then close it.
sourcepub async fn batch_coop_settle(
&self,
channels: Vec<&ChannelState>,
retry_timeout: Option<u64>
) -> Result<Vec<ChannelState>, ApiError>
pub async fn batch_coop_settle( &self, channels: Vec<&ChannelState>, retry_timeout: Option<u64> ) -> Result<Vec<ChannelState>, ApiError>
Batch cooperative settle
sourcepub async fn deposit_to_udc(
&self,
user_deposit_address: H160,
new_total_deposit: U256
) -> Result<(), ApiError>
pub async fn deposit_to_udc( &self, user_deposit_address: H160, new_total_deposit: U256 ) -> Result<(), ApiError>
Deposit some amount to the UserDeposit contract.
sourcepub async fn plan_withdraw_from_udc(
&self,
user_deposit_address: H160,
planned_withdraw_amount: U256
) -> Result<(), ApiError>
pub async fn plan_withdraw_from_udc( &self, user_deposit_address: H160, planned_withdraw_amount: U256 ) -> Result<(), ApiError>
Register desire to withdraw from the UserDeposit contract.
The amount stated will be withdrawable after certain blocks have passed.
sourcepub async fn withdraw_from_udc(
&self,
user_deposit_address: H160,
withdraw_amount: U256
) -> Result<(), ApiError>
pub async fn withdraw_from_udc( &self, user_deposit_address: H160, withdraw_amount: U256 ) -> Result<(), ApiError>
Actually perform the previously planned withdraw from the UserDeposit contract.
sourcepub async fn initiate_payment(
&self,
account: Account<Http>,
token_network_registry_address: H160,
secret_registry_address: H160,
token_address: H160,
partner_address: H160,
amount: U256,
payment_identifier: Option<U64>,
secret: Option<String>,
secret_hash: Option<H256>,
lock_timeout: Option<U64>
) -> Result<Payment, ApiError>
pub async fn initiate_payment( &self, account: Account<Http>, token_network_registry_address: H160, secret_registry_address: H160, token_address: H160, partner_address: H160, amount: U256, payment_identifier: Option<U64>, secret: Option<String>, secret_hash: Option<H256>, lock_timeout: Option<U64> ) -> Result<Payment, ApiError>
Initiate a payment to partner.