Payment Channels: Consumer.setupRefund() failing


(Flotob) #1

hi there,

when following the docs and examples to set up a channel, i get this error:

bitcore-channel.js:140 Uncaught TypeError: Cannot read property 'script' of undefined

this happens because outputs[] is empty. the insight api call however does return utxo transactions. so i assume that something in Consumer.processFunding() is not parsing them properly.

my code:

var consumer = new Consumer({
  network: 'testnet',
  fundingKey: fundingKey,
  refundKey: refundKey,
  commitmentKey: commitmentKey,
  providerPublicKey: providerPublicKey,
});

var insight = new Insight(bitcore.Networks.testnet);
insight.getUnspentUtxos(consumer.fundingAddress, function(err, utxos) {
  consumer.processFunding(utxos);
  consumer.setupRefund();
});

any clues?

// edit-start

Looking at line 317 in bitcore-channel.js, an output script is generated and saved as

this.outscript = Script.buildMultisigOut(this.publicKeys, 2);

Line 141 though looks for a script in

this.commitmentTx.outputs[0].script

which is empty. That seems like part of the bug? Especially since “outscript” as a property is never again called upon anywhere, neither in bitcore-channel.js nor bitcore.js. Though simply editing line 141 such that

script: this.commitmentTx.outscript

generates the following error:

bitcore.js:10347 Uncaught bitcore.ErrorInvalidState: Invalid state: Provided public keys don't hash to the provided output

//edit-end

Thanks a lot in advance.

Cheers, Flo


(esteban) #2

Hey Flo,

This may be related to some changes on the newest bitcore. I’ll take a look at it tomorrow and get back to you.


(Manuel Araoz) #3

Related github issue: https://github.com/bitpay/bitcore-channel/issues/19


#4

@esteban great! :smile:

@maraoz this was a cross-post by my colleague. shall we continue discussing in the github issue or here?