Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NetworkMonitor class #444

Merged
merged 9 commits into from Jul 24, 2014
Merged

Conversation

maraoz
Copy link
Contributor

@maraoz maraoz commented Jul 21, 2014

This PR adds a new class: NetworkMonitor.

The idea is to have a simpler interface than PeerManager to listen to bitcoin network events.

Simlpe usage example:

var config = {
  networkName: 'testnet',
  host: 'localhost',
  port: 18333
};

var nm = new NetworkMonitor.create(config);

// monitor incoming transactions to http://tpfaucet.appspot.com/ donation address
nm.incoming('msj42CCGruhRsFrGATiUuh25dtxYtnpbTx', function(tx) {
  console.log('Donation to tpfaucet! '+JSON.stringify(tx.getStandardizedObject()));
});

// connect to bitcoin network and start listening
nm.start();

This PR also adds some refactoring and convenience methods for other classes. Most importantly:

  • Address.fromScriptSig, extracts an address from a transaction's scriptSig
  • Transaction.getReceivingAddresses, returns a list of addresses that received coins in a given transaction
  • Transaction.getSendingAddresses, returns a list of addresses that sent coins in a given transaction

@ryanxcharles
Copy link
Contributor

Awesome. Will review soon.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.37%) when pulling c4de367 on maraoz:add/NetworkMonitor into b172248 on bitpay:master.

@ryanxcharles
Copy link
Contributor

Pulling in due to offline discussion.

ryanxcharles pushed a commit that referenced this pull request Jul 24, 2014
@ryanxcharles ryanxcharles merged commit 0bcdb7c into bitpay:master Jul 24, 2014
@maraoz maraoz deleted the add/NetworkMonitor branch March 13, 2015 15:24
micahriggan pushed a commit to micahriggan/bitcore that referenced this pull request Dec 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants