1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* User: delboy1978uk |
4
|
|
|
* Date: 18/08/15 |
5
|
|
|
* Time: 19:52 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Del\Bitcoin\Api; |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
class Mining extends AbstractApi |
12
|
|
|
{ |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* The getblocktemplate RPC gets a block template or proposal for use |
16
|
|
|
* with mining software. For more information, please see the following |
17
|
|
|
* resources: |
18
|
|
|
* Bitcoin Wiki GetBlockTemplate https://en.bitcoin.it/wiki/Getblocktemplate |
19
|
|
|
* BIP22 https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki |
20
|
|
|
* BIP23 https://github.com/bitcoin/bips/blob/master/bip-0023.mediawiki |
21
|
|
|
* |
22
|
|
|
* @param array $params see wiki for details |
23
|
|
|
* @return mixed |
24
|
|
|
*/ |
25
|
|
|
public function getBlockTemplate(array $params = ['capabilities' => ['coinbasetxn', 'workid', 'coinbase/append']]) |
26
|
|
|
{ |
27
|
|
|
return $this->send('getblocktemplate',[$params]); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* The getmininginfo RPC returns various mining-related information. |
32
|
|
|
* |
33
|
|
|
* @return mixed |
34
|
|
|
*/ |
35
|
|
|
public function getMiningInfo() |
36
|
|
|
{ |
37
|
|
|
return $this->send('getmininginfo'); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* The getnetworkhashps RPC returns the estimated current or historical |
42
|
|
|
* network hashes per second based on the last n blocks. |
43
|
|
|
* |
44
|
|
|
* @param int $blocks The number of blocks to average together for calculating |
45
|
|
|
* the estimated hashes per second. Default is 120. Use -1 to average all |
46
|
|
|
* blocks produced since the last difficulty change |
47
|
|
|
* @param int $height The height of the last block to use for calculating the |
48
|
|
|
* average. Defaults to -1 for the highest-height block on the local best block |
49
|
|
|
* chain. If the specified height is higher than the highest block on the local |
50
|
|
|
* best block chain, it will be interpreted the same as -1 |
51
|
|
|
* @return mixed |
52
|
|
|
*/ |
53
|
|
|
public function getNetworkHashPS($blocks,$height) |
54
|
|
|
{ |
55
|
|
|
return $this->send('getnetworkhashps',[$blocks,$height]); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* The prioritisetransaction RPC adds virtual priority or fee to a transaction, |
60
|
|
|
* allowing it to be accepted into blocks mined by this node (or miners which |
61
|
|
|
* use this node) with a lower priority or fee. (It can also remove virtual |
62
|
|
|
* priority or fee, requiring the transaction have a higher priority or fee to |
63
|
|
|
* be accepted into a locally-mined block.) |
64
|
|
|
* |
65
|
|
|
* @param string $txid The TXID of the transaction whose virtual priority or |
66
|
|
|
* fee you want to modify, encoded as hex in RPC byte order |
67
|
|
|
* @param float $priority If positive, the priority to add to the transaction |
68
|
|
|
* in addition to its computed priority; if negative, the priority to subtract |
69
|
|
|
* from the transaction’s computed priory. Computed priority is the age of each |
70
|
|
|
* input in days since it was added to the block chain as an output (coinage) |
71
|
|
|
* times the value of the input in satoshis (value) divided by the size of the |
72
|
|
|
* serialized transaction (size), which is coinage * value / size |
73
|
|
|
* @param int $fee Warning: this value is in satoshis, not bitcoins |
74
|
|
|
* If positive, the virtual fee to add to the actual fee paid by the transaction; |
75
|
|
|
* if negative, the virtual fee to subtract from the actual fee paid by the |
76
|
|
|
* transaction. No change is made to the actual fee paid by the transaction |
77
|
|
|
* @return mixed |
78
|
|
|
*/ |
79
|
|
|
public function prioritiseTransaction($txid,$priority,$fee) |
80
|
|
|
{ |
81
|
|
|
return $this->send('prioritisetransaction',[$txid,$priority,$fee]); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* The submitblock RPC accepts a block, verifies it is a valid addition to the block |
86
|
|
|
* chain, and broadcasts it to the network. Extra parameters are ignored by Bitcoin |
87
|
|
|
* Core but may be used by mining pools or other programs. |
88
|
|
|
* |
89
|
|
|
* @param string $block The full block to submit in serialized block format as hex |
90
|
|
|
* @param string $json_params A JSON object containing extra parameters. Not used |
91
|
|
|
* directly by Bitcoin Core and also not broadcast to the network. This is available |
92
|
|
|
* for use by mining pools and other software. A common parameter is a workid string |
93
|
|
|
* @return mixed |
94
|
|
|
*/ |
95
|
|
|
public function submitBlock($block,$json_params = null) |
96
|
|
|
{ |
97
|
|
|
return $this->send('submitblock',[$block,$json_params]); |
98
|
|
|
} |
99
|
|
|
} |