Giter Site home page Giter Site logo

enkrona / abcdi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dodo721/abcdi

0.0 2.0 0.0 12 KB

A module for NodeJS for interacting with any crypto daemon CLI that uses bitcoin-based commands on a per-address basis.

License: MIT License

JavaScript 100.00%

abcdi's Introduction

ABCDi

The Address Based Crypto Daemon Interaction module for NodeJS provides interaction with crypto daemon CLIs while treating crypto addresses as separate accounts, and provides functionalities for miner fees and company fees. It is currently only Linux compatible.

Note: the config file is currently set as an example for Garlicoin, but it can be used with any crypto using Bitcoin commands.

Address Based

The key focus of this module is that it is entirely address-based. In traditional crypto, the daemon links addresses all to their original account and then when making transactions from the account takes currency from any addresses linked, meaning normally a separate wallet would have to be created for every user. ABCDi solved this problem by treating each address as a separate account, so that when a transaction is made it is withdrawn only from one address, not any linked to the same account. This makes generating online "wallets" easy, as only 1 wallet needs to be set up for the service then each user can simply get a generated address from that wallet, another feature inbuilt into the module.

Functionality

This module can currently:

  • Generate online "wallets" for users under one address each
  • Create transactions between accounts, giving custom options for mining fees, and taking fees for profit.
  • Check balances of specific addresses linked to the online account
  • Validate crypto addresses
  • Create raw transactions step by step (ONLY IF YOU KNOW HOW!)

Development

Features will be added frequently as they are thought of / suggested.

Setup

Upload your crypto executeables to a directory on your server, and set it up like a normal wallet. Make sure the daemon is running (usually called [crypto name]d)! Upload abcdi.js and abcdi-conf.json to any directory, so long as they are in the same directory. Then in abcdi-conf.json, change path to the filepath of the cli executeable (usually called [crypto name]-cli). Change company_wallet to the address you want profits to send to. See Documentation for more details and descriptions of the other options. Once set up, simply require ("abcdi") from whatever directory it lies in for use.

Documentation

Functions

generateAddress ( )

Generate an address for a user to be treated as a separate account. Returns a promise which is fullfilled with the address string.

checkBalance ( addr, min_conf )

Check the balance of an address from transactions with a minimum confirmation of min_conf. Returns a promise which is fullfilled with the balance.

validateAddress ( addr )

Check if the given address is a valid crypto address. Returns a promise which is fullfilled with the result (boolean).

transferFromToAddress ( from_addr, to_addr, amount, take_fees, fees_from_sender )

Creates and sends a transaction of amount coins from from_addr to to_addr. If take_fees is true, a fraction of the transaction determined by company_fee in abcdi-conf.json will be automatically deducted from the transaction and added to the company wallet determined by company_wallet in abcdi-conf.json. The miner fee is specified by miner_fee in abcdi-conf.json as a set amount. If fees_from_sender is true, miner fees will be taken from the sender (so the sender sends more), if false the fees are taken from the recipient (so they receive less coins instead). Returns a promise fullfilled with the TXID of the transaction. Will reject with "balance_low" if from_addr does not have enough balance.

Warning: The following are functions for creating raw transactions. Use only if you know how!

createRawTransaction ( from_addr, to_addr, amount, take_fees, fees_from_sender, callback )

Creates a raw transaction with the same parameters as transferFromToAddress. Calls callback ( err, tx_hex, input_txs ) were err is any error ("balance_low" if from_addr does not have enough balance), tx_hex is the hex of the transaction data and input_txs is an array of objects representing the unspent transactions used.

signRawTransaction ( tx_hex, from_addr, input_txs, callback )

Signs a created raw transaction with sender from_addr. tx_hex is the hex of the raw transaction data, and input_txs is an array of objects representing the unspent transactions used. Calls callback ( err, tx_signed_hex ) where err is any error and tx_signed_hex is the hex of the signed transaction data.

sendRawTransaction ( tx_signed_hex, callback )

Sends a created and signed raw transaction with data provided by tx_signed_hex. Calls callback ( err, txid ) where err is any error and txid is the TXID of the resulting transaction.

Config

  • path: The path to the crypto daemon CLI executeable, e.g. "bitcoin/bin/bitcoin-cli" (must omit file extension)
  • company_wallet: The wallet to transfer company fees to
  • miner_fee: The fixed rate fee for mining (higher fee = quicker confirmation time)
  • company_fee: The fraction of a transaction to take as a company fee (if the transaction has take_fees set to true)

abcdi's People

Contributors

dodo721 avatar

Watchers

James Cloos avatar Bradley Taylor avatar

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.