layout |
---|
default |
In this post, we are rewriting some of the examples from the book Mastering Bitcoin by Andreas Antonopoulos using Javascript. Most of these programs require a bitcoin library to execute and for that we will use bcoin. For string encodings, we will use bstring and for cryptographic hash functions, we will use bcrypto.
bcoin.HDPrivateKey.generate()
- generates an object containing private key, public key, and other attributes.bcoin.Address.fromScripthash()
- returns an address from a script hash.bcoin.Script.fromAddress()
- returns a script from a base58 encoded bitcoin address.bcoin.util.revHex()
- returns the reverse of a hex string.
bcrypto.RIPEMD160.digest()
- returns the RIPEMD160 cryptographic hash.bcrypto.SHA256.digest()
- returns the SHA256 cryptographic hash.
base58.encode()
- encodes a string into base58 format.