1
0

p2sh.spec.js 1.0 KB

123456789101112131415161718192021222324252627282930
  1. /* Import modules. */
  2. const Nito = require('../..')
  3. describe('Address:p2sh', () => {
  4. test('it should convert a public script hash to a cash address', () => {
  5. /* Initialize public key (script) hash. */
  6. const scriptPubKey = 'a914e8f3b3d3ceea2d7b8750ef400161c6162b3b484b87'
  7. /* Convert to cash address. */
  8. const cashAddress = Nito.Address.toCashAddress(scriptPubKey)
  9. /* Evaluate test. */
  10. expect(cashAddress).toEqual('bitcoincash:pr508v7nem4z67u82rh5qqtpcctzkw6gfvdyvk6ag2')
  11. })
  12. test('it should convert a cash address to public script hash', () => {
  13. /* Initialize public key (script) hash. */
  14. const cashAddress = 'bitcoincash:pr508v7nem4z67u82rh5qqtpcctzkw6gfvdyvk6ag2'
  15. /* Convert to cash address. */
  16. const pubKeyHash = Nito.Address.toPubKeyHash(cashAddress)
  17. /* Expected result. */
  18. const expected = 'a914e8f3b3d3ceea2d7b8750ef400161c6162b3b484b87'
  19. /* Evaluate test. */
  20. expect(pubKeyHash).toEqual(expected)
  21. })
  22. })