1.2.0 • Published 3 months ago
wallycore v1.2.0
libwally JS
Official Blockstream WASM-based JavaScript bindings for libwally, for nodejs and the browser.
Installation
$ npm install wallycore
Example use
With ES modules:
import wally from 'wallycore'
const word = wally.bip39_get_word(null, 10)
const script = wally.address_to_scriptpubkey("1EMBaSSyxMQPV2fmUsdB7mMfMoocgfiMNw", wally.WALLY_NETWORK_BITCOIN_MAINNET)
const tx = wally.tx_from_hex('020000000100000000000000000000000000000000000000000000000000000000000000000000000000fdffffff0101000000000000000000000000', 0)
console.log(wally.tx_get_txid(tx).toString('hex'))
wally.tx_free(tx)
If you're using CommonJS, the module can be loaded asynchronously using const wally = await import('wallycore')
or import('wallycore').then(wally => { ... })
.
For browser use, you may use a bundler like webpack,
or use the pre-bundled wallycore.bundle.js
file which exposes a global WallyInit
promise that resolves to the module. For example:
<script src="wallycore/wallycore.bundle.min.js"></script>
<script>
WallyInit.then(wally => {
console.log(wally.bip39_get_word(null, 10))
})
// or `const wally = await WallyInit`
</script>
Limitations
- BIP38 (passphrase-protected keys) related functions are disabled due to WASM memory restrictions, which are insufficient for running Scrypt with the BIP38 parameters.