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
### new ubuntu 18.04 server | |
### Be sure to run | |
# sudo apt-get update && sudo apt-get -y upgrade && sudo reboot | |
### For security updates | |
### Then run this script with passwordless sudo account ubuntu (default for ubuntu AWS EC2): | |
# CERTDOMAIN=something.yourdomain.com [email protected] ./thisScript.sh | |
# Install Bitcoin 0.17.0 etc. | |
sudo add-apt-repository -y ppa:bitcoin/bitcoin &>/dev/null | |
sudo apt-get update &>/dev/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
// Usage: | |
// getByteCount({'MULTISIG-P2SH:2-4':45},{'P2PKH':1}) Means "45 inputs of P2SH Multisig and 1 output of P2PKH" | |
// getByteCount({'P2PKH':1,'MULTISIG-P2SH:2-3':2},{'P2PKH':2}) means "1 P2PKH input and 2 Multisig P2SH (2 of 3) inputs along with 2 P2PKH outputs" | |
function getByteCount(inputs, outputs) { | |
var totalWeight = 0 | |
var hasWitness = false | |
var inputCount = 0 | |
var outputCount = 0 | |
// assumes compressed pubkeys in all cases. | |
var types = { |
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
#!/bin/bash | |
SELECTION=$1 | |
if [ -z "$1" ] | |
then | |
SELECTION="JPN" | |
fi | |
# Default JPN | |
CODE=108 |
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
async function aesEncrypt(data, password, difficulty = 10) { | |
const hashKey = await grindKey(password, difficulty) | |
const iv = await getIv(password, data) | |
const key = await window.crypto.subtle.importKey( | |
'raw', | |
hashKey, { | |
name: 'AES-GCM', | |
}, | |
false, |
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
# Get rid of remotes | |
git fetch --prune --all | |
# Check branches for stuff you might want to keep | |
# This will show branches that are NOT on the remote for origin or upstream | |
git branch | grep -v "$(git branch --remote | grep -e "origin/\|upstream/" | grep -v "\->" | cut -d/ -f2)" | |
# Here's another one to check. checks your local master and gives any branches that are merged to master | |
git branch --merged=master | grep -v master |
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
var POW31 = 0x80000000 | |
var MSK31 = 0x7FFFFFFF | |
function checkBitSize(bs) { | |
if (bs > 53 || bs < 1 || Math.floor(bs) !== bs) { | |
throw new Error('Invalid Bit Size') | |
} | |
} | |
function splitBits(val, size) { |
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
class CBOREncoder { | |
private entryCount: number = 0; | |
private data: Uint8Array = Uint8Array.from([]); | |
pushBool(key: string, value: boolean): void { | |
this.entryCount++; | |
this.pushTextInternal(key); | |
this.pushBoolInternal(value); | |
} |
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
/* | |
* input: "wpkh([d34db33f/84h/0h/0h]0279be667ef9dcbbac55a06295Ce870b07029Bfcdb2dce28d959f2815b16f81798)" | |
* output: "wpkh([d34db33f/84h/0h/0h]0279be667ef9dcbbac55a06295Ce870b07029Bfcdb2dce28d959f2815b16f81798)#qwlqgth7" | |
* (This has been checked to match bitcoin-core) | |
*/ | |
function descriptorChecksum(desc) { | |
if (!(typeof desc === 'string' || desc instanceof String)) throw new Error('desc must be string') | |
const descParts = desc.match(/^(.*?)(?:#([qpzry9x8gf2tvdw0s3jn54khce6mua7l]{8}))?$/); | |
if (descParts[1] === '') throw new Error('desc string must not be empty') |
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
# This is one big command. Fill it out in a text editor and copy-paste | |
# the whole thing to get tls.key and tls.cert files for use with lnd | |
openssl \ | |
req \ | |
-newkey ec:<(openssl ecparam -name prime256v1) \ | |
-nodes `# No password` \ | |
-keyout \ | |
tls.key `# private key filename` \ | |
-x509 \ |
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
// Mimics Buffer.from(x, 'hex') logic | |
// Stops on first non-hex string and returns | |
// https://github.com/nodejs/node/blob/v14.18.1/src/string_bytes.cc#L246-L261 | |
Uint8Array.fromHex = function (hexString) { | |
const MAP_HEX = {0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15}; | |
const bytes = new this(Math.floor((hexString || "").length / 2)); | |
let finalLen = bytes.length; | |
for (let i = 0; i < finalLen; i++) { | |
const a = MAP_HEX[hexString[i * 2]]; | |
const b = MAP_HEX[hexString[i * 2 + 1]]; |