Skip to content

Instantly share code, notes, and snippets.

Avatar

Xiaohui Liu xhliu

View GitHub Profile
@xhliu
xhliu / deriveAddress.js
Last active Apr 28, 2021
A simple demo for derived bitcoin addresses
View deriveAddress.js
// Copyright (c) 2020 Xiaohui Liu.
// Use of this source code is governed by a MIT-style license.
// This is an implementation of https://craigwright.net/blog/bitcoin-blockchain-tech/offline-addressing
// For more info, also see Episode 4 of Bitcoin Class with Satoshi: Extended Address https://youtu.be/rezvcJ4j-7U
const bsv = require('bsv');
const BN = bsv.crypto.BN
const Hash = bsv.crypto.Hash
const G = bsv.crypto.Point.getG()
const N = bsv.crypto.Point.getN()
@xhliu
xhliu / scriptEval.js
Last active Dec 2, 2019
Sample code to evaluate bitcoin script using Bitcoin SV Library (bsv) https://docs.moneybutton.com/docs/bsv-overview.html
View scriptEval.js
let bsv = require('bsv')
const slockStr = "OP_2 OP_EQUAL"
const slock = bsv.Script.fromASM(slockStr)
console.log("\nLocking script loaded\n")
const sunlockStr = "OP_2"
const sunlock = bsv.Script.fromASM(sunlockStr)
console.log("\nUnlocking script loaded\n")