Skip to content

Commit

Permalink
refactore key and index
Browse files Browse the repository at this point in the history
  • Loading branch information
sagivo committed Sep 16, 2014
1 parent 90788bd commit c29212a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
9 changes: 9 additions & 0 deletions examples/payToAddress.js
@@ -0,0 +1,9 @@
var settings = {network: 'test'}
var acceptBitcoin = require('accept-bitcoin');
var ac = new acceptBitcoin('YOUR_BITCOIN_ADDRESS', settings);
existingKey = ac.generateAddress(settings, 'Your Public key', 'your private key in WIF format');

existingKey.payTo('address to pay to', {amount: 0.1, fee: 0.0001}, function(err, response){
if (response.status == 'success')
console.log("WOHOO! DONE");
});
26 changes: 21 additions & 5 deletions lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions src/index.coffee
Expand Up @@ -20,7 +20,7 @@ class Main
checkBalanceTimeout: (1000 * 60 * 60 * 2) #60 minutes timeout --remove
checkUnspentTimeout: (1000 * 60 * 60 * 2) #60 minutes timeout
minimumConfirmations: 1
txFee: 0 #0.0001
txFee: 0.0001

constructor: (address, o = {}) ->
return 'must have address' unless address
Expand All @@ -33,8 +33,11 @@ class Main
#tx.pushTx 'mookaUALkRngyevqAP6gyekqNBMtjoRJBm', transferAmount: '0.0001', (err, d) =>
# this.emit('foo', d)

generateAddress: (o) =>
key = new Key extend(settings, o)#, 'mx5nzg1tRwADWDCU53CSHmY7iac2f4B2YK', 'cUWFtYbNycND7wQ9QZKPimkrKQoU9uYJ8M1nyV7W24bXaVdPhTtQ'
generateAddress: (o, privateKey) =>
if privateKey
key = new Key settings, o, privateKey
else
key = new Key extend(settings, o)#, 'mx5nzg1tRwADWDCU53CSHmY7iac2f4B2YK', 'cUWFtYbNycND7wQ9QZKPimkrKQoU9uYJ8M1nyV7W24bXaVdPhTtQ'
key.checkBalance() if o and o.alertWhenHasBalance
key

Expand Down

0 comments on commit c29212a

Please sign in to comment.