bitcoinjs-lib: bscript.compile, undefined is not a function (react-native), circular dependency

Hi, I’m developing an rn project with bitcoinjs-lib. Previously, I have fixed compatible issues by rn-nodeify. Unfortunately, this latest version which contains template module cannot be resolved as before. Transaction creation is always failed when called bscript.compile, because script which was required by out.js is {}. But the Types is required well,like the code in out.js as below:

var bscript = require('../../script')
var types = require('../../types')

I have changed and compared, But got nothing. could anyone please give me some suggestion?Thanks in advance

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 28 (11 by maintainers)

Most upvoted comments

Yeah, i had test it’s send method under node environment, it works. Same method failed in RN

yeah, it failed on 3.0.0 as expected just now, maybe circular dependency is the real reason.@dcousens

@maxcloudwgh the template modules have a circular dependency with bitcoin.script, which is probably the reason it is failing.

I might move the template export injection from bitcoin.script to index.js, as it is purely a convenience for users, and not necessary in bitcoin.script. This wouldn’t be a breaking change.