paypro: example - add --address and --pubkey options. document in readme.
This commit is contained in:
parent
cc3ca4e571
commit
e93e3d83f4
|
@ -45,7 +45,12 @@ Customer: Message from Merchant: Thank you for your payment!
|
|||
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
|
||||
|
||||
|
|
|
@ -141,34 +141,47 @@ app.get('/-/request', function(req, res, next) {
|
|||
// number of satoshis to be paid
|
||||
po.set('amount', value);
|
||||
// a TxOut script where the payment should be sent. similar to OP_CHECKSIG
|
||||
po.set('script', new Buffer([
|
||||
118, // OP_DUP
|
||||
169, // OP_HASH160
|
||||
76, // OP_PUSHDATA1
|
||||
20, // number of bytes
|
||||
55,
|
||||
48,
|
||||
254,
|
||||
188,
|
||||
186,
|
||||
4,
|
||||
186,
|
||||
208,
|
||||
205,
|
||||
71,
|
||||
108,
|
||||
251,
|
||||
130,
|
||||
15,
|
||||
156,
|
||||
55,
|
||||
215,
|
||||
70,
|
||||
111,
|
||||
217,
|
||||
136, // OP_EQUALVERIFY
|
||||
172 // OP_CHECKSIG
|
||||
]));
|
||||
if (argv.pubkey || argv.address) {
|
||||
var pubKey;
|
||||
if (argv.address) {
|
||||
pubKey = bitcore.Base58Check.decode(new Buffer(argv.address));
|
||||
} else {
|
||||
pubKey = new Buffer(argv.pubkey, 'hex');
|
||||
}
|
||||
var pubKeyHash = bitcore.util.sha256ripe160(pubKey);
|
||||
var address = new bitcore.Address(pubKeyHash, 'testnet');
|
||||
var scriptPubKey = addr.getScriptPubKey();
|
||||
po.set('script', scriptPubKey.getBuffer());
|
||||
} else {
|
||||
po.set('script', new Buffer([
|
||||
118, // OP_DUP
|
||||
169, // OP_HASH160
|
||||
76, // OP_PUSHDATA1
|
||||
20, // number of bytes
|
||||
55,
|
||||
48,
|
||||
254,
|
||||
188,
|
||||
186,
|
||||
4,
|
||||
186,
|
||||
208,
|
||||
205,
|
||||
71,
|
||||
108,
|
||||
251,
|
||||
130,
|
||||
15,
|
||||
156,
|
||||
55,
|
||||
215,
|
||||
70,
|
||||
111,
|
||||
217,
|
||||
136, // OP_EQUALVERIFY
|
||||
172 // OP_CHECKSIG
|
||||
]));
|
||||
}
|
||||
outputs.push(po.message);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue