Skip to content

Commit 89330ca

Browse files
fix: updated libbitcoinrpc repository links
1 parent e53f72a commit 89330ca

3 files changed

Lines changed: 34 additions & 34 deletions

File tree

16_1_Accessing_Bitcoind_with_C.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ You've already seen one alternative way to access the Bitcoind's RPC ports: `cur
66

77
## Set Up libbitcoinrpc
88

9-
> :warning: **WARNING** It appears that `libbitcoinrpc` has been entirely abandoned. We have logged updating this to a new C library as an [issue](https://github.com/BlockchainCommons/Community/issues/140). In the meantime, the `libbitcoinrpc` library does not currently compile without intervention. As a result 16.1 and 16.2 is mainly viewable as pseudo-code that shows the process of integrating Bitcoin-Core with C.
10-
9+
> :warning: **WARNING** It appears that `libbitcoinrpc` has been entirely abandoned. We have logged updating this to a new C library as an [issue](https://github.com/BlockchainCommons/Community/issues/140). In the meantime, the `libbitcoinrpc` library does not currently compile without intervention. As a result 16.1 and 16.2 is mainly viewable as pseudo-code that shows the process of integrating Bitcoin-Core with C.
10+
1111
To use `libbitcoinrpc`, you need to install a basic C setup and the dependent packages `libcurl`, `libjansson`, and `libuuid`. The following will do so on your Bitcoin Standup server (or any other Ubuntu server).
1212
```
1313
$ sudo apt-get install make gcc libcurl4-openssl-dev libjansson-dev uuid-dev
@@ -20,13 +20,13 @@ Need to get 358 kB of archives.
2020
After this operation, 1.696 kB of additional disk space will be used.
2121
Do you want to continue? [Y/n] y
2222
```
23-
You can then download [libbitcoinrpc from Github](https://github.com/gitmarek/libbitcoinrpc/blob/master/README.md). Clone it or grab a zip file, as you prefer.
23+
You can then download [libbitcoinrpc from Github](https://github.com/BlockchainCommons/libbitcoinrpc/blob/master/README.md). Clone it or grab a zip file, as you prefer.
2424
```
2525
$ sudo apt-get install git
2626
$ git clone https://github.com/BlockchainCommons/libbitcoinrpc.git
2727
```
2828

29-
> :warning: **WARNING** A change in the "signrawtransaction" RPC caused signing with `libbitcoinrpc` to segfault for Bitcoin 0.17 or higher. A [PR has been submitted](https://github.com/gitmarek/libbitcoinrpc/pull/1/commits) to resolve the problem, but if it hasn't yet been merged, you can just make the one simple change in the source code to `src/bitcoinrpc_method.c` before compiling.
29+
> :warning: **WARNING** A change in the "signrawtransaction" RPC caused signing with `libbitcoinrpc` to segfault for Bitcoin 0.17 or higher. A [PR has been submitted](https://github.com/gitmarek/libbitcoinrpc/pull/1) to resolve the problem, but if it hasn't yet been merged, you can just make the one simple change in the source code to `src/bitcoinrpc_method.c` before compiling.
3030
3131
### Compiling libbitcoinrpc
3232

@@ -36,7 +36,7 @@ $ PATH="/sbin:$PATH"
3636
```
3737
For an Ubuntu system, you'll also want to adjust the `INSTALL_LIBPATH` in the `libbitcoinrpc` `Makefile` to install to `/usr/lib` instead of `/usr/local/lib`:
3838
```
39-
$ emacs ~/libbitcoinrpc/Makefile
39+
$ emacs ~/libbitcoinrpc/Makefile
4040
...
4141
INSTALL_LIBPATH := $(INSTALL_PREFIX)/usr/lib
4242
```
@@ -71,7 +71,7 @@ ln -fs libbitcoinrpc.so.0 .lib/libbitcoinrpc.so
7171
If that works, you can install the package:
7272
```
7373
$ sudo make install
74-
Installing to
74+
Installing to
7575
install .lib/libbitcoinrpc.so.0.2 /usr/local/lib
7676
ldconfig -n /usr/local/lib
7777
ln -fs libbitcoinrpc.so.0 /usr/local/lib/libbitcoinrpc.so
@@ -110,7 +110,7 @@ bitcoinrpc_global_init();
110110
```
111111
Then connect to your `bitcoind` with `bitcoinrpc_cl_init_params`. The four arguments for `bitcoinrpc_cl_init_params` are username, password, IP address, and port. You should already know all of this information from your work with [Curl](04_4__Interlude_Using_Curl.md). As you'll recall, the IP address 127.0.0.1 and port 18332 should be correct for the standard testnet setup described in these documents, while you can extract the user and password from `~/.bitcoin/bitcoin.conf`.
112112
```
113-
$ cat bitcoin.conf
113+
$ cat bitcoin.conf
114114
server=1
115115
dbcache=1536
116116
par=1
@@ -154,15 +154,15 @@ Test code can be found at [16_1_testbitcoin.c in the src directory](src/16_1_tes
154154
You can compile and run this as follows:
155155
```
156156
$ cc testbitcoin.c -lbitcoinrpc -ljansson -o testbitcoin
157-
$ ./testbitcoin
157+
$ ./testbitcoin
158158
Successfully connected to server!
159159
```
160160

161161
> :warning: **WARNING:** If you forget to enter your RPC password in this or any other code samples that depend on RPC, you will receive a mysterious `ERROR CODE 5`.
162162
163163
## Make an RPC Call
164164

165-
In order to use an RPC method using `libbitcoinrpc`, you must initialize a variable of type `bitcoinrpc_method_t`. You do so with the appropriate value for the method you want to use, all of which are listed in the [bitcoinrpc Reference](https://github.com/gitmarek/libbitcoinrpc/blob/master/doc/reference.md).
165+
In order to use an RPC method using `libbitcoinrpc`, you must initialize a variable of type `bitcoinrpc_method_t`. You do so with the appropriate value for the method you want to use, all of which are listed in the [bitcoinrpc Reference](https://github.com/BlockchainCommons/libbitcoinrpc/blob/master/doc/reference.md).
166166
```
167167
bitcoinrpc_method_t *getmininginfo = NULL;
168168
getmininginfo = bitcoinrpc_method_init(BITCOINRPC_METHOD_GETMININGINFO);
@@ -193,7 +193,7 @@ printf ("%s\n", json_dumps(j, JSON_INDENT(2)));
193193
```
194194
However, since you're now writing complete programs, you probably want to do more subtle work, such as pulling out individual JSON values for specific usage. The [jansson Reference](https://jansson.readthedocs.io/en/2.10/apiref.html) details how to do so.
195195

196-
Just as when you were using [Curl](04_4__Interlude_Using_Curl.md), you'll find that RPC returns a JSON object containing an `id`, an `error`, and most importantly a JSON object of the `result`.
196+
Just as when you were using [Curl](04_4__Interlude_Using_Curl.md), you'll find that RPC returns a JSON object containing an `id`, an `error`, and most importantly a JSON object of the `result`.
197197

198198
The `json_object_get` function will let you retrieve a value (such as the `result`) from a JSON object by key:
199199
```
@@ -218,7 +218,7 @@ printf("Block Count: %d\n",blocks);
218218
Retrieve the test code from [the src directory](src/16_1_getmininginfo.c).
219219
```
220220
$ cc getmininginfo.c -lbitcoinrpc -ljansson -o getmininginfo
221-
$ ./getmininginfo
221+
$ ./getmininginfo
222222
Full Response: {
223223
"result": {
224224
"blocks": 1804406,
@@ -245,11 +245,11 @@ Block Count: 1804406
245245
```
246246
## Make an RPC Call with Arguments
247247

