Browse Source

paypro: example - add --address and --pubkey options. document in readme.

patch-2
Christopher Jeffrey 11 years ago
parent
commit
e93e3d83f4
  1. 7
      examples/PayPro/README.md
  2. 69
      examples/PayPro/server.js

7
examples/PayPro/README.md

@ -45,7 +45,12 @@ Customer: Message from Merchant: Thank you for your payment!
Customer: Payment sent successfully. Customer: Payment sent successfully.
``` ```
## Changing the server address in outputs ## Changing the server address contained in outputs
If you want to alter the address or public key the testnet coins get sent to by
the payment server, you can pass in the `--pubkey` or `--address` options.
`address` has to be a testnet address, whereas `pubkey` is a hex encoded public
key.
## Other Options ## Other Options

69
examples/PayPro/server.js

@ -141,34 +141,47 @@ app.get('/-/request', function(req, res, next) {
// number of satoshis to be paid // number of satoshis to be paid
po.set('amount', value); po.set('amount', value);
// a TxOut script where the payment should be sent. similar to OP_CHECKSIG // a TxOut script where the payment should be sent. similar to OP_CHECKSIG
po.set('script', new Buffer([ if (argv.pubkey || argv.address) {
118, // OP_DUP var pubKey;
169, // OP_HASH160 if (argv.address) {
76, // OP_PUSHDATA1 pubKey = bitcore.Base58Check.decode(new Buffer(argv.address));
20, // number of bytes } else {
55, pubKey = new Buffer(argv.pubkey, 'hex');
48, }
254, var pubKeyHash = bitcore.util.sha256ripe160(pubKey);
188, var address = new bitcore.Address(pubKeyHash, 'testnet');
186, var scriptPubKey = addr.getScriptPubKey();
4, po.set('script', scriptPubKey.getBuffer());
186, } else {
208, po.set('script', new Buffer([
205, 118, // OP_DUP
71, 169, // OP_HASH160
108, 76, // OP_PUSHDATA1
251, 20, // number of bytes
130, 55,
15, 48,
156, 254,
55, 188,
215, 186,
70, 4,
111, 186,
217, 208,
136, // OP_EQUALVERIFY 205,
172 // OP_CHECKSIG 71,
])); 108,
251,
130,
15,
156,
55,
215,
70,
111,
217,
136, // OP_EQUALVERIFY
172 // OP_CHECKSIG
]));
}
outputs.push(po.message); outputs.push(po.message);
}); });

Loading…
Cancel
Save