Skip to content

Instantly share code, notes, and snippets.

Avatar
🤔

TANAKA, Koutarou fkfk

🤔
View GitHub Profile
View calc_txfee_multisig.js
const pushdata = require('pushdata-bitcoin')
const MAX_SIGNATURE_SIZE = 73
const COMPRESSED_PUBKEY_SIZE = 33
const VERSION_SIZE = 4
const LOCKTIME_SIZE = 4
// txin size
const PREVIOUS_OUTPUT_SIZE = 36
View verify-message-by-bitcoinjs-message.js
const bitcoinMessage = require('bitcoinjs-message')
const messagePrefix = "\x19Monacoin Signed Message:\n"
const address = 'MU4FQNVv75wEU5a2TTBs7ZRMrpHU5nLEk5'
const message = 'hello'
const signature = 'IPL7L5NAMAPnLYFIeUaFAddK+IaFi9Q0FdsoMft2gl3IDdeUzBttq/kcUQz1AkiW32ohIGpXVrqH5VeO9B3CMtc='
console.log(bitcoinMessage.verify(message, address, signature, messagePrefix))
View monacoin.dart
import 'package:bitcoin_flutter/bitcoin_flutter.dart';
import 'package:bip32/bip32.dart' as bip32;
import 'package:bip39/bip39.dart' as bip39;
final MONACOIN = new NetworkType(
messagePrefix: '\x19Monacoin Signed Message:\n',
bech32: 'mona',
bip32: new Bip32Type(
public: 0x0488b21e,
private: 0x0488ade4
@fkfk
fkfk / sig.js
Last active Sep 11, 2019
test multisig
View sig.js
const bitcoin = require('bitcoinjs-lib')
// for testnet
/*
const network = {
messagePrefix: '\x19Monacoin Signed Message:\n',
bip32: {
public: 0x043587cf,
private: 0x04358394
},
View mpurse-addr.js
const {
bip32,
payments
} = require('bitcoinjs-lib')
const mnemonic = require('./external/mnemonic.js') // https://github.com/ggozad/mnemonic.js
const buffer = require("safe-buffer")
const words = "like like like like like like like like like like like like" // your mnemonic
const network = {
bip32: {
@fkfk
fkfk / index.html
Created Jun 1, 2019
mpurse sign message example
View index.html
<!DOCTYPE html>
<html lang="ja">
<head>
<title>mpurse sign message example</title>
<meta charset="UTF-8">
</head>
<body>
<script>
window.addEventListener("load", async (ev) => {
if (window.mpurse) {
@fkfk
fkfk / index.js
Created Mar 2, 2019
connect ElectrumX server
View index.js
const Socket = require('json-rpc-tls').Socket;
Socket.tlsSocket('electrum-mona.nope.work', 50002, {
rejectUnauthorized: false
}).then(async (socket) => {
socket.setEncoding('utf8')
socket.setKeepAlive(true, 0)
socket.setNoDelay(true)
const banner = await Socket.request(socket, 1, 'server.banner', [])
View promise_callback.js
/**
* fnBの前に実行したい処理
* コールバックを引数として取る
**/
function fnA (successCb, failedCb) {
let result = foo()
if (result) {
successCb(result)
} else {
failedCb(new Error('fnA error'))
@fkfk
fkfk / array_reverse.js
Last active Sep 22, 2018
Safari 12 Array.prototype.reverse bug
View array_reverse.js
let fn = () => {
let array = [1, 2, 3, 4, 5]
console.log(array)
array.reverse()
}
fn() // => [1, 2, 3, 4, 5]
fn() // I expect to be `[1, 2, 3, 4, 5]`, but in the case of Safari 12 it will be `[5, 4, 3, 2, 1]`
View bip21_vips.html
<html>
<head></head>
<body>
<a href="vipstarcoin:VYLPUGaj6WzXTsbcyigAYGV7TNWgyAyNTx?amount=1.00000000&label=BIP21%20URI%20Scheme%20test&message=hello%2C%20VIPSTARCOIN%21">ここをクリックすると製作者さんに1VIPSが!!!!</a>
</body>
</html>