mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
json: Move param_bitcoin_address from wallet/walletrpc.c to lightningd/json.c
It's a useful helper, and it will be used to prase address in `close` command.
This commit is contained in:
@@ -572,3 +572,29 @@ json_to_address_scriptpubkey(const tal_t *ctx,
|
||||
|
||||
return ADDRESS_PARSE_UNRECOGNIZED;
|
||||
}
|
||||
|
||||
struct command_result *param_bitcoin_address(struct command *cmd,
|
||||
const char *name,
|
||||
const char *buffer,
|
||||
const jsmntok_t *tok,
|
||||
const u8 **scriptpubkey)
|
||||
{
|
||||
/* Parse address. */
|
||||
switch (json_to_address_scriptpubkey(cmd,
|
||||
get_chainparams(cmd->ld),
|
||||
buffer, tok,
|
||||
scriptpubkey)) {
|
||||
case ADDRESS_PARSE_UNRECOGNIZED:
|
||||
return command_fail(cmd, LIGHTNINGD,
|
||||
"Could not parse destination address, "
|
||||
"%s should be a valid address",
|
||||
name ? name : "address field");
|
||||
case ADDRESS_PARSE_WRONG_NETWORK:
|
||||
return command_fail(cmd, LIGHTNINGD,
|
||||
"Destination address is not on network %s",
|
||||
get_chainparams(cmd->ld)->network_name);
|
||||
case ADDRESS_PARSE_SUCCESS:
|
||||
return NULL;
|
||||
}
|
||||
abort();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user