mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-23 15:00:34 +01:00
df: add notification for receiving peer's funding tx sigs
This will allow us to build complex, multi-peer transactions, with easeTM! Changelog-Added: EXPERIMENTAL, Plugins: `openchannel_peer_sigs` notification, which contains a peer's signatures for the funding transaction (`opt_dual_fund`)
This commit is contained in:
parent
f9aab50ee8
commit
daa55d1221
4 changed files with 55 additions and 0 deletions
|
@ -653,6 +653,22 @@ at the time lightningd broadcasts the notification.
|
||||||
|
|
||||||
`coin_type` is the BIP173 name for the coin which moved.
|
`coin_type` is the BIP173 name for the coin which moved.
|
||||||
|
|
||||||
|
### `openchannel_peer_sigs`
|
||||||
|
|
||||||
|
When opening a channel with a peer using the collaborative transaction protocol
|
||||||
|
(`opt_dual_fund`), this notification is fired when the peer sends us their funding
|
||||||
|
transaction signatures, `tx_signatures`. We update the in-progress PSBT and return it
|
||||||
|
here, with the peer's signatures attached.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"openchannel_peer_sigs": {
|
||||||
|
"channel_id": "<hex of a channel id (note, v2 format)>",
|
||||||
|
"signed_psbt": "<Base64 serialized PSBT of funding transaction,
|
||||||
|
with peer's sigs>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Hooks
|
## Hooks
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <lightningd/jsonrpc.h>
|
#include <lightningd/jsonrpc.h>
|
||||||
#include <lightningd/lightningd.h>
|
#include <lightningd/lightningd.h>
|
||||||
#include <lightningd/log.h>
|
#include <lightningd/log.h>
|
||||||
|
#include <lightningd/notification.h>
|
||||||
#include <lightningd/onion_message.h>
|
#include <lightningd/onion_message.h>
|
||||||
#include <lightningd/peer_control.h>
|
#include <lightningd/peer_control.h>
|
||||||
#include <lightningd/subd.h>
|
#include <lightningd/subd.h>
|
||||||
|
@ -449,6 +450,10 @@ static void peer_tx_sigs_msg(struct channel *channel, const u8 *msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
wallet_channel_save(ld->wallet, channel);
|
wallet_channel_save(ld->wallet, channel);
|
||||||
|
|
||||||
|
/* Send notification with peer's signed PSBT */
|
||||||
|
notify_openchannel_peer_sigs(ld, &channel->cid,
|
||||||
|
channel->psbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void forget_channel(struct channel *channel, const char *why)
|
void forget_channel(struct channel *channel, const char *why)
|
||||||
|
|
|
@ -467,3 +467,31 @@ void notify_coin_mvt(struct lightningd *ld,
|
||||||
jsonrpc_notification_end(n);
|
jsonrpc_notification_end(n);
|
||||||
plugins_notify(ld->plugins, take(n));
|
plugins_notify(ld->plugins, take(n));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void openchannel_peer_sigs_serialize(struct json_stream *stream,
|
||||||
|
const struct channel_id *cid,
|
||||||
|
const struct wally_psbt *psbt)
|
||||||
|
{
|
||||||
|
json_object_start(stream, "openchannel_peer_sigs");
|
||||||
|
json_add_channel_id(stream, "channel_id", cid);
|
||||||
|
json_add_psbt(stream, "signed_psbt", psbt);
|
||||||
|
json_object_end(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
REGISTER_NOTIFICATION(openchannel_peer_sigs,
|
||||||
|
openchannel_peer_sigs_serialize);
|
||||||
|
|
||||||
|
void notify_openchannel_peer_sigs(struct lightningd *ld,
|
||||||
|
const struct channel_id *cid,
|
||||||
|
const struct wally_psbt *psbt)
|
||||||
|
{
|
||||||
|
void (*serialize)(struct json_stream *,
|
||||||
|
const struct channel_id *cid,
|
||||||
|
const struct wally_psbt *) = openchannel_peer_sigs_notification_gen.serialize;
|
||||||
|
|
||||||
|
struct jsonrpc_notification *n =
|
||||||
|
jsonrpc_notification_start(NULL, "openchannel_peer_sigs");
|
||||||
|
serialize(n->stream, cid, psbt);
|
||||||
|
jsonrpc_notification_end(n);
|
||||||
|
plugins_notify(ld->plugins, take(n));
|
||||||
|
}
|
||||||
|
|
|
@ -19,9 +19,11 @@
|
||||||
#include <lightningd/pay.h>
|
#include <lightningd/pay.h>
|
||||||
#include <lightningd/plugin.h>
|
#include <lightningd/plugin.h>
|
||||||
#include <wallet/wallet.h>
|
#include <wallet/wallet.h>
|
||||||
|
#include <wally_psbt.h>
|
||||||
#include <wire/onion_wire.h>
|
#include <wire/onion_wire.h>
|
||||||
|
|
||||||
struct onionreply;
|
struct onionreply;
|
||||||
|
struct wally_psbt;
|
||||||
|
|
||||||
bool notifications_have_topic(const char *topic);
|
bool notifications_have_topic(const char *topic);
|
||||||
|
|
||||||
|
@ -86,4 +88,8 @@ void notify_sendpay_failure(struct lightningd *ld,
|
||||||
|
|
||||||
void notify_coin_mvt(struct lightningd *ld,
|
void notify_coin_mvt(struct lightningd *ld,
|
||||||
const struct coin_mvt *mvt);
|
const struct coin_mvt *mvt);
|
||||||
|
|
||||||
|
void notify_openchannel_peer_sigs(struct lightningd *ld,
|
||||||
|
const struct channel_id *cid,
|
||||||
|
const struct wally_psbt *psbt);
|
||||||
#endif /* LIGHTNING_LIGHTNINGD_NOTIFICATION_H */
|
#endif /* LIGHTNING_LIGHTNINGD_NOTIFICATION_H */
|
||||||
|
|
Loading…
Add table
Reference in a new issue