Comparing version 0.0.4 to 0.0.5
@@ -1,3 +0,4 @@ | ||
export const printHello = () => { | ||
return 'hello' | ||
} | ||
export default const bla = "3" | ||
import './lib/network' | ||
export changeNetwork | ||
export DEFAULT_NETWORK,DEFAULT_SETTINGS |
{ | ||
"name": "doichain", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "A js-Doichain library. The goal is to fully cover the Doichain protocoll", | ||
@@ -37,4 +37,7 @@ "main": "index.js", | ||
"dependencies": { | ||
"bip39": "^3.0.2" | ||
"bip39": "^3.0.2", | ||
"bitcoinjs-lib": "^5.1.7", | ||
"browser-or-node": "^1.2.1", | ||
"hdkey": "^1.1.1" | ||
} | ||
} |
@@ -10,3 +10,3 @@ # js-doichain | ||
- create and validate mnemonic seed phrases | ||
- hd-keys (from mnemonic seed phrases) | ||
- create hd-key (from mnemonic seed phrases) | ||
- Doichain addresses | ||
@@ -13,0 +13,0 @@ - "double opt-in/DOI" request transaction |
import chai from 'chai' | ||
import {printHello} from '../index' | ||
chai.Assertion.addProperty('uppercase', function () { | ||
var obj = this._obj; | ||
new chai.Assertion(obj).to.be.a('string'); | ||
this.assert( | ||
obj === obj.toUpperCase() // adapt as needed | ||
, 'expected #{this} to be all uppercase' // error message when fail for normal | ||
, 'expected #{this} to not be all uppercase' // error message when fail for negated | ||
); | ||
}); | ||
import {generateMnemonic} from '../lib/generateMnemonic' | ||
import {validateMnemonic} from "../lib/validateMnemonic"; | ||
import {createHdKeyFromMnemonic} from "../lib/createHdKeyFromMnemonic" | ||
import {createDoichainWalletFromHdKey,noEmailError} from "../lib/createDoichainWalletFromHdKey" | ||
import {getAddress} from "../lib/getAddress" | ||
import {changeNetwork, DEFAULT_NETWORK, DOICHAIN_REGTEST,DOICHAIN_TESTNET,DOICHAIN} from "../lib/network" | ||
import {fundWallet} from "../lib/fundWallet"; | ||
@@ -20,4 +34,68 @@ describe('js-doichain', function(){ | ||
it('should create a hdkey from a mnemonic without password', function() { | ||
const mnemonic = "balance blanket camp festival party robot social stairs noodle piano copy drastic" | ||
const hdKey = createHdKeyFromMnemonic(mnemonic) | ||
chai.expect(hdKey).to.have.own.property('_privateKey'); | ||
chai.expect(hdKey).to.have.own.property('_publicKey'); | ||
}) | ||
it('should create a new Doichain wallet from a seed in mainnet', function () { | ||
const mnemonic = "balance blanket camp festival party robot social stairs noodle piano copy drastic" | ||
const hdKey = createHdKeyFromMnemonic(mnemonic) | ||
chai.expect(() => createDoichainWalletFromHdKey(hdKey)).to.throw(); | ||
chai.expect(() => createDoichainWalletFromHdKey(hdKey,'alice@ci-doichain.org')).to.not.throw(); | ||
const wallet = createDoichainWalletFromHdKey(hdKey,'alice@ci-doichain.org',DOICHAIN) | ||
// bitcoin testnet P2PKH addresses start with a 'm' or 'n' | ||
chai.assert.strictEqual(wallet.addresses[0].address.startsWith('M') || wallet.addresses[0].address.startsWith('N'),true) | ||
chai.expect(wallet.addresses[0].address).to.have.length(34) | ||
chai.expect(wallet.addresses[0].address.substring(0,1)).to.be.uppercase | ||
}) | ||
it('should create a new Doichain wallet from a seed in testnet', function () { | ||
const mnemonic = "balance blanket camp festival party robot social stairs noodle piano copy drastic" | ||
const hdKey = createHdKeyFromMnemonic(mnemonic) | ||
const wallet = createDoichainWalletFromHdKey(hdKey,'alice@ci-doichain.org',DOICHAIN_TESTNET) | ||
chai.assert.strictEqual(wallet.addresses[0].address.startsWith('m') || wallet.addresses[0].address.startsWith('n'),true) | ||
chai.expect(wallet.addresses[0].address).to.have.length(34) | ||
chai.expect(wallet.addresses[0].address.substring(0,1)).to.not.be.uppercase | ||
}) | ||
it('should create a new Doichain address for a regtest wallet ', function () { | ||
changeNetwork('regtest') | ||
const mnemonic = "balance blanket camp festival party robot social stairs noodle piano copy drastic" | ||
const hdKey = createHdKeyFromMnemonic(mnemonic) | ||
const wallet = createDoichainWalletFromHdKey(hdKey,'alice@ci-doichain.org',DEFAULT_NETWORK) | ||
chai.assert.strictEqual(wallet.addresses[0].address.startsWith('m') || wallet.addresses[0].address.startsWith('n'),true) | ||
chai.expect(wallet.addresses[0].address).to.have.length(34) | ||
chai.expect(wallet.addresses[0].address.substring(0,1)).to.not.be.uppercase | ||
fundWallet(wallet.addresses[0].address) | ||
const doi = 10 | ||
//sendDoicoinToAddress() | ||
}) | ||
it('should fund a new regtest wallet ', function () { | ||
const address = undefined | ||
chai.expect(address).to.have.length(34) | ||
chai.expect(address.substring(0,1).to.be.uppercase) | ||
}) | ||
it('should get all transactinos for a wallet', function () { | ||
const transactions = undefined | ||
chai.expect(transactions).to.be.an('array') | ||
}) | ||
it('should get all transactinos for an address', function () { | ||
const transactions = undefined | ||
chai.expect(transactions).to.be.an('array') | ||
}) | ||
it('should create a new Doichain change address in wallet', function () { | ||
const transactions = undefined | ||
chai.expect(transactions).to.be.an('array') | ||
}) | ||
}) | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14465
16
286
4
2
+ Addedbitcoinjs-lib@^5.1.7
+ Addedbrowser-or-node@^1.2.1
+ Addedhdkey@^1.1.1
+ Added@types/node@10.12.18(transitive)
+ Addedbase-x@3.0.10(transitive)
+ Addedbech32@1.1.4(transitive)
+ Addedbindings@1.5.0(transitive)
+ Addedbip174@2.1.1(transitive)
+ Addedbip32@2.0.6(transitive)
+ Addedbip66@1.1.5(transitive)
+ Addedbitcoin-ops@1.4.1(transitive)
+ Addedbitcoinjs-lib@5.2.0(transitive)
+ Addedbn.js@4.12.1(transitive)
+ Addedbrorand@1.1.0(transitive)
+ Addedbrowser-or-node@1.3.0(transitive)
+ Addedbrowserify-aes@1.2.0(transitive)
+ Addedbs58@4.0.1(transitive)
+ Addedbs58check@2.1.2(transitive)
+ Addedbuffer-xor@1.0.3(transitive)
+ Addedcipher-base@1.0.6(transitive)
+ Addedcreate-hash@1.2.0(transitive)
+ Addedcreate-hmac@1.1.7(transitive)
+ Addeddrbg.js@1.0.1(transitive)
+ Addedelliptic@6.6.1(transitive)
+ Addedevp_bytestokey@1.0.3(transitive)
+ Addedfile-uri-to-path@1.0.0(transitive)
+ Addedhash-base@3.1.0(transitive)
+ Addedhash.js@1.1.7(transitive)
+ Addedhdkey@1.1.2(transitive)
+ Addedhmac-drbg@1.0.1(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedmd5.js@1.3.5(transitive)
+ Addedmerkle-lib@2.0.10(transitive)
+ Addedminimalistic-assert@1.0.1(transitive)
+ Addedminimalistic-crypto-utils@1.0.1(transitive)
+ Addednan@2.22.0(transitive)
+ Addedpushdata-bitcoin@1.0.1(transitive)
+ Addedrandombytes@2.1.0(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedripemd160@2.0.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsecp256k1@3.8.1(transitive)
+ Addedsha.js@2.4.11(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedtiny-secp256k1@1.1.7(transitive)
+ Addedtypeforce@1.18.0(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedvaruint-bitcoin@1.1.2(transitive)
+ Addedwif@2.0.6(transitive)