248-
But what if your RPC call _did_ have arguments?
248+
But what if your RPC call _did_ have arguments?
249249

250250
### Create a JSON Array
251251

252-
To send parameters to your RPC call using `libbitcoinrpc` you have to wrap them in a JSON array. Since an array is just a simple listing of values, all you have to do is encode the parameters as ordered elements in the array.
252+
To send parameters to your RPC call using `libbitcoinrpc` you have to wrap them in a JSON array. Since an array is just a simple listing of values, all you have to do is encode the parameters as ordered elements in the array.
253253

254254
Create the JSON array using the `json_array` function from `jansson`:
255255
```
@@ -262,7 +262,7 @@ json_array_append_new(params,json_string(tx_rawhex));
262262
```
263263
Note that there are two variants to the append command: `json_array_append_new`, which appends a newly created variable, and `json_array_append`, which appends an existing variable.
264264

265-
This simple `json_array_append_new` methodology will serve for the majority of RPC commands with parameters, but some RPC commands require more complex inputs. In these cases you may need to create subsidiary JSON objects or JSON arrays, which you will then append to the parameters array as usual. The next section contains an example of doing so using `createrawtransaction`, which contains a JSON array of JSON objects for the inputs, a JSON object for the outputs, and the `locktime` parameter.
265+
This simple `json_array_append_new` methodology will serve for the majority of RPC commands with parameters, but some RPC commands require more complex inputs. In these cases you may need to create subsidiary JSON objects or JSON arrays, which you will then append to the parameters array as usual. The next section contains an example of doing so using `createrawtransaction`, which contains a JSON array of JSON objects for the inputs, a JSON object for the outputs, and the `locktime` parameter.
266266

267267
### Assign the Parameters
268268

es/16_1_Accediendo_a_Bitcoind_en_C_con_las_Bibliotecas_RPC.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ Need to get 358 kB of archives.
1818
After this operation, 1.696 kB of additional disk space will be used.
1919
Do you want to continue? [Y/n] y
2020
```
21-
Puede descargar [libbitcoinrpc de Github](https://github.com/gitmarek/libbitcoinrpc/blob/master/README.md). Clónelo o tome un archivo zip, como prefiera.
21+
Puede descargar [libbitcoinrpc de Github](https://github.com/BlockchainCommons/libbitcoinrpc/blob/master/README.md). Clónelo o tome un archivo zip, como prefiera.
2222
```
2323
$ sudo apt-get install git
24-
$ git clone https://github.com/gitmarek/libbitcoinrpc
24+
$ git clone https://github.com/BlockchainCommons/libbitcoinrpc
2525
```
2626

27-
> :warning: **ADVERTENCIA** Un cambio en el RPC de "signrawtransaction" provocó que la firma con `libbitcoinrpc` provocara un segfault para Bitcoin 0.17 o superior. [Se ha enviado un PR](https://github.com/gitmarek/libbitcoinrpc/pull/1/commits) para resolver el problema, pero si aún no se ha fusionado, puede hacer un simple cambio en el código fuente `src/bitcoinrpc_method.c` antes de compilar.
27+
> :warning: **ADVERTENCIA** Un cambio en el RPC de "signrawtransaction" provocó que la firma con `libbitcoinrpc` provocara un segfault para Bitcoin 0.17 o superior. [Se ha enviado un PR](https://github.com/gitmarek/libbitcoinrpc/pull/1) para resolver el problema, pero si aún no se ha fusionado, puede hacer un simple cambio en el código fuente `src/bitcoinrpc_method.c` antes de compilar.
2828
2929

3030
### Compilar libbitcoinrpc
@@ -35,7 +35,7 @@ $ PATH="/sbin:$PATH"
3535
```
3636
Para un sistema Ubuntu, también querrá ajustar el `INSTALL_LIBPATH` en el fichero `Makefile` de `libbitcoinrpc` para instalar en `/usr/lib` lugar de `/usr/local/lib`:
3737
```
38-
$ emacs ~/libbitcoinrpc/Makefile
38+
$ emacs ~/libbitcoinrpc/Makefile
3939
...
4040
INSTALL_LIBPATH := $(INSTALL_PREFIX)/usr/lib
4141
```
@@ -70,7 +70,7 @@ ln -fs libbitcoinrpc.so.0 .lib/libbitcoinrpc.so
7070
Si eso funciona, puede instalar el paquete:
7171
```
7272
$ sudo make install
73-
Installing to
73+
Installing to
7474
install .lib/libbitcoinrpc.so.0.2 /usr/local/lib
7575
ldconfig -n /usr/local/lib
7676
ln -fs libbitcoinrpc.so.0 /usr/local/lib/libbitcoinrpc.so
@@ -109,7 +109,7 @@ bitcoinrpc_global_init();
109109
```
110110
Luego conéctese a su `bitcoind` con `bitcoinrpc_cl_init_params`. Los cuatro argumentos son `bitcoinrpc_cl_init_params` son nombre de usuario, contraseña, dirección IP y puerto. Ya debería conocer toda esta información de su trabajo con [Curl](04_4_Interludio_Usando_Curl.md). Como recordará, la dirección IP 127.0.0.1 y el puerto 18332 deben ser correctos para la configuración estándar de testnet descrita en estos documentos, mientras que puede extraer el usuario y la contraseña de `~/.bitcoin/bitcoin.conf`.
111111
```
112-
$ cat bitcoin.conf
112+
$ cat bitcoin.conf
113113
server=1
114114
dbcache=1536
115115
par=1
@@ -153,15 +153,15 @@ El código de prueba se puede encontrar en el directorio src [16_1_testbitcoin.c
153153
Puede compilar y ejecutar esto de la siguiente manera:
154154
```
155155
$ cc testbitcoin.c -lbitcoinrpc -ljansson -o testbitcoin
156-
$ ./testbitcoin
156+
$ ./testbitcoin
157157
Successfully connected to server!
158158
```
159159

160160
> :warning: **ADVERTENCIA:** Si olvida ingresar su contraseña RPC en este o cualquier otro código de muestra que dependa de RPC, recibirá un mensaje misterioso `ERROR CODE 5`.
161161
162162
## Realizar una llamada RPC
163163

164-
Para utilizar un método RPC con `libbitcoinrpc`, debe inicializar una variable de tipo `bitcoinrpc_method_t`. Lo hace con el valor apropiado para el método que desea utilizar, todos los cuales se enumeran en la [referencia bitcoinrpc](https://github.com/gitmarek/libbitcoinrpc/blob/master/doc/reference.md).
164+
Para utilizar un método RPC con `libbitcoinrpc`, debe inicializar una variable de tipo `bitcoinrpc_method_t`. Lo hace con el valor apropiado para el método que desea utilizar, todos los cuales se enumeran en la [referencia bitcoinrpc](https://github.com/BlockchainCommons/libbitcoinrpc/blob/master/doc/reference.md).
165165
```
166166
bitcoinrpc_method_t *getmininginfo = NULL;
167167
getmininginfo = bitcoinrpc_method_init(BITCOINRPC_METHOD_GETMININGINFO);
@@ -192,7 +192,7 @@ printf ("%s\n", json_dumps(j, JSON_INDENT(2)));
192192
```
193193
Sin embargo, dado que ahora está escribiendo programas completos, probablemente desee hacer un trabajo más sutil, como extraer valores JSON individuales para un uso específico. La [referencia jansson](https://jansson.readthedocs.io/en/2.10/apiref.html) detalla cómo hacerlo.
194194

195-
Al igual que cuando usaba [Curl](04_4_Interludio_Usando_Curl.md), encontrará que RPC devuelve un objeto JSON que contiene un `id`, un `error`, y, lo más importante, un objeto JSON de `result`.
195+
Al igual que cuando usaba [Curl](04_4_Interludio_Usando_Curl.md), encontrará que RPC devuelve un objeto JSON que contiene un `id`, un `error`, y, lo más importante, un objeto JSON de `result`.
196196

197197
La función `json_object_get` le permitirá recuperar un valor (como el `result`) de un objeto JSON por clave:
198198
```
@@ -217,7 +217,7 @@ printf("Block Count: %d\n",blocks);
217217
Recupere el código de prueba del [directorio src](../src/16_1_getmininginfo.c).
218218
```
219219
$ cc getmininginfo.c -lbitcoinrpc -ljansson -o getmininginfo
220-
$ ./getmininginfo
220+
$ ./getmininginfo
221221
Full Response: {
222222
"result": {
223223
"blocks": 1804406,
@@ -261,7 +261,7 @@ json_array_append_new(params,json_string(tx_rawhex));
261261
```
262262
Tenga en cuenta que hay dos variantes del comando append: `json_array_append_new`, que agrega una variable recién creada y `json_array_append`, que agrega una variable existente.
263263

