Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(new HDNode(pair): HDNode);
var bitcoinNetwork = {
messagePrefix: '\x18Bitcoin Signed Message:\n',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x00,
scriptHash: 0x05,
wif: 0x80,
dustThreshold: 546
};
(HDNode.fromBase58('xpub123'): HDNode);
(HDNode.fromBase58('xpub123', bitcoinNetwork): HDNode);
// $ExpectError
(HDNode.fromBase58(new Buffer(1)): HDNode);
(HDNode.fromBase58('xpub123', bitcoinNetwork).getAddress(): string);
var t: Transaction = Transaction.fromHex('1234');
var input = {
script: new Buffer(1),
hash: new Buffer(1),
index: 1,
sequence: 1
};
t.ins.push(input);
messagePrefix: '\x18Bitcoin Signed Message:\n',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x00,
scriptHash: 0x05,
wif: 0x80,
dustThreshold: 546
};
(HDNode.fromBase58('xpub123'): HDNode);
(HDNode.fromBase58('xpub123', bitcoinNetwork): HDNode);
// $ExpectError
(HDNode.fromBase58(new Buffer(1)): HDNode);
(HDNode.fromBase58('xpub123', bitcoinNetwork).getAddress(): string);
var t: Transaction = Transaction.fromHex('1234');
var input = {
script: new Buffer(1),
hash: new Buffer(1),
index: 1,
sequence: 1
};
t.ins.push(input);
// $ExpectError
t.addInput(input);
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x00,
scriptHash: 0x05,
wif: 0x80,
dustThreshold: 546
};
(HDNode.fromBase58('xpub123'): HDNode);
(HDNode.fromBase58('xpub123', bitcoinNetwork): HDNode);
// $ExpectError
(HDNode.fromBase58(new Buffer(1)): HDNode);
(HDNode.fromBase58('xpub123', bitcoinNetwork).getAddress(): string);
var t: Transaction = Transaction.fromHex('1234');
var input = {
script: new Buffer(1),
hash: new Buffer(1),
index: 1,
sequence: 1
};
t.ins.push(input);
// $ExpectError
t.addInput(input);
t.addInput(new Buffer(1), 1);
// $ExpectError
(new HDNode(pair): HDNode);
var bitcoinNetwork = {
messagePrefix: '\x18Bitcoin Signed Message:\n',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4
},
pubKeyHash: 0x00,
scriptHash: 0x05,
wif: 0x80,
dustThreshold: 546
};
(HDNode.fromBase58('xpub123'): HDNode);
(HDNode.fromBase58('xpub123', bitcoinNetwork): HDNode);
// $ExpectError
(HDNode.fromBase58(new Buffer(1)): HDNode);
(HDNode.fromBase58('xpub123', bitcoinNetwork).getAddress(): string);
var t: Transaction = Transaction.fromHex('1234');
var input = {
script: new Buffer(1),
hash: new Buffer(1),
index: 1,
sequence: 1
};
t.ins.push(input);
// Get keypair corresponding to the current user identity
const profileSigningKeypair = identityKeypairs[identityIndex]
const identity = localIdentities[identityIndex]
let blockchainId = null
if (decodedCoreSessionToken) {
blockchainId = decodedCoreSessionToken.payload.blockchain_id
} else {
blockchainId = this.state.blockchainId
}
const profile = identity.profile
const privateKey = profileSigningKeypair.key
const appsNodeKey = profileSigningKeypair.appsNodeKey
const salt = profileSigningKeypair.salt
const appsNode = new AppsNode(HDNode.fromBase58(appsNodeKey), salt)
const appPrivateKey = appsNode.getAppNode(appDomain).getAppPrivateKey()
const gaiaBucketAddress = nextProps.identityKeypairs[0].address
const profileUrlBase = `https://gaia.blockstack.org/hub/${gaiaBucketAddress}`
let profileUrl = `${profileUrlBase}/${identityIndex}/profile.json`
if (identity.zoneFile && identity.zoneFile.length > 0) {
const profileUrlFromZonefile = getTokenFileUrlFromZoneFile(identity.zoneFile)
if (profileUrlFromZonefile !== null && profileUrlFromZonefile !== undefined) {
profileUrl = profileUrlFromZonefile
}
}
// Add app storage bucket URL to profile if publish_data scope is requested
if (this.state.scopes.publishData) {
let apps = {}
// Get keypair corresponding to the current user identity
const profileSigningKeypair = identityKeypairs[identityIndex]
const identity = localIdentities[identityIndex]
let blockchainId = null
if (decodedCoreSessionToken) {
blockchainId = decodedCoreSessionToken.payload.blockchain_id
} else {
blockchainId = this.state.blockchainId
}
const profile = identity.profile
const privateKey = profileSigningKeypair.key
const appsNodeKey = profileSigningKeypair.appsNodeKey
const salt = profileSigningKeypair.salt
const appsNode = new AppsNode(HDNode.fromBase58(appsNodeKey), salt)
const appPrivateKey = appsNode.getAppNode(appDomain).getAppPrivateKey()
let profileUrlPromise
if (identity.zoneFile && identity.zoneFile.length > 0) {
const zoneFileJson = parseZoneFile(identity.zoneFile)
const profileUrlFromZonefile = getTokenFileUrlFromZoneFile(zoneFileJson)
if (
profileUrlFromZonefile !== null &&
profileUrlFromZonefile !== undefined
) {
profileUrlPromise = Promise.resolve(profileUrlFromZonefile)
}
}
const gaiaBucketAddress = nextProps.identityKeypairs[0].address
sign(keyName, hexHash) {
const privateKey = this.KEY_STORAGE[keyName];
const keyPair = HDNode.fromBase58(privateKey);
const hash = Buffer.from(hexHash, 'hex');
const signature = keyPair.sign(hash);
const hexSignature = signature.toDER().toString('hex');
// keys are volatile in this impl, removes
delete this.KEY_STORAGE[keyName];
return hexSignature;
}
installKey(keyName, key) {
try {
// Test if key is a valid HDNode key
HDNode.fromBase58(key);
this.KEY_STORAGE[keyName] = key;
} catch (err) {
throw new Error(`Invalid key format: ${err.message}`);
}
}
verify(keyName, hexHash, hexSignature) {
const key = this.KEY_STORAGE[keyName];
const keyPair = HDNode.fromBase58(key);
const hash = Buffer.from(hexHash, 'hex');
const signature = Buffer.from(hexSignature, 'hex');
const ecSignature = ECSignature.fromDER(signature);
// keys are volatile in this impl, removes
delete this.KEY_STORAGE[keyName];
return keyPair.verify(hash, ecSignature);
}
}
coreWallet: Object.assign({}, state.coreWallet, {
balance: action.coreWalletBalance
})
})
case types.UPDATE_BACKUP_PHRASE:
return Object.assign({}, state, {
encryptedBackupPhrase: action.encryptedBackupPhrase
})
case types.NEW_BITCOIN_ADDRESS:
return Object.assign({}, state, {
bitcoinAccount: {
publicKeychain: state.bitcoinAccount.publicKeychain,
addresses: [
...state.bitcoinAccount.addresses,
getBitcoinAddressNode(
HDNode.fromBase58(state.bitcoinAccount.publicKeychain),
state.bitcoinAccount.addressIndex + 1
).getAddress()
],
addressIndex: state.bitcoinAccount.addressIndex + 1,
balances: state.bitcoinAccount.balances
}
})
case types.UPDATE_BALANCES:
return Object.assign({}, state, {
bitcoinAccount: {
publicKeychain: state.bitcoinAccount.publicKeychain,
addresses: state.bitcoinAccount.addresses,
balances: action.balances
}
})
case types.BUILD_TRANSACTION: