Skip to content

Instantly share code, notes, and snippets.

@boyangwang
Last active March 30, 2019 11:14
Show Gist options
  • Save boyangwang/95a085c1b76be95d9e0c54a5ae6e977b to your computer and use it in GitHub Desktop.
Save boyangwang/95a085c1b76be95d9e0c54a5ae6e977b to your computer and use it in GitHub Desktop.
Snippets
statusReponse = await vault.status();
vault.checkSucceeded(statusReponse);
// Beyond this point Vault has been unsealed using 3 out of 5 multisig keys
console.log('generating mnemonic, password and ga...');
let
mnemonic = bip39.generateMnemonic(256),
password = crypto.randomBytes(32).toString('hex'),
ga = crypto.randomBytes(16).toString('hex');
let data = {};
data[constants.KEY_MNEMONIC] = mnemonic;
data[constants.KEY_PASSWORD] = password;
data[constants.KEY_GA] = ga;
hdResponse = await vault.write(constants.KEY_PATH, data);
generateXpub(data[constants.KEY_MNEMONIC], data[constants.KEY_PASSWORD]);
function generateXpub(hdWords, hdPassword) {
let
seedHex = bip39.mnemonicToSeedHex(hdWords, hdPassword),
xprvRoot = HDNode.fromSeedHex(seedHex),
xpubRoot = xprvRoot.neutered();
for (let coin in constants.COINS) {
let
n = constants.COINS[coin],
p = `m/44'/${n}'/0'/0`,
xprv = xprvRoot.derivePath(p);
}
}
const req = {
"transactions": [{
"tx_hash": "accf5c09cc027339a3beb2e28104ce9f406ecbbd29775b4a1a17ba213f1e035e",
"customer_reference": "123456",
"is_deposit": true,
"base58": "15Hm2UEPaEuiAmgyNgd5mF3wugqLsYs3Wn",
}]
};
const res = {
"process_status": "complete",
"id": "ed476590-1b23-4273-a670-5f741600e2d8",
"customer_id": "e4b0b894-c96c-452e-9752-62e748da6963",
"is_deposit": true,
"tx_hash": "36dd1c824e8583fbfde27dc4204a54cdc5614460afb579e9331dbf8cda790e75",
"base58": "1DFzRod3w9y65q85b4kBsgfMZHcaAsiWy6",
"output_indices": [1],
"user_supplied_base58": true,
"actor_id": "f83d6e5f-b819-465a-ab68-1352898cb1c5",
"analysed_at": "2019-01-23T16:59:12.348Z",
"note": null,
"output_satoshis": 100000000,
"tx_time": "2011-04-25T05:06:37.000Z",
"risk_score": null,
"analysis_meta": {
"data_version": {
"assertions": {
"version": "0.2"
},
"latest_block": {
"hash": "00000000000000000000048fd851b9df2d71dcb497478de4ac85346ce5449d55",
"time": 1548218553000,
"height": 559702
}
},
"schema_version": "0.2"
},
"tx_info": {
"clusters": [
{
"id": 267721348,
"name": null,
"pii_d": 7924.559,
"pii_s": 0,
"labels": [],
"taint_d": 3.8724704,
"category": null,
"risk_score": 0,
"satoshis_in": 3272989964,
"satoshis_out": 3272989964,
"address_count": 1,
"last_seen_time": 1303707997000,
"first_seen_time": 1303706673000,
"primary_label_id": null,
"satoshis_balance": 0,
"candidate_address": "12uiBrxB8mDxsrivFz6cCo8RxYrfW5ni8G",
"total_incoming_edges": 1,
"total_outgoing_edges": 2,
"last_seen_block_height": 120039,
"first_seen_block_height": 120033
}
],
"transaction": {
"fee": 0,
"vin": [
{
"base58": "12uiBrxB8mDxsrivFz6cCo8RxYrfW5ni8G",
"satoshis": 3272989964,
"cluster_id": 267721348,
"prev_index": 0,
"prev_tx_hash": "63768bc91ef1f950d97becc07ff6fea1df575b6589918f97cef5bcc2b98411e7"
}
],
"hash": "36dd1c824e8583fbfde27dc4204a54cdc5614460afb579e9331dbf8cda790e75",
"size": 257,
"time": 1303707997000,
"vout": [
{
"index": 0,
"spent": true,
"base58": "12PPjyxQqHxcQxjtAR6mJhRZouS7zMDT9P",
"satoshis": 3172989964,
"cluster_id": 267725999,
"spending_tx_hash": "1c272cbe45b5a7a52f0dd74d7f93f811487606db85b5048f749a01f962525704"
},
{
"index": 1,
"spent": true,
"base58": "1DFzRod3w9y65q85b4kBsgfMZHcaAsiWy6",
"satoshis": 100000000,
"cluster_id": 127585679,
"spending_tx_hash": "896eeba2476e2aa9e383f3dae713836a3f186a6283cfa9bbe558c758d3a56289"
}
],
"labels": [],
"assertions": [],
"satoshis_in": 3272989964,
"block_height": 120039,
"satoshis_out": 3272989964
}
},
"error": null,
"created_at": "2018-11-09T09:03:26.968Z",
"updated_at": "2019-01-23T16:59:12.352Z",
"has_triggered_rule": false
}
const req = {
"address": {
"cluster_id": 16162291,
"base58": "16TV2GavikEtUiHaQfSy1nxEVLgbPn5ZpQ",
"total_received": 312446529,
"total_spent": 312446529,
"balance": 0,
"num_incoming_transactions": 5,
"num_outgoing_transactions": 5,
"num_transactions": 10,
"first_seen_block_height": 278480,
"first_seen_time": 1388781713000,
"last_seen_block_height": 295342,
"last_seen_time": 1397261169000
},
"cluster": {
"id": 16162291,
"candidate_address": "1HFwLkodSVBEdGPVX5vz5ZAx4QarY5LuLq",
"risk_score": 4.138326,
"taint_d": 3.903963,
"pii_s": 10000,
"pii_d": 10000,
"satoshis_balance": 106420477373,
"satoshis_in": 1693595947034989,
"satoshis_out": 1693426709752694,
"address_count": 528072,
"labels": [
{
"id": "56b240c3-a79f-4627-a9c7-fce9d6f46a33",
"name": "GetBits - 73, Surbiton Road, Kingston Upon Thames KT1 2HG.",
"category": "ATM",
"confidence": 0.92277306,
"info": {
"country_hq": "United Kingdom",
"url": null,
"lexis_nexis": null
},
"evidence_types": [
"\u0003\u0003Third Party Provider"
]
}
],
"name": "Bitstamp",
"category": "Exchange",
"primary_label_id": "89a4d22a-a803-4783-9223-9169bfd8545c",
"total_incoming_edges": 1196961,
"total_outgoing_edges": 1041516,
"first_seen_block_height": 141342,
"first_seen_time": 1313591500000,
"last_seen_block_height": 560370,
"last_seen_time": 1548614898000
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment