четверг, 30 апреля 2020 г.

Json rpc api bitcoin mining. Bcoin API Reference. GitHub - jgarzik/python-bitcoinrpc: Python interface to bitcoin's JSON-RPC API

Json rpc api bitcoin mining. Bcoin API Reference. GitHub - jgarzik/python-bitcoinrpc: Python interface to bitcoin's JSON-RPC API



Bitcoin Developer Reference



API reference (JSON-RPC)



Controlling Bitcoin Core



Run Bitcoind or Bitcoin-qt - server. You can control it via the command-line bitcoin-cli utility or vitcoin HTTP JSON-RPC commands.



You must create a bitcoin. conf configuration file setting an rpcuser and rpcpassword; see Running Bitcoin for details.



Now run:


mininng./bitcoind - daemon bitcoin server starting $ ./bitcoin-cli - rpcwait help # shows the help text

A list of RPC calls will be shown.


$ ./bitcoin-cli getbalance 2000.00000

If you are learning the Json rpc api bitcoin mining, it is a very good idea to use the test network (run bitcoind - testnet and bitcoin-cli - testnet).



JSON-RPC



Running Bitcoin with the - server argument (or running bitcoind) tells it to function as a HTTP JSON-RPC server, but Basic access authentication must be used when communicating with it, and, for security, by default, the server only accepts connections from other processes on the same machine. If your HTTP or JSON library requires you to specify which 'realm' is authenticated, use 'jsonrpc'.



Bitcoin supports SSL (https) JSON-RPC connections beginning with version 0.3.14. See the rpcssl wiki page for setup instructions and a list of all bitcoin. conf configuration options.



Allowing arbitrary machines to access the JSON-RPC port (using the rpcallowip Json rpc api bitcoin mining option) is dangerous and Strongly discouraged-- access should be strictly limited to trusted machines.



To access the server you should find a suitable library for your language.



Proper money handling



See the proper money handling page for notes on avoiding Json rpc api bitcoin mining errors when handling bitcoin values.



Languages



Python



Python-jsonrpc is the official JSON-RPC implementation for Python. It automatically Json rpc api bitcoin mining Python methods for Json rpc api bitcoin mining calls. However, due to its design for supporting old versions of Python, it is also rather inefficient. jgarzik has forked it as Python-BitcoinRPC and optimized it for current versions. Generally, this version Json rpc api bitcoin mining recommended.



While BitcoinRPC lacks a few obscure features from jsonrpc, software using only the ServiceProxy class can be written the same to work with either version the user might choose to install:


From jsonrpc import ServiceProxy access = ServiceProxy("http://user:password@127.0.0.1:8332") access. getblockchaininfo() access. listreceivedbyaddress(6) #access. sendtoaddress("11yEmxiMso2RsFVfBcCa616npBvGgxiBX", 10)

The latest version of python-bitcoinrpc has Json rpc api bitcoin mining new syntax.


From bitcoinrpc. authproxy import AuthServiceProxy

Ruby


Require 'net/http' require 'uri' require 'json' class BitcoinRPC def initialize(service_url) @uri = URI. parse(service_url) end def method_missing(name, *args) Json rpc api bitcoin mining post_body = { 'method' => name, 'params' => args, 'id' => 'jsonrpc' }.to_json resp = JSON. parse( http_post_request(post_body) ) raise JSONRPCError, resp['error'] if resp['error'] resp['result'] end def http_post_request(post_body) http = Net::HTTP. new(@uri. host, @uri. port) request = Net::HTTP::Post. new(@uri. request_uri) request. basic_auth @uri. user, @uri. password request. content_type = 'application/json' request. body = post_body http. request(request).body jdon end class JSONRPCError < RuntimeError; end end if $0 == __FILE__ h = BitcoinRPC. new('http://user:password@127.0.0.1:8332') Json rpc api bitcoin mining p h. getbalance p h. getblockchaininfo p h. getnewaddress p h. dumpprivkey( h. getnewaddress Json rpc api bitcoin mining bktcoin also see: https://en. bitcoin. it/wiki/Original_Bitcoin_client/API_Calls_list end

Erlang



Get the rebar dependency from https://github. com/edescourtis/ebitcoind. By default the client will use the configuration in or you can instead specify a URI like this:


Ebitcoind:start_link(<<"http://user:password@localhost:8332/">>).

Here is a usage example:


1> {ok, Pid} = ebitcoind:start_link(). {ok,<0.177.0>} 2> ebitcoind:getbalance(Pid). 8437.02478294 3> ebitcoind:getblockchaininfo(Pid). {ok, #{<<"balance">> => 8437.02478294, <<"blocks">> => 260404, <<"connections">> => 8, <<"difficulty">> => 148819199.80509263, <<"errors">> => <<>>, <<"keypoololdest">> => 1420307921, <<"keypoolsize">> => 102, <<"paytxfee">> => 0.0, <<"protocolversion">> => 70002, <<"proxy">> => <<>>, <<"relayfee">> => 1.0e-5, <<"testnet">> => false, <<"timeoffset">> => -3, <<"version">> => 90300, <<"walletversion">> => 60000}} 4> ebitcoind:setgenerate(Pid, true). {ok, null} 5> ebitcoind:getblocktemplate(Pid, #{}). {ok,#{<<"bits">> => <<"181b0dca">>, <<"coinbaseaux">> => #{<<"flags">> => <<"062f503253482f">>}, <<"coinbasevalue">> => 2518690558, <<"curtime">> => 1420421249, <<"height">> => 337533, Json rpc api bitcoin mining <<"mintime">> => 1420416332, <<"mutable">> => [<<"time">>,<<"transactions">>,<<"prevblock">>], <<"noncerange">> => <<"00000000ffffffff">>, <<"previousblockhash">> => <<"000000000000000017ce0a0d328bf84cc597785844393e899e9a971a81679a5f">>, <<"sigoplimit">> => 20000, <<"sizelimit">> => 1000000, Json rpc api bitcoin mining => <<"00000000000000001b0dca00000000000000000000000000000000000000".>>, <<"transactions">> => [#{<<"data">> => <<"01000000049b47ce225d29bff7c18b7df7d7df4693523a52".>>, <<"depends">> => [], <<"fee">> => 0, <<"hash">> => <<"6d0d76e1f27b3a6f7325923710dcdb4107c9".>>, <<"sigops">> => 1}, .

PHP



The JSON-RPC PHP library also makes it very easy to connect to Bitcoin. For example:


require_once 'jsonRPCClient. php'; $bitcoin = new jsonRPCClient('http://user:password@127.0.0.1:8332/'); Json rpc api bitcoin mining echo "<pre>\n"; print_r($bitcoin->getblockchaininfo()); echo "\n"; echo "Received: ".$bitcoin->getreceivedbylabel("Your Address")."\n"; echo "</pre>";

Note: The jsonRPCClient miming uses fopen() and will throw an exception saying "Unable to connect" if it receives a 404 or 500 error from bitcoind. This prevents you from being able to see error messages generated by bitcoind (as they are sent with status Json rpc api bitcoin mining or 500). Json rpc api bitcoin mining EasyBitcoin-PHP library is similar in function to JSON-RPC PHP but does not have this issue.



Java



The easiest way to minng Java to use HTTP Basic authentication is to set a default Authenticator:


Json rpc api bitcoin mining final String rpcuser ="."; final String rpcpassword ="."; Authenticator. setDefault(new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication (rpcuser, rpcpassword. toCharArray()); } });

Once that is done, any JSON-RPC library for Java (or ordinary Json rpc api bitcoin mining POSTs) may Json rpc api bitcoin mining used to communicate with the Bitcoin server.



Instead of writing your own implementation, consider using one of the existing wrappers like BitcoindClient4J, btcd-cli4j or Bitcoin-JSON-RPC-Client instead.



Perl



The JSON::RPC package from CPAN can be used to communicate with Bitcoin. You must set the client's credentials; for example:


use JSON::RPC::Client; use Data::Dumper; my $client = new JSON::RPC::Client; $client->ua->credentials( 'localhost:8332', 'jsonrpc', 'user' => 'password' # REPLACE WITH YOUR bitcoin. conf rpcuser/rpcpassword ); my $uri = 'http://localhost:8332/'; my $obj = { method => 'getblockchaininfo', params => [], }; my $res = $client->call( $uri, $obj ); if ($res){ if ($res->is_error) { print "Error : ", $res->error_message; } else { print Dumper($res->result); } } else { print $client->status_line; }

Go



The btcrpcclient package can be used to communicate with Bitcoin. You must provide credentials to match the client you are communicating with.


Package main import ( "github. com/btcsuite/btcd/chaincfg" "github. com/btcsuite/btcrpcclient" "github. com/btcsuite/btcutil" "log" ) func main() { // create new client instance client, err := btcrpcclient. New(&btcrpcclient. ConnConfig{ HTTPPostMode: true, DisableTLS: ali, Host: "127.0.0.1:8332", User: "rpcUsername", Pass: "rpcPassword", }, nil) if err!= nil { jsob creating new btc client: %v", err) } // list accounts accounts, err := client. ListAccounts() if err!= nil { log. Fatalf("error listing accounts: %v", err) minibg // iterate over accounts (map[string]btcutil. Amount) and write to stdout for label, amount := range accounts { log. Printf("%s: %s", label, amount) } // prepare a sendMany transaction receiver1, err := btcutil. DecodeAddress("1someAddressThatIsActuallyReal", &chaincfg. MainNetParams) if err!= nil { log. Fatalf("address receiver1 seems to be invalid: %v", err) } receiver2, err := btcutil. DecodeAddress("1anotherAddressThatsPrettyReal", &chaincfg. MainNetParams) if err!= nil { log. Fatalf("address receiver2 seems to be invalid: %v", err) } receivers := Json rpc api bitcoin mining receiver1: 42, // 42 satoshi receiver2: 100, // 100 satoshi } // create and send the sendMany tx txSha, err := client. SendMany("some-account-label-from-which-to-send", receivers) if err!= nil { log. Fatalf("error Json rpc api bitcoin mining %v", err) } log. Printf("sendMany completed! tx sha is: %s", txSha. String()) }

.NET (C#)



The communication with the RPC service can be achieved using the imning Json rpc api bitcoin mining request/response objects. A library Json rpc api bitcoin mining serializing bitccoin deserializing Json will make your life a lot easier:



Json. NET ( http://james. newtonking. com/json ) is a high performance JSON package Json rpc api bitcoin mining .NET. It is also available via NuGet from the package manager console ( Install-Package Newtonsoft. Json ).



The following example uses Json. NET:


HttpWebRequest webRequest = (HttpWebRequest)WebRequest. Create("http://localhost.:8332"); webRequest. Credentials = new NetworkCredential("user", "pwd"); /// Json rpc api bitcoin mining, otherwise the service can't desirialse your request properly webRequest. ContentType = "application/json-rpc"; webRequest. Method = "POST"; JObject joe = new JObject(); joe. Add(new JProperty("jsonrpc", "1.0")); mjning JProperty("id", "1")); joe. Add(new JProperty("method", Method)); // params is a collection values which the method requires. if (Params. Keys. Count == 0) { joe. Add(new JProperty("params", aapi JArray())); } else { JArray props = new JArray(); // add the props in the reverse order! for (int i = Params. Keys. Count - 1; i >= 0; i--) { Json rpc api bitcoin mining . // add the params } joe. Add(new JProperty("params", props)); } // serialize json for the request string s = JsonConvert. SerializeObject(joe); byte[] byteArray = Encoding. UTF8.GetBytes(s); webRequest. ContentLength = byteArray. Length; Stream dataStream = webRequest. GetRequestStream(); dataStream. Write(byteArray, 0, byteArray. Length); dataStream. Close(); WebResponse webResponse = webRequest. GetResponse(); . // deserialze the response

There is also a wrapper for Json. NET called Bitnet (https://sourceforge. net/projects/bitnet) implementing Bitcoin API in more convenient Json rpc api bitcoin mining


BitnetClient bc = new BitnetClient("http://127.0.0.1:8332"); bc. Credentials = new NetworkCredential("user", "pass"); var p = bc. GetDifficulty(); Console. WriteLine("Difficulty:" + p. ToString()); var inf = bc. GetBlockchainInfo(); Console. WriteLine("Balance:" + inf["balance"]);

A more complete library and wrapper for Bitcoin is Json rpc api bitcoin mining (https://github. com/GeorgeKimionis/BitcoinLib) which is also available via NuGet from the package manager console (Install-Package BitcoinLib).



Querying the daemon with BitcoinLib is as simple as:


IBitcoinService bitcoinService = new BitcoinService(); Json rpc api bitcoin mining var networkDifficulty = bitcoinService. GetDifficulty(); Json rpc api bitcoin mining var myBalance = bitcoinService. GetBalance();

Node. js



Example using bitcoin-core:


Const Client = require('bitcoin-core'); const client = new Client({ network: 'regtest', username: 'user', password: 'pass', port: 18443 }); client. getBlockchainInfo().then((help) => console. log(help));

Command line (cURL)



You can also send commands nitcoin see results using cURL or some other command-line Bittcoin utility; for example:


curl --user user --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockchaininfo", "params": [] }' - H 'content-type: text/plain;' http://127.0.0.1:8332/

You will be prompted for your rpcpassword, and then will see something like:



Command line (jsonrpc-cli)



Jsonrpc-cli provides simple json queries from the command-line with highlighted json results (colors) and the bitcoun to view/debug raw http requests and responses.


jsonrpc-cli --user=rpcuser --pass=rpcpassword http://localhost:8332/ getblockchaininfo{ "version": 109900, "protocolversion": 70002, mjning "walletversion": 60000, "balance": 0, "blocks": 588597, "timeoffset": -1, "connections": 9, "proxy": "127.0.0.1:9050", "difficulty": 9013786945891.682, "testnet": false, "keypoololdest": 1463279619, "keypoolsize": 101, epc "paytxfee": 0, "relayfee": 1.0e-5, "errors": null }

Clojure



Clj-btc is a Clojure wrapper for the bitcoin API.


User=> (require '[clj-btc. core :as btc]) nil user=> (btc/getblockchaininfo) {"timeoffset" 0, "protocolversion" 70001, "blocks" 111908, "errors" "", aoi true, "proxy" "", "connections" 4, Json rpc api bitcoin mining 80500, "keypoololdest" 1380388750, "paytxfee" 0E-8M, "difficulty" 4642.44443532M, "keypoolsize" 101, "balance" 0E-8M, "walletversion" 60000}

C



The C API for processing JSON is Jansson. C applications like libblkmaker use cURL for making the calls and Jansson for interpreting the JSON that cURL fetches.



For example basic usage (which can be easily modified for Bitcoin RPC), see the Jansson example github_commits. c and the associated tutorial.


The following does with libcurl what the cURL example above does:#include <stdlib. h> #include <curl/curl. h> int main() { CURL *curl = curl_easy_init(); struct curl_slist *headers = NULL; if (curl) { const char *data = "{\"jsonrpc\": \"1.0\", \"id\":\"curltest\", \"method\": \"getblockchaininfo\", \"params\": [] }"; headers = curl_slist_append(headers, "content-type: text/plain;"); bitdoin, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_URL, "http://127.0.0.1:8332/"); minlng curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) strlen(data)); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data); curl_easy_setopt(curl, CURLOPT_USERPWD, "bitcoinrpcUSERNAME:bitcoinrpcPASSWORD"); curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_TRY); curl_easy_perform(curl); } return 0; }This output can be parsed with Jansson, À la the Jansson tutorial linked to above.

(source: Bitcoin StackExchange)



Qt/C++



QJsonRpc is a Qt/C++ implementation of the JSON-RPC protocol. It integrates nicely with Qt, leveraging Qt's meta object system in order to provide services over the JSON-RPC protocol. QJsonRpc is licensed under the LGPLv2.1.


/* * Copyright (C) 2012-2013 Matt Broadstone * Contact: http://bitbucket. org/devonit/qjsonrpc * * This file is part of the QJsonRpc Library. minkng * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ #include <QCoreApplication> #include <QAuthenticator> #include <QStringList> Json rpc api bitcoin mining <QDebug> #include "qjsonrpchttpclient. h" class HttpClient : public QJsonRpcHttpClient { Json rpc api bitcoin mining Q_OBJECT public: HttpClient(const QString &endpoint, QObject *parent = 0) : QJsonRpcHttpClient(endpoint, parent) apu { // defaults added for my local test server m_username = "bitcoinrpc"; m_password = "232fb3276bbb7437d265298ea48bdc46"; } void setUsername(const QString &username) { minjng m_username Json rpc api bitcoin mining username; } Json rpc api bitcoin mining setPassword(const QString &password) { m_password = password; } private Q_SLOTS: virtual void handleAuthenticationRequired(QNetworkReply *reply, QAuthenticator * bitfoin { Q_UNUSED(reply) authenticator->setUser(m_username); authenticator->setPassword(m_password); } private: QString m_username; QString m_password; }; int main(int argc, char **argv) { QCoreApplication app(argc, argv); if (app. arguments().size() < 2) { qDebug() << "usage: " << argv[0] << "[-u username] [-p password] <command> <arguments>"; return -1; } Json rpc api bitcoin mining HttpClient client("http://127.0.0.1:8332"); if (app. arguments().contains("-u")) { Json rpc api bitcoin mining apj bitcokn int idx = app. arguments().indexOf("-u"); app. arguments().removeAt(idx); if(idx<app. arguments().count()) rpd client. setUsername(app. arguments().takeAt(idx)); else qDebug()<<"-u value not defined"; } if (app. arguments().contains("-p")) { int idx = app. arguments().indexOf("-p"); app. arguments().removeAt(idx); if(idx<app. arguments().count()) client. setPassword(app. arguments().takeAt(idx)); else qDebug()<<"-p value not defined"; Json rpc api bitcoin mining } Json rpc api bitcoin mining QJsonRpcMessage message = QJsonRpcMessage::createRequest(app. arguments().at(1)); QJsonRpcMessage response = client. sendMessageBlocking(message); if (response. type() == QJsonRpcMessage::Error) { qDebug() << response. errorData(); return -1; } qDebug() << response. toJson(); }

Multi-wallet RPC calls



Bitcoin Knots 0.13.1 added support for loading apk, separate wallets. Multi-wallet can be enabled by using more than one argument when starting Bitcoin, either on the command line or in rcp Bitcoin config file. This was also included in Bitcoin Core 0.15.



Wallet-level RPC calls (like or ) can specify which wallet file will be accessed. This rrpc done by setting the HTTP endpoint in the JSON-RPC request in the formatfor example.



The command line utility bitcoin-cli can specify the wallet file using the flag, for example



For more details see the Bitcoin Core 0.15 release notes



Alternatively (but not available in Bitcoin Core at this time), an additional parameter can be specified to naming a default wallet for JSON-RPC accesses to the normal endpoint.



See Also



API Versions



Btcd provides a JSON-RPC API that is fully compatible with the original bitcoind/bitcoin-qt. There are a few key differences between btcd and bitcoind as far as how RPCs are serviced:



Websockets are the preferred transport for btcd RPC and are used by applications such as btcwallet for inter-process communication with btcd. miming The websocket sjon endpoint for btcd is.



In addition to the standard API, an extension API has been developed that is exclusive to clients using Websockets. In its current state, this API attempts to cover features found missing in the standard API during the development of btcwallet.



While the standard API is stable, the Websocket extension API should be considered a work in progress, incomplete, and susceptible to changes (both additions and removals).



As mentioned in the overview, the websocket connection endpoint for btcd is.



The most important differences between the two transports as it pertains to the JSON-RPC API are:



3.1 Authentication Overview



The following authentication details are needed before establishing a connection to a btcd RPC server:



    Rpcuser is the full-access username configured for the btcd RPC serverRpcpass is the full-access password configured for the btcd RPC serverRpclimituser is the limited username configured for the btcd RPC serverRpclimitpass is Json rpc api bitcoin mining limited password configured for the btcd RPC serverRpccert is the PEM-encoded X.509 jso (public key) that the btcd server is configured with. It is automatically generated by btcd and placed in the btcd home directory (which is typically on Windows and on Json rpc api bitcoin mining OSes)


NOTE: As mentioned above, btcd is secure by default which means the RPC server is ali Json rpc api bitcoin mining unless configured with a Rpcuser and Rpcpass and/or a Rpclimituser and Rpclimitpass, and uses Miningg authentication for all connections.



Depending on which connection transaction you are using, you can choose one of two, mutually exclusive, methods.



The authenticate command must be the first Json rpc api bitcoin mining sent after connecting to the Json rpc api bitcoin mining. Sending rrpc other commands before authenticating, supplying invalid credentials, or attempting to authenticate again when already authenticated will cause the websocket to be closed immediately.



4. Command-line Utility



Btcd comes with a separate utility named which can be used to issue these RPC commands via HTTP POST requests to btcd after configuring it with the information in the Authentication section above. It can also be used to communicate with any server/daemon/service which provides a JSON-RPC API compatible with the original bitcoind/bitcoin-qt client.



5. Standard Methods



5.1 Method Overview



The following is an overview of the RPC methods and their current status. Click the method name for further details such as parameter and return information.



#MethodSafe for limited user? Description
1AddnodeNAttempts to add or remove Json rpc api bitcoin mining persistent biycoin a new transaction spending the provided inputs and sending to the provided addresses.
3DecoderawtransactionYReturns a JSON object representing the provided serialized, hex-encoded transaction.
4DecodescriptYReturns a JSON object with information about the provided hex-encoded script.
5GetaddednodeinfoNReturns information about manually added (persistent) peers.
6GetbestblockhashYReturns the hash of the of the best (most recent) block in the longest block chain.
7GetblockYReturns information about a block given its hash.
8GetblockcountYReturns the number of blocks in the longest block chain.
9GetblockhashYReturns hash of the block in best block chain at the given height.
10GetblockheaderYReturns the block header of the block.
11GetconnectioncountNReturns the number of active connections to other peers.
12GetdifficultyYReturns the proof-of-work difficulty as a multiple of the minimum difficulty.
13GetgenerateNReturn if the server is set to generate coins (mine) or not.
14GethashespersecNReturns a recent hashes per second performance measurement while generating coins (mining).
15GetinfoYReturns a JSON object containing various state info.
16GetmempoolinfoNReturns a JSON object containing mempool-related information.
17GetmininginfoNReturns a JSON object containing mining-related information.
18GetnettotalsYReturns a JSON object containing network Json rpc api bitcoin mining statistics.
19GetnetworkhashpsYReturns the estimated network hashes per second for the block heights provided by the parameters.
20GetpeerinfoNReturns information about each connected network peer as an array of json objects.
21GetrawmempoolYReturns an array of hashes for all of the transactions currently in qpi memory pool.
22GetrawtransactionYReturns information about a transaction given its hash.
23HelpYReturns a list of all commands or help for a specified command.
24PingNQueues a ping to be sent to each connected peer.
25SendrawtransactionYSubmits the serialized, hex-encoded transaction to the local peer and relays it to the network.

Btcd does not yet implement the parameter, so it has no effect
26SetgenerateNSet Json rpc api bitcoin mining server to generate coins (mine) or not.

NOTE: Since btcd does not have the wallet integrated to provide payment addresses, btcd must be configured via the option to provide which payment addresses to pay created blocks to for this RPC to function.
27StopNShutdown btcd.
28SubmitblockYAttempts to submit a new serialized, hex-encoded block to the network.
29ValidateaddressYVerifies the given address is valid. NOTE: Since btcd does not have a wallet integrated, btcd will only return whether the address is valid or not.
30VerifychainNVerifies the block nining database.


5.2 Method Details



MethodAddnode
Parameters1. peer (string, required) - ip address and port of the peer to operate on

2. command (string, required) - to add a persistent peer, to remove a persistent peer, or sjon try a single connection to a peer
DescriptionAttempts to add or remove a persistent peer.
ReturnsNothing
Return to Overview



MethodCreaterawtransaction
Parameters1. transaction inputs (JSON array, required) - json array of json objects













2. addresses and amounts (JSON object, required) - json object with addresses as keys and amounts as values









3. locktime (int64, optional, default=0) - specifies the transaction locktime. Json rpc api bitcoin mining If non-zero, the inputs will also have their locktimes activated.
DescriptionReturns a new transaction spending the provided inputs and sending to the provided addresses.

The transaction inputs are not signed in the created transaction.

The RPC command provided by wallet must be used to Json rpc api bitcoin mining the resulting transaction.
Returns
Example Parameters1. transaction inputs

2. addresses and amounts

3. locktime
Example Return





Newlines added for display purposes. The actual return does not contain newlines.
Return to Moning. data Json rpc api bitcoin mining, required) - serialized, hex-encoded transaction
DescriptionReturns a JSON object representing the provided serialized, hex-encoded transaction.
Returns









For coinbase transactions:









For non-coinbase transactions:





















































Example Return









For coinbase transactions:









For non-coinbase transactions:



















































Return to Overview



MethodDecodescript
Parameters1. script (string, required) - hex-encoded script
DescriptionReturns a JSON object with information about the provided bitcin script.
Returns

















Example Return















Return to Overview



MethodGetaddednodeinfo
Parameters1. dns (boolean, required) - specifies whether the returned data is a JSON object including DNS and connection information, or just a list of added peers

2. node (string, optional) - only return information about this specific peer instead of Json rpc api bitcoin mining added peers.
DescriptionReturns information about manually added (persistent) peers.
Returns (dns=false)
Returns (dns=true)





















Example Return (dns=false)
Example Return (dns=true)





























Return to Overview



MethodGetbestblockhash
ParametersNone
DescriptionReturns the hash of the of the best (most recent) block in the longest block chain.
ReturnsString
Example Return
Return to Overview



MethodGetblock
Parameters1. block hash (string, required) - the hash of the block

2. verbose (boolean, optional, default=true) - specifies the block is returned as a JSON object instead of hex-encoded string

3. bitcin (boolean, optional, default=false) - specifies that each transaction is returned as a JSON object and only applies if the flag is true.This parameter is a btcd extension
DescriptionReturns information about a block given its hash.
Returns (verbose=false)
Returns (verbose=true, verbosetx=false)





































Returns Json rpc api bitcoin mining, verbosetx=true)



































Example Return (verbose=false)















Newlines added for display purposes. The actual return does not contain newlines.
Example Return Json rpc api bitcoin mining, verbosetx=false)































Return to Overview



MethodGetblockcount
ParametersNone
DescriptionReturns the number of blocks in the longest block chain.
ReturnsNumeric
Example Return
Return to Overview



MethodGetblockhash
Parameters1. block height (numeric, required)
DescriptionReturns hash of the block in best block chain at the given height.
ReturnsString
Example Return
Return to Overview



MethodGetblockheader
Parameters1. block hash (string, required) - Json rpc api bitcoin mining hash of the block

2. verbose (boolean, optional, default=true) - specifies the block header is returned as a JSON object instead of a hex-encoded string
DescriptionReturns hex-encoded bytes of the serialized block header.
Returns (verbose=false)
Returns (verbose=true)























Example Return (verbose=false)





Newlines added for display purposes. The actual return does not contain newlines.
Example Return (verbose=true)























Return to Overview



MethodGetconnectioncount
ParametersNone
DescriptionReturns the number of active connections to other peers
ReturnsNumeric
Example Return
Return to Overview



MethodGetdifficulty
ParametersNone
DescriptionReturns the proof-of-work difficulty as a multiple of the minimum difficulty.
ReturnsNumeric
Example Return
Return to Overview



MethodGetgenerate
ParametersNone
DescriptionReturn if the server is set to generate coins (mine) or not.
Returns(boolean)
Return to Overview



MethodGethashespersec
ParametersNone
DescriptionReturns a recent hashes per second performance measurement while generating coins (mining).
Returns(numeric)
Return to Overview



MethodGetinfo
ParametersNone
DescriptionReturns a JSON object containing various state info.
NotesNOTE: Since btcd does NOT contain wallet functionality, wallet-related fields are Json rpc api bitcoin mining returned. See getinfo in btcwallet for a version which includes that information.
Returns



















Example Return



















Return to Overview



MethodGetmempoolinfo
ParametersNone
DescriptionReturns a JSON object containing mempool-related information.
Returns





Example Return





Return to Overview



MethodGetmininginfo
ParametersNone
DescriptionReturns a JSON object containing mining-related information.
Returns













Zcash Integration Guide — Zcash Documentation 2.1.2 documentation



There are two variations of the original bitcoin program available; one with a graphical user interface (usually referred to as just “Bitcoin”), and a 'headless' version (called bitcoind). They are completely compatible with each other, and take the same command-line arguments, read the same configuration file, and read and write the same data files. You can run one copy of either Bitcoin or bitcoind on your system at a time (if you accidently try to launch another, the copy will let you rpx that Bitcoin or aapi is already running and will exit).



Linux Quickstart[edit]



The simplest way to start from scratch with the command line client, automatically syncing blockchain and creating a wallet, is to just run this command (without arguments) from the directory containing your bitcoind binary:


./bitcoind

To run with the standard GUI interface:


./bitcoin-qt

Command-line arguments[edit]



These commands are accurate as of Bitcoin Core version V0.14.0.



Command Description
-?Print this help apo and exit
- versionPrint version and exit
- alertnotify=<cmd>Execute Json rpc api bitcoin mining when a relevant alert is received or we see a really long fork (%s in cmd is replaced by message)
- blocknotify=<cmd>Execute command when the best block changes (%s in cmd is replaced by block hash)
- assumevalid=<hex>If this block is in the Json rpc api bitcoin mining assume that it and its ancestors are valid and potentially skip their script verification (0 to verify all, minong 00000000000000000013176bf8d7dfeab4e1db31dc93bc311b436e82ab226b90, testnet: 00000000000128796ee387cf110ccb9d2f36cffaf7f73079c995377c65ac0dcc)
- conf=<file>Specify configuration file (default: bitcoin. conf)
- datadir=<dir>Specify data directory
- dbcache=<n>Set database cache size in megabytes (4 to 16384, default: 300)
- loadblock=<file>Imports blocks from external blk000??.dat file on startup
- maxorphantx=<n>Keep at most <n> unconnectable transactions in memory (default: 100)
- maxmempool=<n> bitvoin Keep the transaction memory pool below <n> megabytes (default: 300)
- mempoolexpiry=<n>Do not keep transactions Json rpc api bitcoin mining the mempool longer than <n> hours (default: ison
- blockreconstructionextratxn=<n>Extra transactions to keep in memory for compact block reconstructions (default: 100)
- par=<n>Set the number of script verification threads (-2 to 16, 0 = auto, <0 = Json rpc api bitcoin mining that bitcpin cores free, default: 0)
- pid=<file>Specify pid file (default: bitcoind. pid)
- prune=<n>Reduce storage requirements prc enabling pruning (deleting) of old blocks. This allows the pruneblockchain RPC to be called to delete specific blocks, and enables automatic pruning of old blocks if a target size in MiB is provided. This mode is incompatible with - txindex and - rescan. Warning: Reverting this setting requires re-downloading the entire blockchain. (default: 0 = disable pruning blocks, 1 = allow manual pruning via RPC, >550 = automatically prune block files to stay under the specified target size in MiB)
- reindex-chainstateRebuild chain state from the currently nitcoin blocks
- reindexRebuild chain state and block index from the blk*.dat files on disk
- syspermsCreate new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)
- txindexJson rpc api bitcoin mining a full transaction index, used by the getrawtransaction rpc call (default: 0)


Connection options:
- addnode=<ip>Add a node to connect to and attempt to keep the connection open
- banscore=<n>Threshold for disconnecting misbehaving peers (default: 100)
- bantime=<n>Number of seconds minong keep misbehaving peers from Json rpc api bitcoin mining (default: 86400)
- bind=<addr>Bind to given address and always listen on it. Use [host]:port notation for IPv6
- connect=<ip>Connect only to the specified node(s); - noconnect or - connect=0 alone to disable automatic connections
- discoverDiscover own IP addresses (default: 1 when listening and no - externalip or - proxy)
- dnsAllow DNS lookups for - addnode, - seednode and - connect (default: 1)
- dnsseedQuery for peer addresses via DNS lookup, if low on addresses Json rpc api bitcoin mining 1 unless - connect/-noconnect)
- externalip=<ip>Specify your own public address
- forcednsseedAlways query for peer addresses via DNS lookup (default: 0)
- listenAccept connections from outside (default: 1 if no - proxy minijg - connect/-noconnect)
Json rpc api bitcoin miningAutomatically create Tor hidden service (default: 1)
- maxconnections=<n>Maintain at most <n> connections to peers (default: 125)
- maxreceivebuffer=<n>Maximum per-connection receive buffer, <n>*1000 bytes (default: 5000)
- maxsendbuffer=<n>Maximum per-connection send buffer, <n>*1000 bytes (default: 1000)
- maxtimeadjustmentMaximum allowed median peer time offset adjustment. Local perspective of time may be influenced by peers forward or backward by this amount. (default: 4200 seconds)
- onion=<ip:port>Use separate SOCKS5 proxy to reach peers via Tor hidden services (default: - proxy)
- onlynet=<net>Only connect to nodes in network <net> (ipv4, rpv or onion)
- permitbaremultisigRelay non-P2SH multisig (default: 1)
- peerbloomfiltersSupport filtering of blocks and transaction with bloom filters (default: 1)
- port=<port>Listen for apo on <port> (default: 8333 or testnet: 18333)
- proxy=<ip:port>Connect through SOCKS5 proxy
- proxyrandomizeRandomize credentials for every proxy connection. This enables Tor stream isolation (default: 1)
- rpcserialversionSets the serialization of raw transaction or block hex returned in non-verbose mode, non-segwit(0) or mininng (default: 1)
- seednode=<ip>Connect to a node bitcon retrieve peer addresses, and disconnect
- timeout=<n>Specify Json rpc api bitcoin mining timeout in milliseconds (minimum: 1, default: Json rpc api bitcoin mining
- torcontrol=<ip>:<port>Tor control port to use if onion listening enabled (default: 127.0.0.1:9051)
- torpassword=<pass>Tor control port password (default: empty)
- upnp=<pass>Use UPnP to map gitcoin listening port (default: 0)
- whitebind=<addr>Bind to given address and whitelist peers connecting to it. Use [host]:port notation for IPv6
- whitelist=<IP address or network>Whitelist peers connecting from the given IP address (e. g. 1.2.3.4) or CIDR notated network (e. g. 1.2.3.0/24). Can be specified multiple times. Whitelisted peers cannot be DoS banned and their transactions are always relayed, even if they are already in the mempool, useful e. g. for a gateway
bitccoinAccept relayed transactions received from whitelisted peers even when not relaying transactions (default: 1)
- whitelistforcerelayPai relay of transactions from whitelisted peers even jzon they violate local relay policy (default: 1)
- maxuploadtarget=<n>Tries to keep outbound traffic under the Json rpc api bitcoin mining target (in MiB per 24h), 0 = no limit (default: 0)


Wallet options:
- disablewalletDo not load the wallet and disable wallet RPC calls
- keypool=<n>Set key pool size to <n> (default: 100)
- fallbackfee=<amt>A fee rate (in Minibg that will be used when fee estimation has insufficient data (default: 0.0002)
- mintxfee=<amt>Fees (in BTC/kB) smaller than this are considered zero fee for transaction creation (default: 0.00001)
- paytxfee=<amt>Fee (in BTC/kB) to add to transactions you send (default: 0.00)
- rescanRescan the block chain for missing wallet transactions on startup Json rpc api bitcoin mining - salvagewalletAttempt a;i recover private keys from a corrupt wallet on startup
- spendzeroconfchangeSpend unconfirmed change when sending transactions (default: 1)
- txconfirmtarget=<n>If paytxfee is not set, include enough fee so transactions begin confirmation on average within n blocks (default: 6)
- usehdUse hierarchical deterministic key generation (HD) after BIP32. Only has effect during wallet creation/first start (default: 1)
- walletrbfSend transactions with full-RBF opt-in enabled (default: 0)
- upgradewalletUpgrade wallet to latest format on startup
- wallet=<file>Specify wallet file (within data directory) (default: wallet. dat)
- walletbroadcastMake the wallet broadcast transactions (default: 1)
- walletnotify=<cmd>Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)
- zapwallettxes=<mode>Delete all wallet transactions and only recover those parts of the blockchain through - rescan on startup (1 = keep tx meta data e. g. account owner and payment request information, 2 = drop tx meta data)


ZeroMQ notification options:
- zmqpubhashblock=<address>Enable publish hash block in <address>
- zmqpubhashtx=<address>Enable publish hash transaction in <address>
- zmqpubrawblock=<address>Enable publish raw block in <address> jsin - zmqpubrawtx=<address>Enable publish raw transaction in <address>


Debugging/Testing options:
- uacomment=<cmt>Append comment to the user agent string
- debug=<category>Output debugging information (default: 0, supplying <category> is optional). If <category> is not supplied or if <category> = 1, output all debugging information.<category> can Json rpc api bitcoin mining addrman, alert, bench, cmpctblock, coindb, db, http, libevent, lock, mempool, mempoolrej, net, proxy, prune, Json rpc api bitcoin mining, reindex, rpc, selectcoins, tor, zmq, qt.
- help-debugShow all debugging options (usage: --help - help-debug)
- logipsInclude IP addresses in debug output (default: 0)
- logtimestampsPrepend debug ap with timestamp (default: 1)
- minrelaytxfee=<amt>Fees (in BTC/kB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: 0.00001)
- maxtxfee=<amt>Maximum total fees (in Bltcoin to use in a single bitcin transaction or raw transaction; setting this too low may abort large transactions (default: 0.10)
- printtoconsoleSend trace/debug info to console instead of debug. log file
- shrinkdebugfileXpi debug. log file on client startup imning 1 when no - debug)


Chain selection options:
- testnetUse the aoi chain


Node relay options:
- bytespersigop Json rpc api bitcoin mining Equivalent bytes per sigop in transactions for relay and mining (default: 20)
- datacarrierRelay and mine data carrier transactions (default: 1)
- datacarriersizeMaximum size of data in data carrier transactions we relay and mine (default: 83)
- mempoolreplacementEnable transaction replacement in the memory pool (default: 1) Json rpc api bitcoin mining colspan="3">

Block creation options:
- blockmaxweight=<n>Set maximum BIP141 block weight (default: 3000000)
- blockmaxsize=<n>Set maximum block size in bytes (default: 750000)
- blockprioritysize=<n>Set maximum size of high-priority/low-fee transactions in bytes (default: 0)
- blockmintxfee=<amt>Set lowest fee rate (in BTC/kB) Json rpc api bitcoin mining transactions to be included in block creation. (default: 0.00001)


RPC server options:
- serverAccept command line and Jon commands
- restAccept public REST requests (default: Json rpc api bitcoin mining
- rpcbind=<addr>Bind to given address to listen for JSON-RPC connections. Use [host]:port notation for IPv6. This option can be specified multiple times (default: bind to all interfaces)
- rpccookiefile=<loc>Location of the auth cookie (default: data dir)
- rpcuser=<user>Username for JSON-RPC Json rpc api bitcoin mining
- rpcpassword=<pw> mininf Password for JSON-RPC connections
- rpcauth=<userpw>Username and hashed password for Rc connections. The field <userpw> comes in the format: <USERNAME>:<SALT>$<HASH>. A canonical python script is included in share/rpcuser. The rcp then connects normally using the rpcuser=<USERNAME>/rpcpassword=<PASSWORD> pair of arguments. This miing can be specified multiple times
- rpcport=<port>Listen for JSON-RPC connections on <port> (default: 8332 or testnet: 18332)
- rpcallowip=<ip>Allow JSON-RPC connections from specified source. Valid for <ip> are a single IP (e. g. 1.2.3.4), a jsoj (e. g. 1.2.3.4/255.255.255.0) or a network/CIDR (e. g. 1.2.3.4/24). This option can be specified multiple times
- rpcthreads=<n>Set the number of threads to service RPC calls (default: 4)


UI Options:
spiChoose data directory on startup (default: 0)
- lang=<lang>Set language, for example "de_DE" (default: system locale)
- minStart minimized
- rootcertificates=<file>Set SSL root certificates for payment request (default: - system-)
- splashShow splash screen on startup (default: 1)
- resetguisettingsReset all settings changed in the GUI


Many of the boolean options can also be set to off by specifying them with a "no" prefix: e. g. - nodnseed.



Bitcoin. conf Configuration File[edit]



All command-line options (except for - conf) may be specified in a configuration file, and all configuration file options may also be specified on the command line. Command-line options override values set in the configuration file.



The configuration file is a list of setting=value pairs, one per line, with optional comments starting with the '#' character. miniing configuration file is not automatically created; you can create it using your Json rpc api bitcoin mining plain-text editor. A user-friendly configuration file generator is available here. By default, Bitcoin (or bitcoind) will look for a file named 'bitcoin. conf' in the bitcoin data apii, but both the data directory and the configuration file path may be changed using the - datadir and - conf command-line arguments.



Operating System Default bitcoin datadir Typical path to configuration file
Windows%APPDATA%\Bitcoin\C:\Users\username\AppData\Roaming\Bitcoin\bitcoin. conf
Linux$HOME/.bitcoin//home/username/.bitcoin/bitcoin. conf
Mac OSX$HOME/Library/Application Support/Bitcoin/Json rpc api bitcoin mining Support/Bitcoin/bitcoin. conf


Note: if running Bitcoin in testnet mode, the sub-folder "testnet" will be appended to the data directory automatically.



Sample Bitcoin. conf[edit]



Copied from https://github. com/bitcoin/bitcoin/blob/master/contrib/debian/examples/bitcoin. conf:


## ## bitcoin. conf configuration file. Lines beginning with # are comments. ## # Network-related settings: # Run on the test network instead of the real bitcoin network. #testnet=0 # Run a regression test network #regtest=0 # Connect via a SOCKS5 proxy #proxy=127.0.0.1:9050 # Bind to given address and always listen on it. Use [host]:port notation for IPv6 #bind=<addr> # Bitcoln Json rpc api bitcoin mining given address and whitelist peers connecting to it. Use [host]:port notation minibg IPv6 #whitebind=<addr> ############################################################## Json rpc api bitcoin mining Quick Primer on addnode vs connect ## ## Let's say for instance you use addnode=4.2.2.4 ## ## addnode will connect you Json rpc api bitcoin mining and tell you about the ## ## nodes connected to 4.2.2.4. In addition it will tell ## ## the other nodes connected to it that you exist so ## ## they can connect to you. ## ## connect will not do epc above Json rpc api bitcoin mining you 'connect' to it. ## ## It will *only* connect you to 4.2.2.4 and no one else.## ## bitfoin ## mmining So roc you're behind a firewall, or have other problems ## ## finding nodes, add some using 'addnode'. ## ## ## ## If you aoi to stay private, use 'connect' to only ## Json rpc api bitcoin mining connect rcp "trusted" nodes. ## ## ## ## If you run multiple nodes on a LAN, there's no need for ## ## all of them to open lots of connections. Instead ## ## 'connect' them all to one node that is port forwarded ## ## and has lots of connections. ## ## Thanks goes to [Noodle] on Freenode. ## ############################################################## # Minung as many addnode= settings as you like to connect to specific peers #addnode=69.164.218.197 #addnode=10.0.0.2:8333 # Alternatively use as many connect= settings as you like to connect ONLY to specific peers #connect=69.164.218.197 #connect=10.0.0.1:8333 # Listening mode, enabled by default except when 'connect' is being used #listen=1 # Maximum number of inbound+outbound connections. #maxconnections= # # JSON-RPC options (for controlling a running Bitcoin/bitcoind process) # # server=1 tells Bitcoin-Qt and bitcoind to accept JSON-RPC commands butcoin # Bind to given address to listen for JSON-RPC connections. Use [host]:port notation for IPv6. # This option can be specified multiple times Json rpc api bitcoin mining bind to all interfaces) #rpcbind=<addr> # If no rpcpassword jzon set, rpc cookie auth is sought. Ap default Json rpc api bitcoin mining name # is. cookie and found in the `-datadir` being used for bitcoind. This option is typically used # when the server and client are run as the same user. # # If not, pai must set rpcuser and rpcpassword to secure the JSON-RPC api. Minnig first # method(DEPRECATED) is to set this pair for the server and client: #rpcuser=Ulysseys #rpcpassword=YourSuperGreatPasswordNumber_DO_NOT_USE_THIS_OR_YOU_WILL_GET_ROBBED_385593 # # The second method `rpcauth` can be added to server startup argument. It is set at intialization time # using the output imning the script in share/rpcuser/rpcuser. py after providing a username: # # ./share/rpcuser/rpcuser. py alice # String to be appended to bitcoin. conf: # rpcauth=alice:f7efda5c189b999524f151318c0c86$d5b51b3beffbc02b724e5d095828e0bc8b2456e9ac8757ae3211a5d9b16a22ae # Your password: # DONT_USE_THIS_YOU_WILL_GET_ROBBED_8ak1gI25KFTvjovL3gAM967mies3E= # # On client-side, you add the normal user/password sjon to send commands: #rpcuser=alice #rpcpassword=DONT_USE_THIS_YOU_WILL_GET_ROBBED_8ak1gI25KFTvjovL3gAM967mies3E= # # You can even add multiple entries of these to the server conf file, and client can use any of them: # rpcauth=bob:b2dd077cb54591a2f3139e69a897ac$4e71f08d48b4347cf8eff3815c0e25ae2e9a4340474079f55705f40574f4ec99 # How many seconds bitcoin will wait for a complete RPC HTTP request. # after minihg HTTP connection is established. #rpcclienttimeout=30 # By default, only RPC connections from localhost are allowed. # Specify as many rpcallowip= settings as you like to allow connections from other hosts, # either as a single IPv4/IPv6 or with a subnet specification. # NOTE: opening up the RPC port to hosts outside your local trusted network is NOT RECOMMENDED, # because the rpcpassword is transmitted over the network unencrypted. # server=1 tells Bitcoin-Qt to accept JSON-RPC commands. # it is also read by bitcoind to determine if RPC should be enabled #rpcallowip=10.1.1.34/255.255.255.0 #rpcallowip=1.2.3.4/24 #rpcallowip=2001:db8:85a3:0:0:8a2e:370:7334/96 # Listen for RPC connections on this TCP port: #rpcport=8332 # You can use Bitcoin or bitcoind to send commands to Bitcoin/bitcoind # running on another host using this option: #rpcconnect=127.0.0.1 # Create transactions that have enough fees so they are Json rpc api bitcoin mining to begin confirmation within n blocks (default: 6). # This setting is gpc by the - paytxfee option. #txconfirmtarget=n # Miscellaneous options biycoin Pre-generate this many public/private key pairs, so wallet backups will be valid for # both appi transactions and several dozen future transactions. #keypool=100 # Pay an optional transaction fee every time you send bitcoins. Mihing with fees # are more likely than free transactions to be included in generated blocks, so may # be validated sooner. #paytxfee=0.00 # Enable pruning to reduce storage requirements by deleting old blocks. gpc This mode is incompatible with - txindex and - rescan. # 0 = default (no pruning). # minkng = allows manual pruning via RPC. # >=550 = target to stay under in MiB. #prune=550 # User interface options # Start Bitcoin minimized #min=1 # Minimize to the system tray #minimizetotray=1

Platforms[edit]



Windows[edit]



Start automatically[edit]



To configure the Bitcoin client to start automatically:



You might use the configuration-file, or the Jdon



Settings -> Options



Then mark the checkbox titled:


[X] Start Json rpc api bitcoin mining on system startup



Batch automation[edit]



To work with batch, you have to start the daemon (bitcoind. exe). The bitcoin. exe run with option "-server" will respond with GUI-messages you are not able to process its answers.



Mac[edit]





Linux[edit]





See Also on BitcoinWiki[edit]



Links[edit]

Комментариев нет:

Отправить комментарий