GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - pmitchev/difficulty-lock

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

7 Commits
7 Commits

Folders and files

NameName
Last commit message
Last commit date
.husky
.husky
 
 
.vscode
.vscode
 
 
src/contracts
src/contracts
 
 
tests
tests
 
 
.env.example
.env.example
 
 
.eslintcache
.eslintcache
 
 
.eslintignore
.eslintignore
 
 
.eslintrc
.eslintrc
 
 
.gitignore
.gitignore
 
 
.mocharc.json
.mocharc.json
 
 
.npmignore
.npmignore
 
 
.prettierignore
.prettierignore
 
 
.prettierrc
.prettierrc
 
 
.travis.yml
.travis.yml
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
deploy.ts
deploy.ts
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
tsconfig.json
tsconfig.json
 
 

Repository files navigation

DifficultyLock

Build

npm run build

Testing Locally

npm run test

Run Tests on the Bitcoin Testnet

npm run test:testnet

Config

static readonly MAX_HEADERS = 52n
// maximum number of block headers that can be processed in a single transaction call
// 52596n = 1 year's worth of blocks at 10 minutes per block.
// Smaller values will produce a smaller bitcoin transactions, but recordBlocks
// will need to be called more timesin order to unlock the contract

Methods

Constructor

  • benificiary: Addr - recipient of funds if difficulty is reached
  • issuer: Addr - issuer of contract
  • satoshis: bigint - satoshis being locked in contract
  • prevHeader: ByteString - previous block header. Submit header from few blocks back to ensure a reorg does not invalidate contract
  • prevHeight: bigint - height associated with previous block header
  • targetDifficulty: bigint - Difficulty which much be acheived to unlock contract
  • requiredTargetCount: bigint - number of blocks at target difficulty required
  • expirationHeight: bigint - Block height at which issuer can refund the contract

recordBlocks

  • sig: Sig - beneficiary signature
  • pubkey: PubKey - beneficiary pubkey
  • headers: ByteString - Up to MAX_HEADERS 80-byte block headers
  • trailingOuts: ByteString - Transaction outputs after the contract output and before change output.

refund

  • sig: Sig - issuer signature
  • pubkey: PubKey - issuer pubkey nLockTime must be on or after expiration height nSequence must be less that 0xffffffff

transferBenificiary

  • sig: Sig - beneficiary signature
  • pubkey: PubKey - beneficiary pubkey
  • benificiary: Addr - new beneficiary pubkeyhash
  • trailingOuts: ByteString - Transaction outputs after the contract output and before change output.

transferIssuer

  • sig: Sig - issuer signature
  • pubkey: PubKey - old issuer pubkey
  • issuer: Addr - new issuer pubkeyhash
  • trailingOuts: ByteString - Transaction outputs after the contract output and before change output.

Convert to target from bits field in block

static bits2Target(bits: ByteString): bigint {
    const exponent = Utils.fromLEUnsigned(slice(bits, 3n))
    const coefficient = Utils.fromLEUnsigned(slice(bits, 0n, 3n))
    const n = 8n * (exponent - 3n)
    return lshift(coefficient, n)
}

Bounty Payments

1shrgL5Hd3XDnm8AChvKmi1nFpkVa6kxz

About

No description, website, or topics provided.

Resources

Readme
License
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.