264-
Esta sencilla metodología `json_array_append_new` servirá para la mayoría de los comandos RPC con parámetros, pero algunos comandos RPC requieren entradas más complejas. En estos casos, es posible que deba crear objetos JSON subsidiarios o matrices JSON, que luego agregará a la matriz de parámetros como de costumbre. La siguiente sección contiene un ejemplo de cómo hacerlo usando `createrawtransaction`, que contiene una matriz JSON de objetos JSON para las entradas, un objeto JSON para las salidas y el parámetro `locktime`.
264+
Esta sencilla metodología `json_array_append_new` servirá para la mayoría de los comandos RPC con parámetros, pero algunos comandos RPC requieren entradas más complejas. En estos casos, es posible que deba crear objetos JSON subsidiarios o matrices JSON, que luego agregará a la matriz de parámetros como de costumbre. La siguiente sección contiene un ejemplo de cómo hacerlo usando `createrawtransaction`, que contiene una matriz JSON de objetos JSON para las entradas, un objeto JSON para las salidas y el parámetro `locktime`.
265265

266266
### Asignar los parámetros
267267

pt/16_1_Accessing_Bitcoind_with_C.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ Need to get 358 kB of archives.
1919
After this operation, 1.696 kB of additional disk space will be used.
2020
Do you want to continue? [Y/n] y
2121
```
22-
Agora, podemos baixar o [libbitcoinrpc no github](https://github.com/gitmarek/libbitcoinrpc/blob/master/readme.md). Vamos clonar ou pegar um arquivo zip, do jeito que preferir.
22+
Agora, podemos baixar o [libbitcoinrpc no github](https://github.com/BlockchainCommons/libbitcoinrpc/blob/master/readme.md). Vamos clonar ou pegar um arquivo zip, do jeito que preferir.
2323

2424
```
2525
$ sudo apt-get install git
26-
$ git clone https://github.com/gitmarek/libbitcoinrpc
26+
$ git clone https://github.com/BlockchainCommons/libbitcoinrpc
2727
```
2828

29-
> :warning: **ATENÇÃO** Uma alteração no RPC "signrawtransaction" causou uma assinatura com ``libbitcoinrpc`` para o segfault no Bitcoin 0.17 ou superior. O [Pull Request foi submetido](https://github.com/gitmarek/libbitcoinrpc/pull/1/commits) para resolver o problema, mas se ainda não tiver sido feito o merge, podemos simplesmente fazer uma simples mudança no código-fonte para ``src/bitcoinrpc_method.c`` antes de compilarmos.
29+
> :warning: **ATENÇÃO** Uma alteração no RPC "signrawtransaction" causou uma assinatura com ``libbitcoinrpc`` para o segfault no Bitcoin 0.17 ou superior. O [Pull Request foi submetido](https://github.com/gitmarek/libbitcoinrpc/pull/1) para resolver o problema, mas se ainda não tiver sido feito o merge, podemos simplesmente fazer uma simples mudança no código-fonte para ``src/bitcoinrpc_method.c`` antes de compilarmos.
3030
3131
### Compilando o libbitcoinrpc
3232

@@ -38,7 +38,7 @@ $ PATH="/sbin:$PATH"
3838
Para o Ubuntu, também precisaremos ajustar o ``install_libpath`` no ``makefile`` do ``libbitcoinrpc`` para instalar no ``/usr/lib`` ao invés do ``/usr/local/lib``:
3939

4040
```
41-
$ emacs ~/libbitcoinrpc/Makefile
41+
$ emacs ~/libbitcoinrpc/Makefile
4242
...
4343
INSTALL_LIBPATH := $(INSTALL_PREFIX)/usr/lib
4444
```
@@ -75,7 +75,7 @@ ln -fs libbitcoinrpc.so.0 .lib/libbitcoinrpc.so
7575
Se tudo correr bem, podemos instalar o pacote:
7676
```
7777
$ sudo make install
78-
Installing to
78+
Installing to
7979
install .lib/libbitcoinrpc.so.0.2 /usr/local/lib
8080
ldconfig -n /usr/local/lib
8181
ln -fs libbitcoinrpc.so.0 /usr/local/lib/libbitcoinrpc.so
@@ -116,7 +116,7 @@ bitcoinrpc_global_init();
116116
```
117117
Em seguida, vamos conectar ao ``Bitcoind`` com ``bitcoinrpc_cl_init_params``. Os quatro argumentos necessários para o ``bitcoinrpc_cl_init_params`` são o nome de usuário, a senha, o endereço IP e a porta. A esta altura, você deve saber todas essas informações, já que foram necessárias para realizar o trabalho com o [curl](04_4__interlude_using_curl.md). Apenas para recordar, o endereço de IP é 127.0.0.1 e a porta 18332 devem estar corretos para a configuração padrão da testenet descrita neste documento, enquanto podemos encontrar o usuário e a senha no arquivo ``~/.bitcoin/bitcoin.conf``.
118118
```
119-
$ cat bitcoin.conf
119+
$ cat bitcoin.conf
120120
server=1
121121
dbcache=1536
122122
par=1
@@ -160,15 +160,15 @@ O código de teste pode ser encontrado [no diretório src com o nome 16_1_testbi
160160
Podemos compilar e executar o código da seguinte maneira:
161161
```
162162
$ cc testbitcoin.c -lbitcoinrpc -ljansson -o testbitcoin
163-
$ ./testbitcoin
163+
$ ./testbitcoin
164164
Successfully connected to server!
165165
```
166166

167167
> :warning: **ATENÇÃO:** Se esquecermos de inserir a senha RPC nesta ou em qualquer outro código que possuem dependências do RPC, receberemos um misterioso ``ERROR CODE 5``.
168168
169169
## Fazendo uma Chamada ao RPC
170170

171-
Para usarmos um método RPC usando ``libbitcoinrpc``, devemos inicializar uma variável do tipo ``bitcoinrpc_method_t``. Podemos fazer com o valor apropriado para o método que desejamos utilizar, que estão todos listados na [Referências do BitcoinRPC](https://github.com/gitmarek/libbitcoinrpc/blob/master/doc/reference.md).
171+
Para usarmos um método RPC usando ``libbitcoinrpc``, devemos inicializar uma variável do tipo ``bitcoinrpc_method_t``. Podemos fazer com o valor apropriado para o método que desejamos utilizar, que estão todos listados na [Referências do BitcoinRPC](https://github.com/BlockchainCommons/libbitcoinrpc/blob/master/doc/reference.md).
172172
``` c
173173
bitcoinrpc_method_t *getmininginfo = NULL;
174174
getmininginfo = bitcoinrpc_method_init(BITCOINRPC_METHOD_GETMININGINFO);
@@ -226,7 +226,7 @@ printf("Block Count: %d\n",blocks);
226226
Vamos recuperar o código de teste que está no [diretório src](../src/16_1_getmininginfo.c).
227227
```
228228
$ cc getmininginfo.c -lbitcoinrpc -ljansson -o getmininginfo
229-
$ ./getmininginfo
229+
$ ./getmininginfo
230230
Full Response: {
231231
"result": {
232232
"blocks": 1804406,

0 commit comments

Comments
 (0)