mirror of
https://github.com/ZmnSCPxj/clboss.git
synced 2026-08-14 12:43:19 +02:00
CLN deprecated and then removed the implicit-bech32 default for the
newaddr command. Modern CLN (tested on v26.04.1) responds to
newaddr with only {"p2tr": "..."} and prints the warning
jsonrpc: Note: disallowing deprecated newaddr.addresstype.defaultbech32
This hit our existing code at line 38, which extracted res["bech32"]
unconditionally. Jsmn::Object::operator[] returns an Object with
null pimpl when the key is missing, and the std::string conversion
operator then throws TypeError. The exception propagates up the
Ev::Io chain and is swallowed silently, so Msg::ResponseNewaddr is
never raised.
Downstream symptom: SwapManager hangs forever in state 0
(NeedsOnchainAddress) after restart. Its getting_address flag was
set true when it raised the request, and only clears when the
queue empties via the response chain that never completes. Every
subsequent Timer10Minutes tick short-circuits on the still-true
flag and does nothing. Full investigation captured in
DEVSTATE/SWAPMANAGER-GETTING-ADDRESS-DEADLOCK-2026-05-14.org.
Fix matches the draft on origin/boltzapi-v2-taproot-reverse-swaps
commit c3dd1de: explicitly request newaddr p2tr and read res["p2tr"].
This is a breaking change for CLN v23.05 and older, but those are
two-plus years out of support already.
53 lines
1.3 KiB
C++
53 lines
1.3 KiB
C++
#include"Boss/Mod/NewaddrHandler.hpp"
|
|
#include"Boss/Mod/Rpc.hpp"
|
|
#include"Boss/Msg/Init.hpp"
|
|
#include"Boss/Msg/RequestNewaddr.hpp"
|
|
#include"Boss/Msg/ResponseNewaddr.hpp"
|
|
#include"Boss/concurrent.hpp"
|
|
#include"Ev/Io.hpp"
|
|
#include"Ev/foreach.hpp"
|
|
#include"Jsmn/Object.hpp"
|
|
#include"Json/Out.hpp"
|
|
#include"S/Bus.hpp"
|
|
|
|
namespace Boss { namespace Mod {
|
|
|
|
void NewaddrHandler::start() {
|
|
bus.subscribe<Msg::Init
|
|
>([this](Msg::Init const& init) {
|
|
rpc = &init.rpc;
|
|
auto f = [this](void* r) { return newaddr(r); };
|
|
return Boss::concurrent(
|
|
Ev::foreach(f, std::move(pending))
|
|
);
|
|
});
|
|
bus.subscribe<Msg::RequestNewaddr
|
|
>([this](Msg::RequestNewaddr const& r) {
|
|
auto requester = r.requester;
|
|
if (!rpc) {
|
|
pending.push_back(requester);
|
|
return Ev::lift();
|
|
}
|
|
return Boss::concurrent(newaddr(requester));
|
|
});
|
|
}
|
|
Ev::Io<void> NewaddrHandler::newaddr(void* requester) {
|
|
/** BREAKING CHANGE:
|
|
* Requesting addresstype=p2tr is NOT compatible with CLN v23.05
|
|
* and older, which did not accept the p2tr addresstype. */
|
|
auto params = Json::Out()
|
|
.start_object()
|
|
.field("addresstype", "p2tr")
|
|
.end_object()
|
|
;
|
|
return rpc->command( "newaddr"
|
|
, std::move(params)
|
|
).then([this, requester](Jsmn::Object res) {
|
|
auto addr = std::string(res["p2tr"]);
|
|
return bus.raise(Msg::ResponseNewaddr{
|
|
std::move(addr), requester
|
|
});
|
|
});
|
|
}
|
|
|
|
}}
|