mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02:00
Merge 411ba32af2 into merged_master (Bitcoin PR bitcoin/bitcoin#24748)
This commit is contained in:
commit
9aa49bb8d7
15 changed files with 753 additions and 67 deletions
|
|
@ -371,6 +371,7 @@ static RPCHelpMan addconnection()
|
|||
{
|
||||
{"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The IP address and port to attempt connecting to."},
|
||||
{"connection_type", RPCArg::Type::STR, RPCArg::Optional::NO, "Type of connection to open (\"outbound-full-relay\", \"block-relay-only\", \"addr-fetch\" or \"feeler\")."},
|
||||
{"v2transport", RPCArg::Type::BOOL, RPCArg::Default{false}, "Attempt to connect using BIP324 v2 transport protocol"},
|
||||
},
|
||||
RPCResult{
|
||||
RPCResult::Type::OBJ, "", "",
|
||||
|
|
@ -379,8 +380,8 @@ static RPCHelpMan addconnection()
|
|||
{ RPCResult::Type::STR, "connection_type", "Type of connection opened." },
|
||||
}},
|
||||
RPCExamples{
|
||||
HelpExampleCli("addconnection", "\"192.168.0.6:8333\" \"outbound-full-relay\"")
|
||||
+ HelpExampleRpc("addconnection", "\"192.168.0.6:8333\" \"outbound-full-relay\"")
|
||||
HelpExampleCli("addconnection", "\"192.168.0.6:8333\" \"outbound-full-relay\" true")
|
||||
+ HelpExampleRpc("addconnection", "\"192.168.0.6:8333\" \"outbound-full-relay\" true")
|
||||
},
|
||||
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
|
||||
{
|
||||
|
|
@ -402,11 +403,16 @@ static RPCHelpMan addconnection()
|
|||
} else {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, self.ToString());
|
||||
}
|
||||
bool use_v2transport = !request.params[2].isNull() && request.params[2].get_bool();
|
||||
|
||||
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||
CConnman& connman = EnsureConnman(node);
|
||||
|
||||
const bool success = connman.AddConnection(address, conn_type);
|
||||
if (use_v2transport && !(connman.GetLocalServices() & NODE_P2P_V2)) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Error: Adding v2transport connections requires -v2transport init flag to be set.");
|
||||
}
|
||||
|
||||
const bool success = connman.AddConnection(address, conn_type, use_v2transport);
|
||||
if (!success) {
|
||||
throw JSONRPCError(RPC_CLIENT_NODE_CAPACITY_REACHED, "Error: Already at capacity for specified connection type.");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue