jsonrpc: Let Base58 '2..' address work on both regtest and testnet.

This commit is contained in:
ZmnSCPxj
2018-02-24 14:59:39 +00:00
committed by Rusty Russell
parent 0e40c85691
commit bd07a91782
4 changed files with 66 additions and 26 deletions

View File

@@ -1,6 +1,7 @@
#ifndef LIGHTNING_LIGHTNINGD_JSONRPC_H
#define LIGHTNING_LIGHTNINGD_JSONRPC_H
#include "config.h"
#include <bitcoin/chainparams.h>
#include <ccan/autodata/autodata.h>
#include <ccan/list/list.h>
#include <common/json.h>
@@ -109,11 +110,22 @@ void json_add_address(struct json_result *response, const char *fieldname,
/* For initialization */
void setup_jsonrpc(struct lightningd *ld, const char *rpc_filename);
/* Returns NULL, or bip173 network name and fills in *scriptpubkey
* allocated off ctx
enum address_parse_result {
/* Not recognized as an onchain address */
ADDRESS_PARSE_UNRECOGNIZED,
/* Recognized as an onchain address, but targets wrong network */
ADDRESS_PARSE_WRONG_NETWORK,
/* Recognized and succeeds */
ADDRESS_PARSE_SUCCESS,
};
/* Return result of address parsing and fills in *scriptpubkey
* allocated off ctx if ADDRESS_PARSE_SUCCESS
*/
const char *json_tok_address_scriptpubkey(const tal_t *ctx, const char *buffer,
const jsmntok_t *tok, const u8 **scriptpubkey);
enum address_parse_result
json_tok_address_scriptpubkey(const tal_t *ctx,
const struct chainparams *chainparams,
const char *buffer,
const jsmntok_t *tok, const u8 **scriptpubkey);
AUTODATA_TYPE(json_command, struct json_command);
#endif /* LIGHTNING_LIGHTNINGD_JSONRPC_H */