GithubHelp home page GithubHelp logo

atomiclabs / get-komodo-rewards Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 3.0 343 KB

Calculate the accrued rewards for a given Komodo UTXO

License: MIT License

JavaScript 89.20% Shell 10.80%
kmd komodo rewards interest cryptocurrency

get-komodo-rewards's Introduction

get-komodo-rewards

Calculate the accrued rewards for a given Komodo UTXO

Build Status codecov npm

Calculates the rewards in satoshis for a given Komodo UTXO. Heavily tested and 100% compliant with komodod consensus.

Originally built for our Ledger KMD Reward Claim app. Released as a re-usable module for the benefit of the Komodo ecosystem.

Install

npm install get-komodo-rewards

Usage

Pass in a utxo object and an integer of the accrued rewards in satoshis will be returned.

const getKomodoRewards = require('get-komodo-rewards');

const utxo = {
  tiptime: 1552292091,
  locktime: 1552248193,
  height: 1263192,
  satoshis: 3206795322480
};

const rewards = getKomodoRewards(utxo);
// 205000320

Tip

tiptime should be the current tiptime from komodod.

If you don't have access to this you can use a client-side generated UNIX timestamp at the cost of slightly reduced accuracy. If you do this, use a timestamp ~10 minutes in the past to avoid over calculating the rewards and creating an invalid transaction.

API

getKomodoRewards(utxo)

Returns a the accrued rewards in satoshis.

utxo

Type: Object

An object containing the following properties of the UTXO:

tiptime

Type: number

The current tiptime of the Komodo blockchain.

locktime

Type: number

The locktime value of the UTXO.

height

Type: number

The height of the UTXO.

satoshis

Type: number

The value of the UTXO in satoshis.

License

MIT © Atomic Labs
MIT © Luke Childs

get-komodo-rewards's People

Contributors

lukechilds avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

jl777 gcharang

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.