es/channel/index.js
function update (from, to, amount, sign) {
  return new Promise((resolve, reject) => {
    enqueueAction(
      this,
      (channel, state) => state.handler === handlers.channelOpen,
      (channel, state) => {
        send(channel, {
          jsonrpc: '2.0',
          method: 'channels.update.new',
          params: { from, to, amount }
        })
        return {
          handler: handlers.awaitingOffChainTx,
          state: {
            resolve,
            reject,
            sign
          }
        }
      }
    )
  })
}
function update (from, to, amount, sign) {
  return new Promise((resolve, reject) => {
    enqueueAction(
      this,
      (channel, state) => state.handler === handlers.channelOpen,
      (channel, state) => {
        send(channel, {
          jsonrpc: '2.0',
          method: 'channels.update.new',
          params: { from, to, amount }
        })
        return {
          handler: handlers.awaitingOffChainTx,
          state: {
            resolve,
            reject,
            sign
          }
        }
      }
    )
  })
}
function update ( from , to , amount , sign ) { return new Promise ( ( resolve , reject ) => { enqueueAction ( this , ( channel , state ) => state . handler === handlers . channelOpen , ( channel , state ) => { send ( channel , { jsonrpc : '2.0' , method : 'channels.update.new' , params : { from , to , amount } } ) return { handler : handlers . awaitingOffChainTx , state : { resolve , reject , sign } } } ) } ) }
Trigger a transfer update

The transfer update is moving tokens from one channel account to another.
The update is a change to be applied on top of the latest state.

Sender and receiver are the channel parties. Both the initiator and responder
can take those roles. Any public key outside of the channel is considered invalid.

@param {String} from - Sender's public address
@param {String} to - Receiver's public address
@param {Number} amount - Transaction amount
@param {Function} sign - Function which verifies and signs offchain transaction
@return {Promise<Object>}
@example channel.update(
'ak_Y1NRjHuoc3CGMYMvCmdHSBpJsMDR6Ra2t5zjhRcbtMeXXLpLH',
'ak_V6an1xhec1xVaAhLuak7QoEbi6t7w5hEtYWp9bMKaJ19i6A9E',
10,
async (tx) => await account.signTransaction(tx)
).then(({ accepted, signedTx }) =>
if (accepted) {
console.log('Update has been accepted')
}
)
Trigger a transfer update