Payment Channels: Consumer.setupRefund() failing

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) {

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


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


Thanks a lot in advance.

Cheers, Flo

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.

Related github issue:

@esteban great! :smile:

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