Skip to content

Instantly share code, notes, and snippets.

View zhfnjust's full-sized avatar
💭
bitcoin sv is everything

hh zhfnjust

💭
bitcoin sv is everything
View GitHub Profile
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
/**
* The UUIDS have been collected from the following sources:
* <p>
* - http://developer.nokia.com/community/wiki/Bluetooth_Services_for_Windows_Phone
* - The Bluez project
@zhfnjust
zhfnjust / DemoP2PKH.js
Created November 6, 2020 15:25
sCrypt DemoP2PKH
contract DemoP2PKH {
Ripemd160 pubKeyHash;
constructor(Ripemd160 pubKeyHash) {
this.pubKeyHash = pubKeyHash;
}
public function unlock(Sig sig, PubKey pubKey) {
require(hash160(pubKey) == this.pubKeyHash);
require(checkSig(sig, pubKey));
@zhfnjust
zhfnjust / p2pkh.scrypttest.js
Last active November 7, 2020 01:47
p2pkh unit test
const { expect } = require('chai');
const { bsv, buildContractClass, Ripemd160, Sig, PubKey, signTx, toHex } = require('scryptlib');
/**
* an example test for contract containing signature verification
*/
const { compileContract, inputIndex, inputSatoshis, tx } = require('../../helper');
const privateKey = new bsv.PrivateKey.fromRandom('testnet')
const publicKey = privateKey.publicKey
@zhfnjust
zhfnjust / p2pkh.launch.json
Created November 7, 2020 02:07
p2pkh debug launch config
{
"type": "scrypt",
"request": "launch",
"name": "Debug P2PKH",
"program": "${workspaceFolder}/contracts/p2pkh.scrypt",
"constructorParams": "Ripemd160(b'92474c7477ba646adfb72ebe6347bfa233887086')",
"entryMethod": "unlock",
"entryMethodParams": "Sig(b'3045022100f6d1c4713177da22dc9287ba130706bd0edab214f63fdf9f6022ec96f9a1241002203214181dc70800333a5e4a97f7ff9f067a4f90e84abd76b105d08e39d3b01dbf41'), PubKey(b'033055b67fd1620569c3209950a627898c01905a8d8ef85230f1d0e89e9d877d7b')",
"txContext": {
"hex": "01000000015884e5db9de218238671572340b207ee85b628074e7e467096c267266baf77a40000000000ffffffff0000000000",
/*
* print out parameters used in debugger, see ""../.vscode/launch.json" for an example
console.log(toHex(pkh))
console.log(toHex(sig))
console.log(toHex(publicKey))
console.log(tx.toString())
*/
const { buildContractClass, toHex, signTx, Ripemd160, Sig, PubKey, bsv } = require('scryptlib');
const {
createLockingTx,
createUnlockingTx,
sendTx,
showError,
loadDesc
} = require('../helper')
{
"version": 3,
"compilerVersion": "0.4.3+commit.5c8a86d",
"contract": "Demo",
"md5": "0c4f4b3e2ba282b171f8d1f0685c55b4",
"buildTypes": "debug",
"structs": [],
"alias": [],
"abi": [
{
@zhfnjust
zhfnjust / txAdvancedArgs.js
Created November 16, 2021 16:01 — forked from scrypt-sv/txAdvancedArgs.js
A simple program to compute arguments for contract TxAdvanced
/*
* a simple program to compute arguments for contract TxAdvanced
*/
const bsv = require('bsv')
const BN = bsv.crypto.BN
const pt = bsv.crypto.Point
const G = pt.getG()
const N = pt.getN()
@zhfnjust
zhfnjust / rawtx.hex
Created October 19, 2022 12:23
[script is too big ] happend when boardcasting transation
0100000002b0da8d4b4d27856ba30d00a11933c48978dc7b23f76b748d63264fbb5eae128700000000fd5a0320b65bda374ea6213cd4aa1db878c63ad75847a5f599694dfbdb64b194c2712306207dadae0de01794cf196a807b3c817db12a58476c17fd177d68438c4e45e0b22e20bfca36a4b014a415abde0de011677f71cce98b744d85b4373a6db2abf6f4612f20e4043224f4d8ef84028fac98a889d4eea720ca773cb17a267b04954e7e54d70e2070535e538ccfd59a19265df19167fc6752e0e97ef08e36c7440df420b11d471b20aeae4ff8d1bfe8c0738383b662bc9e7c6ba55138ed131bbcae3b0a4375badf20204302a29959fbc715eba9e51f7a45a0fa8c6dd90496b97041ca3e99b0993d7413208702aed399a897e0e475fa01cd6b371092b148026c89b270f29bc525c6a26b2120cd011634b8fa236a7fcd5db3d4648e15681cda415b3e1b295da1773e63dbc40820df3e10de08923be9f8f7ff95942381d673fda79218695df654cf63ea612e481720de9ca828a68f5752fcc24498303dc29952a88a6a6e06af7715fbc842d84d3b04205f5c74fbd057f71fe327f3d1e49450d3ec8c7f76b7f05c58b6ef80de9353c02a20cc349b57f76fb812b4d06443a2baa6ceab7f99112be761a435dde0682b73732a2015f25c7ba8cd75beed9b128043c125e1586b6d7526b15cd4be53c1ad6158c91f20ff90c400c1