Skip to content

Instantly share code, notes, and snippets.

View pinheadmz's full-sized avatar
🕺

Matthew Zipkin pinheadmz

🕺
  • port 8333
View GitHub Profile
Verifying that +pinheadmz is my blockchain ID. https://onename.com/pinheadmz

Keybase proof

I hereby claim:

  • I am pinheadmz on github.
  • I am pinheadmz (https://keybase.io/pinheadmz) on keybase.
  • I have a public key ASASo_ygLPme3aWwR3bYt0LPgyl0YHHfxhfJMPvQiT6VLwo

To claim this, I am signing this object:

const bcoin = require('bcoin').set('regtest');
const NetAddress = bcoin.net.NetAddress;
const Network = bcoin.Network;
const assert = require('assert');
async function delay(ms) {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
}
@pinheadmz
pinheadmz / bcoin tx-mess
Created January 24, 2019 17:55
Script that uses bclient to generate lots of txs and blocks for bcoin testing
'use strict';
const bcoin = require('bcoin');
const client = require('bclient');
const network = bcoin.Network.get(process.env.BCOIN_NETWORK);
const walletClient = new client.WalletClient({
port: network.walletPort,
apiKey: process.env.BCOIN_WALLET_API_KEY
});
/*
* Packet sniffer plgin for bcoin
* USAGE:
* bcoin --log-console=false --plugins <path/to/packetsniffer.js>
*/
'use strict';
const EventEmitter = require('events');
  1. Create new file test.html with the following single line:

<script src='bcoin.js'></script>

  1. Bundle bcoin
$ npm install -g bpkg
$ bpkg --browser --standalone --name BCOIN --output /path/adjacent/to/html/file/bcoin.js /git/repo/bcoin/lib/bcoin.js
0000a8030a526567697374657265640477697468086e616d656261736501344765080d0980208120822e696f2f
version 00
ttl 00a8 10752 seconds (~3 hours)
decompressor count 03
word 1 length 0a
word 1 52656769737465726564 Registered
'use strict';
const bcoin = require('bcoin');
const plugin = bcoin.wallet.plugin;
const network = bcoin.Network.get('regtest');
const client = require('bclient');
const {MTX, Input, Outpoint} = bcoin;
const random = require('bcrypto/lib/random');
const walletClient = new client.WalletClient({
'use strict';
const bcoin = require('bcoin');
const client = require('bclient');
const plugin = bcoin.wallet.plugin;
const network = bcoin.Network.get('regtest');
// create full node
const node = new bcoin.FullNode({
network: 'regtest',
$ bitcoin-cli getblock 0000000000000000000b47042b90c6a893e6e5cdef70c92beefb88f4c5fa5a69 3
{
"hash": "0000000000000000000b47042b90c6a893e6e5cdef70c92beefb88f4c5fa5a69",
"confirmations": -1,
"strippedsize": 298,
"size": 334,
"weight": 1228,
"height": 584802,
"version": 541065216,
"versionHex": "20400000",