Skip to content

Commit 5f86706

Browse files
authored
Update 04_4_Interludio_Usando_Curl.md
1 parent 6045bc5 commit 5f86706

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

es/04_4_Interludio_Usando_Curl.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,17 @@ Así es como se ven algunos arreglos de parámetros:
105105
* `[6, 9999999]` — Un arreglo con parametros
106106
* `{}` - Un objeto vacío
107107
* `[''[ { "txid": "'$utxo_txid'", "vout": '$utxo_vout' } ]'', ''{ "'$recipient'": 0.298, "'$changeaddress'": 1.0}'']` — Un arreglo con una arreglo que contiene un objeto y un objeto vacío
108+
108109
## Obtener información
109110

110111
Ahora puede enviar su primer comando `curl` accediendo al RPC `getmininginfo`:
112+
111113
```
112114
$ curl --user StandUp:8eaf562eaf45c33c3328bc66008f2dd1 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getmininginfo", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:18332/
113-
{"result":{"blocks":1772428,"difficulty":10178811.40698772,"networkhashps":91963587385939.06,"pooledtx":61,"chain":"test","warnings":"Warning: unknown new rules activated (versionbit 28)"},"error":null,"id":"curltest"}```
114-
Note that we provided the method, `getmininginfo`, and the parameter, `[]`, but that everything else was the standard `curl` command line.
115+
{"result":{"blocks":1772428,"difficulty":10178811.40698772,"networkhashps":91963587385939.06,"pooledtx":61,"chain":"test","warnings":"Warning: unknown new rules activated (versionbit 28)"},"error":null,"id":"curltest"}
115116
```
117+
Tenga en cuenta que proporcionamos el método, `getmininginfo`, y el parámetro,`[]`, pero que todo lo demás era la línea de comando estándar` curl`.
118+
116119
> **AVISO:** Si obtiene un resultado como "Failed to connect to 127.0.0.1 port 8332: Connection refused", asegúrese de que una línea como `rpcallowip=127.0.0.1` está en su ~/.bitcoin/bitcoin.conf. Si las cosas siguen sin funcionar, asegúrese de que está permitiendo el acceso al puerto 18332 (o 8332) desde localhost. Nuestra configuración estándar del [2.0: Configuración de un Servidor Privado Virtual de Bitcoin-Core](02_0_Configurando_un_Bitcoin-Core_VPS.md) debería hacer todo esto.
117120
118121
El resultado es otro arreglo JSON, que desafortunadamente es feo de leer si está usando `curl` a mano. Afortunadamente, puede limpiarlo simplemente pasándolo por `jq`:
@@ -216,18 +219,19 @@ Esta es casi la misma salida que recibe cuando escribe `bitcoin-cli listunspent`
216219
### Crear una dirección
217220

218221
Después de saber dónde están sus fondos, el siguiente paso en la elaboración de una transacción es conseguir una dirección de cambio. A estas alturas, probablemente ya se haya hecho a la idea, y sabe que para los comandos RPC simples, todo lo que necesita hacer es ajustar el `method` es el comando `curl`:
222+
219223
```
220-
$ curl --user StandUp:8eaf562eaf45c33c3328bc66008f2dd1 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getrawchangeaddress", "params": ["legacy"] }' -H 'content-type: text/plain;' http://127.0.0.1:18332/ | jq -r '.'
224+
$ curl --user StandUp:8eaf562eaf45c33c3328bc66008f2dd1 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getrawchangeaddress", "params": ["", "legacy"] }' -H 'content-type: text/plain;' http://127.0.0.1:18332/ | jq -r '.'
221225
{
222226
"result": "mrSqN37TPs89GcidSZTvXmMzjxoJZ6RKoz",
223227
"error": null,
224228
"id": "curltest"
225229
}
226-
227230
```
231+
228232
En este punto, podemos incluso volver a nuestra práctica estándar de guardar los resultados en variables con la ayuda adicional de `jq`:
229233
```
230-
$ changeaddress=$(curl --user StandUp:8eaf562eaf45c33c3328bc66008f2dd1 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getrawchangeaddress", "params": ["legacy"] }' -H 'content-type: text/plain;' http://127.0.0.1:18332/ | jq -r '.result')
234+
$ changeaddress=$(curl --user StandUp:8eaf562eaf45c33c3328bc66008f2dd1 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getrawchangeaddress", "params": ["", "legacy"] }' -H 'content-type: text/plain;' http://127.0.0.1:18332/ | jq -r '.result')
231235
$ echo $changeaddress
232236
mqdfnjgWr2r3sCCeuTDfe8fJ1CnycF2e6R
233237
```

0 commit comments

Comments
 (0)