https://github.com/getbitpocket/electrum-network-plugin
Cordova plugin for accessing the electrum/bitcoin network
https://github.com/getbitpocket/electrum-network-plugin
bitcoin cordova cordova-plugin electrum
Last synced: about 1 month ago
JSON representation
Cordova plugin for accessing the electrum/bitcoin network
- Host: GitHub
- URL: https://github.com/getbitpocket/electrum-network-plugin
- Owner: getbitpocket
- License: apache-2.0
- Created: 2016-04-03T18:34:34.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-11-13T14:52:37.000Z (over 9 years ago)
- Last Synced: 2025-01-16T09:07:27.016Z (over 1 year ago)
- Topics: bitcoin, cordova, cordova-plugin, electrum
- Language: TypeScript
- Homepage:
- Size: 227 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cordova Plugin for accessing Electrum network servers
Electrum network protocol documentation can be found here: [http://docs.electrum.org/en/latest/protocol.html](http://docs.electrum.org/en/latest/protocol.html)
## Installation
- Add the Plugin to your Cordova project: `cordova plugin add https://github.com/getbitpocket/electrum-network-plugin`
- Depending on the Promise support of your target environment (http://caniuse.com/#feat=promises), the [es6-shim](https://github.com/paulmillr/es6-shim) javascript library might be included
## Quick Examples
### Example: Init Network, discover peers and send a request to a random network peer
```javascript
var networkDiscovery = new electrum.NetworkDiscovery();
networkDiscovery.init();
networkDiscovery.on('peers:discovered', function() {
networkDiscovery.sendRandomRequest({ "id": 1, "method":"blockchain.address.get_balance", "params":["1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L"] });
networkDiscovery.on('peers:response', function(response) {
console.log(response);
});
});
```
### Example: Connect to a peer and send a request
```javascript
var peer = new electrum.Peer('some.electrum.server.com', 50002);
peer.connect();
peer.on('connected', function() {
peer.sendRequest({ "id": 1, "method":"blockchain.address.get_balance", "params":["1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L"] });
peer.on('response', function(response) {
console.log(response);
});
});
```
## Build Project
`npm install`
`npm run build`
## Running Unit Tests
`npm install`
`npm test`
## Running Integration Tests
- `npm install`
- `npm run integration -- run android` or `npm run integration -- run ios` for testing on real devices
- `npm run integration -- emulate android` or `npm run integration -- emulate ios` for testing on emulator
## Roadmap
- This plugin should also work with altcoins, which support electrum
- Observable (rx.js) rather of Promise for Requests