es/channel/index.js
function deposit (amount, sign, { onOnChainTx, onOwnDepositLocked, onDepositLocked } = {}) {
  return new Promise((resolve, reject) => {
    enqueueAction(
      this,
      (channel, state) => state.handler === handlers.channelOpen,
      (channel, state) => {
        send(channel, { jsonrpc: '2.0', method: 'channels.deposit', params: { amount } })
        return {
          handler: handlers.awaitingDepositTx,
          state: {
            sign,
            resolve,
            reject,
            onOnChainTx,
            onOwnDepositLocked,
            onDepositLocked
          }
        }
      }
    )
  })
}
function deposit (amount, sign, { onOnChainTx, onOwnDepositLocked, onDepositLocked } = {}) {
  return new Promise((resolve, reject) => {
    enqueueAction(
      this,
      (channel, state) => state.handler === handlers.channelOpen,
      (channel, state) => {
        send(channel, { jsonrpc: '2.0', method: 'channels.deposit', params: { amount } })
        return {
          handler: handlers.awaitingDepositTx,
          state: {
            sign,
            resolve,
            reject,
            onOnChainTx,
            onOwnDepositLocked,
            onDepositLocked
          }
        }
      }
    )
  })
}
function deposit ( amount , sign , { onOnChainTx , onOwnDepositLocked , onDepositLocked } = { } ) { return new Promise ( ( resolve , reject ) => { enqueueAction ( this , ( channel , state ) => state . handler === handlers . channelOpen , ( channel , state ) => { send ( channel , { jsonrpc : '2.0' , method : 'channels.deposit' , params : { amount } } ) return { handler : handlers . awaitingDepositTx , state : { sign , resolve , reject , onOnChainTx , onOwnDepositLocked , onDepositLocked } } } ) } ) }
Deposit tokens into the channel

After the channel had been opened any of the participants can initiate a deposit.
The process closely resembles the update. The most notable difference is that the
transaction has been co-signed: it is channel_deposit_tx and after the procedure
is finished - it is being posted on-chain.

Any of the participants can initiate a deposit. The only requirements are:

- Channel is already opened
- No off-chain update/deposit/withdrawal is currently being performed
- Channel is not being closed or in a solo closing state
- The deposit amount must be equal to or greater than zero, and cannot exceed
the available balance on the channel (minus the channel_reserve)

After the other party had signed the deposit transaction, the transaction is posted
on-chain and onOnChainTx callback is called with on-chain transaction as first argument.
After computing transaction hash it can be tracked on the chain: entering the mempool,
block inclusion and a number of confirmations.

After the minimum_depth block confirmations onOwnDepositLocked callback is called
(without any arguments).

When the other party had confirmed that the block height needed is reached
onDepositLocked callback is called (without any arguments).

@param {Number} amount - Amount of tokens to deposit
@param {Function} sign - Function which verifies and signs deposit transaction
@param {Object} [callbacks]
@param {Function} [callbacks.onOnChainTx] - Called when deposit transaction has been posted on chain
@param {Function} [callbacks.onOwnDepositLocked]
@param {Function} [callbacks.onDepositLocked]
@return {Promise<Object>}
@example channel.deposit(
100,
async (tx) => await account.signTransaction(tx),
{ onOnChainTx: (tx) => console.log('on_chain_tx', tx) }
).then(({ accepted, state }) => {
if (accepted) {
console.log('Deposit has been accepted')
console.log('The new state is:', state)
} else {
console.log('Deposit has been rejected')
}
})
Deposit tokens into the channel