How to use the bsv.Networks function in bsv

To help you get started, we’ve selected a few bsv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dfoderick / bitshovel / misc / genWallet.js View on Github external
// generate a wallet.json file
// remember to fund the wallet using the address generated
// the easiest way to do that is go to https://www.moneybutton.com/test
// and use withdraw button
// then review the tx on a block explorer e.g. https://bchsvexplorer.com

const bsv = require('bsv')
const fs = require('fs');

var pk = bsv.PrivateKey()
console.log(pk)
var address = new bsv.Address(pk.publicKey, bsv.Networks.mainnet)
console.log(address.toLegacyAddress())

wallet = {
    "wif": pk.toWIF(),
    "address": address.toLegacyAddress()
}

const sWallet = JSON.stringify(wallet, null, 2);
console.log(sWallet)

fs.writeFile('wallet.json', sWallet, 'utf8', function(err) {
    if(err) {
        return console.log(err);
    }
});
github dfoderick / bitshovel / bitshovel.js View on Github external
function generateWallet(key) {
    let pk = null;
    if (key !== null && key !== undefined && key !== '') {
        pk = bsv.PrivateKey(key)
    } else {
        pk = bsv.PrivateKey()
    }
    const address = new bsv.Address(pk.publicKey, bsv.Networks.mainnet)
    console.log(`generated wallet with address ${address}`);

    const wallet = {
        "wif": pk.toWIF(),
        "address": address.toLegacyAddress()
    }
    return storeWallet(wallet)
}
github dfoderick / bitshovel / shovelwallet.js View on Github external
let generateWallet = function generateWallet(key) {
    let pk = null;
    if (key !== null && key !== undefined && key !== '') {
        pk = bsv.PrivateKey(key)
    } else {
        pk = bsv.PrivateKey()
    }
    const address = new bsv.Address(pk.publicKey, bsv.Networks.mainnet)
    console.log(`generated wallet with address ${address}`);

    const wallet = {
        "wif": pk.toWIF(),
        "address": address.toLegacyAddress()
    }
    return storeWallet(wallet)
}
github interplanaria / bpu / index.js View on Github external
}
          } else {
            cell.push(o.transform({ op: c, ii: chunk_index, i: cell_i++ }, c))
          }
        }
      })
      if (cell.length > 0) xputres.tape.push({ cell: cell, i: tape_i++ });
      if (type === 'in') {
        let sender = { h: xput.prevTxId.toString('hex'), i: xput.outputIndex }
        let address = xput.script.toAddress(bsv.Networks.livenet).toString()
        if (address && address.length > 0) { sender.a = address; }
        xputres.e = sender;
        xputres.seq = xput.sequenceNumber;
      } else if (type === 'out') {
        let receiver = { v: xput.satoshis, i: xput_index }
        let address = xput.script.toAddress(bsv.Networks.livenet).toString()
        if (address && address.length > 0) { receiver.a = address; }
        xputres.e = receiver;
      }
      xputsres.push(xputres)
    }
  })
  return xputsres;