// submit tx:
submitTx(signedTx, (err, res) => {
if (err) throw err;
// Check if `engine_result` is "tesSUCCESS":
if (res.engine_result !== "tesSUCCESS") {
// the tx's failed immediately.
return;
}
const txhash = res.tx_json.hash;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs"); | |
const inputFilePath = process.argv[2]; | |
console.log("file:", inputFilePath); | |
async function main(inputFilePath) { | |
const readStream = fs.createReadStream(inputFilePath, { encoding: 'utf8', highWaterMark: 1024 }); | |
// NOTE: Async-Iterator starts with NodeJS v10, but it's experimental yet. (Current latest LTS version: v10.13.0) | |
for await (const chunk of readStream) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Char.js Simple Stock Chart Example</title> | |
</head> | |
<body> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.min.js" integrity="sha256-XF29CBwU1MWLaGEnsELogU6Y6rcc5nCkhhx89nFMIDQ=" crossorigin="anonymous"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Payments URI Scheme Parser | |
* @param {String} - eg. "bitcoin:1XXX?amount=123&comment=%66%77" | |
* @see also: https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki | |
*/ | |
function parsePaymentURIScheme(s) { | |
const tmp = s.match(/^(\w+)\:(\w+)\??(.+)?/); | |
const protocol = (tmp && tmp.length >= 1) ? tmp[1] : null; | |
const address = (tmp && tmp.length >= 2) ? tmp[2] : null; | |
const qstr = (tmp && tmp.length >= 3) ? tmp[3] : null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// const entropy = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] | |
const entropy = []; | |
let captureStart = false; | |
/** | |
* Mouse Moving Entropy Generator on browser. | |
* Returns an entropy which is 16 bytes long array of unsigned char integer (0-255). | |
*/ | |
$(document).on("mousemove", "html", function(e) { | |
const MAX_LEN = 16; // size of entropy's array |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const aesjs = require('aes-js'); | |
const pbkdf2 = require('pbkdf2'); | |
const password = "mySecretPassword"; | |
const message = "HelloWorld!"; | |
const encrypted = encrypt(message, password); | |
console.log("encrypted:", encrypted); // 3ed20b7c474c96af513d1c | |
const decrypted = decrypt(encrypted, password); | |
console.log("decrypted:", decrypted); // HelloWorld! |
Ripple: Understand rippled book_offers
request & response
{
"id": 4,
"command": "book_offers",
"taker": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
"taker_gets": {
"currency": "XRP"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
websocket client module (supports either NodeJS and browser) | |
NOTE: | |
`browserify` makes this websocket client lib browser-compatible. | |
# Usage | |
``` | |
const onmessage = function(e) { | |
console.log("onmessage:", e); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple JSON RPC Client | |
const request = require("request"); | |
const requestAsync = require("request-promise"); | |
// const axios = require("axios"); | |
module.exports = class RpcClient { | |
constructor({ | |
url, | |
jsonrpc = "2.0", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Usage: | |
* $ node ./getCounterwalletAddress.js "<livenet_or_testnet>" <derived_index> "<passphrase of 12 words>" | |
*/ | |
const network = process.argv[2]; // "testnet" or "livenet" | |
const index = process.argv[3]; // derived address's index | |
const passphrase = process.argv[4]; // passphrase | |
// Mnemonic function inspired by: | |
// Mnemonic.js v. 1.0.0 |