Giter VIP home page Giter VIP logo

mempool-dat's Introduction

mempool-dat

GoDoc

This Go package parses bitcoin mempool mempool.dat files. These are wirtten by Bitcoin Core v0.14+ on shutdown and since v0.16.0 with the RPC savemempool.

The package offers access to the mempool.dat

  • header: version and number of transactions
  • mempool entries: raw transaction (here parsed as btcsuite/btcd/wire MsgTx), first seen timestamp and the feeDelta
  • and the not-parsed mapDeltas as byte slices

You may see this package as Work-In-Progress. There are no tests yet.

Example usage

For a runnable version of this snippet see main.go.

import (
  "fmt"
  mempoolDat "github.com/0xb10c/mempool-dat/lib"
)

[...]

const path string = "mempool.dat"

[...]

// please handle errors, omitted for brevity 
mempool, _ := mempoolDat.ReadMempoolFromPath(path)

// prints the version and number of tx
fmt.Println(mempool.GetFileHeader())

// get all mempool entries with GetMempoolEntries (here only the first three are used)
for _, e := range mempool.GetMempoolEntries()[:3]{
  fmt.Println(e.Info())
}

// get the firstSeen timestamp of a transaction
fmt.Println(mempool.GetMempoolEntries()[4].GetFirstSeen())

/* Furthermore you can use the full functionality of MsgTx (https://godoc.org/github.com/btcsuite/btcd/wire#MsgTx):
    - transaction has a witness (spends a SegWit output)? with <entry>.transaction.HasWitness() 
    - access input and outputs
    - ...
    But there is no way to get feerates for transactions, because they are (rightfully) not stored in the `mempool.dat`.
    You'd have to the current UTXO set to get input amounts (which you need to calculate the fees)
*/

The full documentation can be fund on https://godoc.org/github.com/0xB10C/mempool-dat/lib.

mempool-dat's People

Contributors

0xb10c avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.