Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

doichain

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

doichain - npm Package Compare versions

Comparing version 0.0.9 to 0.0.10

1

15

lib/fundWallet.js
import getUrl from "./getUrl";
import { isBrowser, isNode } from 'browser-or-node';
export const fundWallet = (address) => {
export const fundWallet = async (address,amount) => {
//1. connect to dApp (if this is not dApp)
if(isBrowser){
const url = getUrl()
console.log('this is a browser calling Doichain dApp API and request loaded privateKey',url)

@@ -13,3 +12,13 @@

console.log('this is on nodejs - we just call Doichain Node via RPC')
//1. execute sendmoney
const url = getUrl()+"api/v1/funding?address="+address+"&amount="+amount;
console.log(url)
const fetch = require('node-fetch');
const response = await fetch(url, {method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}})
const json = await response.json();
return json
}

@@ -16,0 +25,0 @@

8

lib/network.js

@@ -0,1 +1,2 @@

import settings from './settings'
export var network

@@ -12,3 +13,3 @@ export var DEFAULT_NETWORK

},
pubKeyHash: 52, //D=30 d=90 (52=N) https://en.bitcoin.it/wiki/List_of_address_prefixes
pubKeyHash: 30, //D=30 d=90 (52=M) https://en.bitcoin.it/wiki/List_of_address_prefixes
scriptHash: 13,

@@ -25,3 +26,3 @@ wif: 180, //???

},
pubKeyHash: 111, //D=30 d=90 (52=N) https://en.bitcoin.it/wiki/List_of_address_prefixes
pubKeyHash: 90, //D=30 d=90 (52=N) https://en.bitcoin.it/wiki/List_of_address_prefixes
scriptHash: 196,

@@ -38,3 +39,3 @@ wif: 239, //???

},
pubKeyHash: 111, //D=30 d=90 (52=N) https://en.bitcoin.it/wiki/List_of_address_prefixes
pubKeyHash: 90, //D=30 d=90 (52=N) https://en.bitcoin.it/wiki/List_of_address_prefixes
scriptHash: 196,

@@ -83,4 +84,5 @@ wif: 239, //???

console.log('changed network to',network)
settings.setSettings(DEFAULT_SETTINGS)
//console.log('DEFAULT_NETWORK',DEFAULT_NETWORK)
//console.log('DEFAULT_SETTINGS',DEFAULT_SETTINGS)
}
{
"name": "doichain",
"version": "0.0.9",
"version": "0.0.10",
"description": "A js-Doichain library. The goal is to fully cover the Doichain protocoll",

@@ -40,4 +40,5 @@ "main": "index.js",

"browser-or-node": "^1.2.1",
"hdkey": "^1.1.1"
"hdkey": "^1.1.1",
"node-fetch": "^2.6.0"
}
}

@@ -19,5 +19,7 @@ import chai from 'chai'

import {fundWallet} from "../lib/fundWallet";
import {listTransactions} from "../lib/listTransactions"
import {listUnspent} from "../lib/listUnspent";
describe('js-doichain', function(){
this.timeout(0);
describe('basic doichain functions', function(){

@@ -51,3 +53,3 @@ it('should create a new mnemonic seed phrase', function () {

// 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.assert.strictEqual(wallet.addresses[0].address.startsWith('D') || wallet.addresses[0].address.startsWith('N'),true)
chai.expect(wallet.addresses[0].address).to.have.length(34)

@@ -61,3 +63,3 @@ chai.expect(wallet.addresses[0].address.substring(0,1)).to.be.uppercase

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.assert.strictEqual(wallet.addresses[0].address.startsWith('d') || wallet.addresses[0].address.startsWith('n'),true)
chai.expect(wallet.addresses[0].address).to.have.length(34)

@@ -67,3 +69,3 @@ 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 () {
it('should create a new Doichain address for a regtest wallet ', async () => {
changeNetwork('regtest')

@@ -73,33 +75,20 @@ const mnemonic = "balance blanket camp festival party robot social stairs noodle piano copy drastic"

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.assert.strictEqual(wallet.addresses[0].address.startsWith('d') || 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
const funding = await fundWallet(wallet.addresses[0].address,doi)
console.log('funding',funding)
const wif = funding.data.wif
const address = funding.data.address
chai.expect(address).to.have.length(34)
chai.expect(address.substring(0,1).to.be.uppercase)
chai.expect(address.substring(0,1)).to.not.be.uppercase
const unspent = await listUnspent(address)
console.log(unspent)
const transactions = await listTransactions(address)
console.log(transactions)
})
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')
})
})
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc