1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* User: delboy1978uk |
4
|
|
|
* Date: 18/08/15 |
5
|
|
|
* Time: 19:58 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Del\Bitcoin\Api; |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
class Utility extends AbstractApi |
12
|
|
|
{ |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* The createmultisig RPC creates a P2SH multi-signature address. |
16
|
|
|
* |
17
|
|
|
* @param int $num The minimum (m) number of signatures required to |
18
|
|
|
* spend this m-of-n multisig script |
19
|
|
|
* @param array $keys An array of strings with each string being a |
20
|
|
|
* public key or address |
21
|
|
|
* A public key against which signatures will be checked. If wallet |
22
|
|
|
* support is enabled, this may be a P2PKH address belonging to the |
23
|
|
|
* wallet—the corresponding public key will be substituted. There must |
24
|
|
|
* be at least as many keys as specified by the Required parameter, |
25
|
|
|
* and there may be more keys |
26
|
|
|
* @return mixed |
27
|
|
|
*/ |
28
|
|
|
public function createMultiSig($num,$keys) |
29
|
|
|
{ |
30
|
|
|
return $this->send('createmultisig',[$num,$keys]); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* The estimatefee RPC estimates the transaction fee per kilobyte |
35
|
|
|
* that needs to be paid for a transaction to be included within |
36
|
|
|
* a certain number of blocks. |
37
|
|
|
* |
38
|
|
|
* @param int $blocks The maximum number of blocks a transaction |
39
|
|
|
* should have to wait before it is predicted to be included |
40
|
|
|
* in a block |
41
|
|
|
* @return mixed |
42
|
|
|
*/ |
43
|
|
|
public function estimateFee($blocks) |
44
|
|
|
{ |
45
|
|
|
return $this->send('estimatefee',[$blocks]); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* The estimatepriority RPC estimates the priority that a transaction |
50
|
|
|
* needs in order to be included within a certain number of blocks as |
51
|
|
|
* a free high-priority transaction. |
52
|
|
|
* |
53
|
|
|
* @param int $blocks |
54
|
|
|
* @return mixed |
55
|
|
|
*/ |
56
|
|
|
public function estimatePriority($blocks) |
57
|
|
|
{ |
58
|
|
|
return $this->send('estimatepriority',[$blocks]); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* The validateaddress RPC returns information about |
63
|
|
|
* the given Bitcoin address. |
64
|
|
|
* |
65
|
|
|
* @param string $address The P2PKH or P2SH address to validate |
66
|
|
|
* encoded in base58check format |
67
|
|
|
* @return mixed |
68
|
|
|
*/ |
69
|
|
|
public function validateAddress($address) |
70
|
|
|
{ |
71
|
|
|
return $this->send('validateaddress',[$address]); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* The verifymessage RPC verifies a signed message. |
76
|
|
|
* |
77
|
|
|
* @param string $address The P2PKH address corresponding to the private |
78
|
|
|
* key which made the signature. A P2PKH address is a hash of the public |
79
|
|
|
* key corresponding to the private key which made the signature. When |
80
|
|
|
* the ECDSA signature is checked, up to four possible ECDSA public keys |
81
|
|
|
* will be reconstructed from from the signature; each key will be hashed |
82
|
|
|
* and compared against the P2PKH address provided to see if any of them |
83
|
|
|
* match. If there are no matches, signature validation will fail. |
84
|
|
|
* @param string $signature The signature created by the signer encoded |
85
|
|
|
* as base-64 (the format output by the signmessage RPC) |
86
|
|
|
* @param string $message The message exactly as it was signed (e.g. no |
87
|
|
|
* extra whitespace) |
88
|
|
|
* @return mixed |
89
|
|
|
*/ |
90
|
|
|
public function verifyMessage($address, $signature, $message) |
91
|
|
|
{ |
92
|
|
|
return $this->send('verifymessage',[$address,$signature,$message]); |
93
|
|
|
} |
94
|
|
|
} |