Merge pull request #568 from heath/fix/language-identifiers
remove whitespace, add js language identifiers
This commit is contained in:
commit
38b69f4bfc
191
examples.md
191
examples.md
@ -1,4 +1,7 @@
|
|||||||
#Address.js
|
#Address.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
@ -27,8 +30,12 @@
|
|||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
#Armory.js
|
#Armory.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
var Armory = require('../lib/Armory');
|
var Armory = require('../lib/Armory');
|
||||||
var Address = require('../lib/Address');
|
var Address = require('../lib/Address');
|
||||||
|
|
||||||
@ -94,8 +101,12 @@
|
|||||||
console.log(Address.fromPubKey(b.pubkey).as('base58'));
|
console.log(Address.fromPubKey(b.pubkey).as('base58'));
|
||||||
b = b.next();
|
b = b.next();
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
#ConnectionTor.js
|
#ConnectionTor.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
var Peer = require('../lib/Peer');
|
var Peer = require('../lib/Peer');
|
||||||
var Connection = require('../lib/Connection');
|
var Connection = require('../lib/Connection');
|
||||||
var dns = require('dns');
|
var dns = require('dns');
|
||||||
@ -133,8 +144,12 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
```
|
||||||
|
|
||||||
#CreateAndSignTx-Multisig.js
|
#CreateAndSignTx-Multisig.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
var run = function() {
|
var run = function() {
|
||||||
bitcore = typeof(bitcore) === 'undefined' ? require('../bitcore') : bitcore;
|
bitcore = typeof(bitcore) === 'undefined' ? require('../bitcore') : bitcore;
|
||||||
var networks = require('../networks');
|
var networks = require('../networks');
|
||||||
@ -155,6 +170,7 @@
|
|||||||
address: input.addr,
|
address: input.addr,
|
||||||
txid: "39c71ebda371f75f4b854a720eaf9898b237facf3c2b101b58cd4383a44a6adc",
|
txid: "39c71ebda371f75f4b854a720eaf9898b237facf3c2b101b58cd4383a44a6adc",
|
||||||
vout: 1,
|
vout: 1,
|
||||||
|
ts: 1396288753,
|
||||||
scriptPubKey: "76a914e867aad8bd361f57c50adc37a0c018692b5b0c9a88ac",
|
scriptPubKey: "76a914e867aad8bd361f57c50adc37a0c018692b5b0c9a88ac",
|
||||||
amount: 0.4296,
|
amount: 0.4296,
|
||||||
confirmations: 2
|
confirmations: 2
|
||||||
@ -204,6 +220,7 @@
|
|||||||
address: input.addr,
|
address: input.addr,
|
||||||
txid: "e4bc22d8c519d3cf848d710619f8480be56176a4a6548dfbe865ab3886b578b5",
|
txid: "e4bc22d8c519d3cf848d710619f8480be56176a4a6548dfbe865ab3886b578b5",
|
||||||
vout: 0,
|
vout: 0,
|
||||||
|
ts: 1396288753,
|
||||||
scriptPubKey: scriptPubKey,
|
scriptPubKey: scriptPubKey,
|
||||||
amount: 0.05,
|
amount: 0.05,
|
||||||
confirmations: 2
|
confirmations: 2
|
||||||
@ -241,8 +258,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
////
|
////
|
||||||
|
```
|
||||||
|
|
||||||
#CreateAndSignTx-PayToPubkeyHash.js
|
#CreateAndSignTx-PayToPubkeyHash.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
var run = function() {
|
var run = function() {
|
||||||
bitcore = typeof(bitcore) === 'undefined' ? require('../bitcore') : bitcore;
|
bitcore = typeof(bitcore) === 'undefined' ? require('../bitcore') : bitcore;
|
||||||
|
|
||||||
@ -255,6 +276,7 @@
|
|||||||
address: "mqSjTad2TKbPcKQ3Jq4kgCkKatyN44UMgZ",
|
address: "mqSjTad2TKbPcKQ3Jq4kgCkKatyN44UMgZ",
|
||||||
txid: "2ac165fa7a3a2b535d106a0041c7568d03b531e58aeccdd3199d7289ab12cfc1",
|
txid: "2ac165fa7a3a2b535d106a0041c7568d03b531e58aeccdd3199d7289ab12cfc1",
|
||||||
vout: 1,
|
vout: 1,
|
||||||
|
ts: 1394719301,
|
||||||
scriptPubKey: "76a9146ce4e1163eb18939b1440c42844d5f0261c0338288ac",
|
scriptPubKey: "76a9146ce4e1163eb18939b1440c42844d5f0261c0338288ac",
|
||||||
amount: 0.01,
|
amount: 0.01,
|
||||||
confirmations: 2
|
confirmations: 2
|
||||||
@ -315,8 +337,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
////
|
////
|
||||||
|
```
|
||||||
|
|
||||||
#CreateAndSignTx-PayToScriptHash.js
|
#CreateAndSignTx-PayToScriptHash.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
var run = function() {
|
var run = function() {
|
||||||
bitcore = typeof(bitcore) === 'undefined' ? require('../bitcore') : bitcore;
|
bitcore = typeof(bitcore) === 'undefined' ? require('../bitcore') : bitcore;
|
||||||
var networks = require('../networks');
|
var networks = require('../networks');
|
||||||
@ -338,6 +364,7 @@
|
|||||||
address: "n2hoFVbPrYQf7RJwiRy1tkbuPPqyhAEfbp",
|
address: "n2hoFVbPrYQf7RJwiRy1tkbuPPqyhAEfbp",
|
||||||
txid: "e4bc22d8c519d3cf848d710619f8480be56176a4a6548dfbe865ab3886b578b5",
|
txid: "e4bc22d8c519d3cf848d710619f8480be56176a4a6548dfbe865ab3886b578b5",
|
||||||
vout: 1,
|
vout: 1,
|
||||||
|
ts: 1396290442,
|
||||||
scriptPubKey: "76a914e867aad8bd361f57c50adc37a0c018692b5b0c9a88ac",
|
scriptPubKey: "76a914e867aad8bd361f57c50adc37a0c018692b5b0c9a88ac",
|
||||||
amount: 0.3795,
|
amount: 0.3795,
|
||||||
confirmations: 7
|
confirmations: 7
|
||||||
@ -402,6 +429,7 @@
|
|||||||
address: p2shAddress,
|
address: p2shAddress,
|
||||||
txid: "c2e50d1c8c581d8c4408378b751633f7eb86687fc5f0502be7b467173f275ae7",
|
txid: "c2e50d1c8c581d8c4408378b751633f7eb86687fc5f0502be7b467173f275ae7",
|
||||||
vout: 0,
|
vout: 0,
|
||||||
|
ts: 1396375187,
|
||||||
scriptPubKey: scriptPubKey,
|
scriptPubKey: scriptPubKey,
|
||||||
amount: 0.05,
|
amount: 0.05,
|
||||||
confirmations: 1
|
confirmations: 1
|
||||||
@ -466,8 +494,12 @@
|
|||||||
} else {
|
} else {
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
#CreateKey.js
|
#CreateKey.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
@ -516,8 +548,12 @@
|
|||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
#CreateScript.js
|
#CreateScript.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var run = function() {
|
var run = function() {
|
||||||
@ -594,8 +630,12 @@
|
|||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
#ECIES.js
|
#ECIES.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
var run = function() {
|
var run = function() {
|
||||||
bitcore = typeof(bitcore) === 'undefined' ? require('../bitcore') : bitcore;
|
bitcore = typeof(bitcore) === 'undefined' ? require('../bitcore') : bitcore;
|
||||||
|
|
||||||
@ -626,8 +666,12 @@
|
|||||||
} else {
|
} else {
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
#ElectrumMPK.js
|
#ElectrumMPK.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
var Electrum = require('../lib/Electrum');
|
var Electrum = require('../lib/Electrum');
|
||||||
var Address = require('../lib/Address');
|
var Address = require('../lib/Address');
|
||||||
|
|
||||||
@ -639,8 +683,12 @@
|
|||||||
var addr0 = Address.fromPubKey(key0);
|
var addr0 = Address.fromPubKey(key0);
|
||||||
|
|
||||||
console.log(addr0.as('base58'));
|
console.log(addr0.as('base58'));
|
||||||
|
```
|
||||||
|
|
||||||
#HierarchicalKey.js
|
#HierarchicalKey.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
var run = function() {
|
var run = function() {
|
||||||
bitcore = typeof(bitcore) === 'undefined' ? require('../bitcore') : bitcore;
|
bitcore = typeof(bitcore) === 'undefined' ? require('../bitcore') : bitcore;
|
||||||
var HierarchicalKey = bitcore.HierarchicalKey;
|
var HierarchicalKey = bitcore.HierarchicalKey;
|
||||||
@ -724,8 +772,73 @@
|
|||||||
} else {
|
} else {
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#NetworkMonitor.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var run = function() {
|
||||||
|
// Replace '../bitcore' with 'bitcore' if you use this code elsewhere.
|
||||||
|
var bitcore = require('../bitcore');
|
||||||
|
var NetworkMonitor = bitcore.NetworkMonitor;
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.run = run;
|
||||||
|
if (require.main === module) {
|
||||||
|
run();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#Opreturn.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var run = function() {
|
||||||
|
// Replace '../bitcore' with 'bitcore' if you use this code elsewhere.
|
||||||
|
var bitcore = require('../bitcore');
|
||||||
|
var Address = bitcore.Address;
|
||||||
|
var coinUtil = bitcore.util;
|
||||||
|
var Script = bitcore.Script;
|
||||||
|
var network = bitcore.networks.testnet;
|
||||||
|
|
||||||
|
var script = 'OP_RETURN 58434c524e4748530000000000000000000000010000000005f5e100';
|
||||||
|
var s = Script.fromHumanReadable(script);
|
||||||
|
var result = (s.classify() == Script.TX_RETURN)
|
||||||
|
console.log("Is op_return:", result);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.run = run;
|
||||||
|
if (require.main === module) {
|
||||||
|
run();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
#PayToScriptHashAddress.js
|
#PayToScriptHashAddress.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
var bitcore = require('../bitcore');
|
var bitcore = require('../bitcore');
|
||||||
var Address = bitcore.Address;
|
var Address = bitcore.Address;
|
||||||
var bitcoreUtil = bitcore.util;
|
var bitcoreUtil = bitcore.util;
|
||||||
@ -743,16 +856,24 @@
|
|||||||
|
|
||||||
// This outputs the "address" of thescript
|
// This outputs the "address" of thescript
|
||||||
console.log(addrStr);
|
console.log(addrStr);
|
||||||
|
```
|
||||||
|
|
||||||
#PeerDiscovery.js
|
#PeerDiscovery.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
var PeerManager = require('../lib/PeerManager');
|
var PeerManager = require('../lib/PeerManager');
|
||||||
var peerman = new PeerManager();
|
var peerman = new PeerManager();
|
||||||
|
|
||||||
peerman.discover({
|
peerman.discover({
|
||||||
limit: 12
|
limit: 12
|
||||||
}).start();
|
}).start();
|
||||||
|
```
|
||||||
|
|
||||||
#PeerManager.js
|
#PeerManager.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var run = function() {
|
var run = function() {
|
||||||
@ -800,8 +921,12 @@
|
|||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
#Rpc.js
|
#Rpc.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var run = function() {
|
var run = function() {
|
||||||
@ -834,8 +959,12 @@
|
|||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
#Script.js
|
#Script.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var run = function() {
|
var run = function() {
|
||||||
@ -888,8 +1017,60 @@
|
|||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#ScriptInterpreter.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var run = function() {
|
||||||
|
// Replace '../bitcore' with 'bitcore' if you use this code elsewhere.
|
||||||
|
var bitcore = require('../bitcore');
|
||||||
|
var Address = bitcore.Address;
|
||||||
|
var coinUtil = bitcore.util;
|
||||||
|
var Script = bitcore.Script;
|
||||||
|
var ScriptInterpreter = bitcore.ScriptInterpreter;
|
||||||
|
var network = bitcore.networks.testnet;
|
||||||
|
|
||||||
|
|
||||||
|
// using "static" method
|
||||||
|
var scriptPubKeyHR = '0x14 0x3744841e13b90b4aca16fe793a7f88da3a23cc71 EQUAL';
|
||||||
|
var scriptPubKey = Script.fromHumanReadable(scriptPubKeyHR);
|
||||||
|
|
||||||
|
var scriptSigHR = '0x14 0x3744841e13b90b4aca16fe793a7f88da3a23cc71';
|
||||||
|
var scriptSig = Script.fromHumanReadable(scriptSigHR);
|
||||||
|
|
||||||
|
ScriptInterpreter.verifyFull(scriptSig, scriptPubKey, undefined, undefined,
|
||||||
|
undefined, undefined, function(err, result) {
|
||||||
|
console.log('script verified successfully? ', result)
|
||||||
|
});
|
||||||
|
|
||||||
|
// using an instance
|
||||||
|
scriptPubKeyHR = '0x26 0x554e5a49500370e53982a1d5201829562c5d9eebf256eb755b92c9b1449afd99f9f8c3265631 DROP HASH256 0x20 0x34b4f6042e1bcfc6182ee2727a3d0069a9071385bc07b318f57e77a28ffa13ac EQUAL';
|
||||||
|
scriptPubKey = Script.fromHumanReadable(scriptPubKeyHR);
|
||||||
|
|
||||||
|
scriptSigHR = '0x41 0x0470e53982a1d5201829562c5d9eebf256eb755b92c9b1449afd99f9f8c3265631142f3bf6954e3bec4bdad1a1a197bf90904a1e6f06c209eb477e2fde00d26691';
|
||||||
|
scriptSig = Script.fromHumanReadable(scriptSigHR);
|
||||||
|
|
||||||
|
var si = new ScriptInterpreter();
|
||||||
|
si.verifyFull(scriptSig, scriptPubKey, undefined, undefined,
|
||||||
|
undefined, function(err, result) {
|
||||||
|
console.log('script verified successfully? ', result)
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.run = run;
|
||||||
|
if (require.main === module) {
|
||||||
|
run();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
#SendTx.js
|
#SendTx.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var run = function() {
|
var run = function() {
|
||||||
@ -997,8 +1178,12 @@
|
|||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
#SimpleP2Pmonitor.js
|
#SimpleP2Pmonitor.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a simple script that will display network messages.
|
* This is a simple script that will display network messages.
|
||||||
* It users the Peer / Connection classes directly instead of
|
* It users the Peer / Connection classes directly instead of
|
||||||
@ -1071,8 +1256,12 @@
|
|||||||
log('Received message inv (%s invs)', event.message.count);
|
log('Received message inv (%s invs)', event.message.count);
|
||||||
console.log(event.message.invs);
|
console.log(event.message.invs);
|
||||||
});
|
});
|
||||||
|
```
|
||||||
|
|
||||||
#VanityAddress.js
|
#VanityAddress.js
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
@ -1101,4 +1290,4 @@
|
|||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|||||||
@ -9,7 +9,7 @@ var format = es.through(
|
|||||||
if (file.isStream()) return this.emit('error', new Error('Streaming not supported'));
|
if (file.isStream()) return this.emit('error', new Error('Streaming not supported'));
|
||||||
|
|
||||||
//add indentation
|
//add indentation
|
||||||
var contents = "\t" + file.contents.toString("utf8").split("\n").join("\n\t");
|
var contents = "\n```js\n\n" + file.contents.toString("utf8").split("\n").join("\n") + "```\n";
|
||||||
//add header
|
//add header
|
||||||
contents = ["#", path.basename(file.path), "\n", contents].join("");
|
contents = ["#", path.basename(file.path), "\n", contents].join("");
|
||||||
file.contents = new Buffer(contents, "utf8");
|
file.contents = new Buffer(contents, "utf8");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user