machinomy / machinomy

Node.js library for micropayments in Ether and ERC20 tokens over HTTP

Home Page:http://machinomy.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to claim channel

karzak opened this issue · comments

I am trying to test a simple send/receive workflow and cannot get the receiver to accept the payment. As far as I can tell the formatting of the payment is fine, so I think there is an error in the canClaim function that's called during payment validation.

The code to reproduce this error is located here.

The sender script creates a channel, sends a payment and saves it as JSON that looks like this:

{ channelId: '0xdd1b28611dfc4b488c27aad5e7d8906100000000000000000000000000000000',
  value: '200000',
  sender: '0x293c4e447b0519665ef40763840ca6aa253b0b3c',
  receiver: '0xfee2837d64476df777fe142f993b2b6001d0d41e',
  price: '200000',
  channelValue: '1000000',
  v: 28,
  r: '0x902fbb7e4ed58c165920facca0085fccc5d188374217cc3212e5678293c53394',
  s: '0x092eb551da10d79f01b048db92ef6caf913a0d620f84e5a999e3ffe633d2b422',
  token: undefined,
  meta: '',
  createdAt: undefined,
  tokenContract: '' }

The receiver script fails when calling the acceptPayment method with the following output:

error:PaymentValidation Payment is invalid: Channel contract cannot accept the claim. Payment: [ Payment { channelId: '0xdd1b28611dfc4b488c27aad5e7d8906100000000000000000000000000000000', sender: '0x293c4e447b0519665ef40763840ca6aa253b0b3c', receiver: '0xfee2837d64476df777fe142f993b2b6001d0d41e', price: BigNumber { s: 1, e: 5, c: [Array] }, value: BigNumber { s: 1, e: 5, c: [Array] }, channelValue: BigNumber { s: 1, e: 6, c: [Array] }, signature: Signature { rpcSig: '0x902fbb7e4ed58c165920facca0085fccc5d188374217cc3212e5678293c53394092eb551da10d79f01b048db92ef6caf913a0d620f84e5a999e3ffe633d2b42201' }, meta: '', token: undefined, createdAt: NaN, tokenContract: '' } ] +0ms
  info:PaymentValidation Settlement period for channel 0xdd1b28611dfc4b488c27aad5e7d8906100000000000000000000000000000000 is ok: 172800 +0ms
Error: Invalid payment.
    at mutex.synchronizeOn (/Users/kjd/ILP/temp/machinomy-test/node_modules/machinomy/lib/ChannelManager.js:81:19)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

That error traces to the canClaim method which is called on the contract in ChannelContract.ts

Solved by using the machinomy fork of the hd-wallet-provider. See changes here for working example of settling a channel.