mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 23:54:22 +01:00
daemon: struct rval to represent r values.
We've been stuffing these into sha256s, but they're actually nonces. Create a new structure for that for clarity. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -205,7 +205,7 @@ void queue_pkt_htlc_add(struct peer *peer, const struct channel_htlc *htlc)
|
||||
queue_pkt(peer, PKT__PKT_UPDATE_ADD_HTLC, u);
|
||||
}
|
||||
|
||||
void queue_pkt_htlc_fulfill(struct peer *peer, u64 id, const struct sha256 *r)
|
||||
void queue_pkt_htlc_fulfill(struct peer *peer, u64 id, const struct rval *r)
|
||||
{
|
||||
UpdateFulfillHtlc *f = tal(peer, UpdateFulfillHtlc);
|
||||
size_t n;
|
||||
@@ -213,7 +213,7 @@ void queue_pkt_htlc_fulfill(struct peer *peer, u64 id, const struct sha256 *r)
|
||||
|
||||
update_fulfill_htlc__init(f);
|
||||
f->id = id;
|
||||
f->r = sha256_to_proto(f, r);
|
||||
f->r = rval_to_proto(f, r);
|
||||
|
||||
/* BOLT #2:
|
||||
*
|
||||
@@ -724,7 +724,8 @@ Pkt *accept_pkt_htlc_fulfill(struct peer *peer, const Pkt *pkt)
|
||||
{
|
||||
const UpdateFulfillHtlc *f = pkt->update_fulfill_htlc;
|
||||
size_t n_local;
|
||||
struct sha256 r, rhash;
|
||||
struct sha256 rhash;
|
||||
struct rval r;
|
||||
Pkt *err;
|
||||
union htlc_staging stage;
|
||||
|
||||
@@ -733,7 +734,7 @@ Pkt *accept_pkt_htlc_fulfill(struct peer *peer, const Pkt *pkt)
|
||||
return err;
|
||||
|
||||
/* Now, it must solve the HTLC rhash puzzle. */
|
||||
proto_to_sha256(f->r, &r);
|
||||
proto_to_rval(f->r, &r);
|
||||
sha256(&rhash, &r, sizeof(r));
|
||||
|
||||
if (!structeq(&rhash, &peer->local.staging_cstate->side[OURS].htlcs[n_local].rhash))
|
||||
|
||||
@@ -546,7 +546,7 @@ static bool command_htlc_fail(struct peer *peer, u64 id)
|
||||
|
||||
static bool command_htlc_fulfill(struct peer *peer,
|
||||
u64 id,
|
||||
const struct sha256 *r)
|
||||
const struct rval *r)
|
||||
{
|
||||
if (!state_can_remove_htlc(peer->state))
|
||||
return false;
|
||||
@@ -1310,7 +1310,8 @@ static void our_htlc_spent(struct peer *peer,
|
||||
ptrint_t *pi)
|
||||
{
|
||||
struct channel_htlc *h;
|
||||
struct sha256 preimage, sha;
|
||||
struct sha256 sha;
|
||||
struct rval preimage;
|
||||
size_t i = ptr2int(pi);
|
||||
|
||||
/* It should be spending the HTLC we expect. */
|
||||
@@ -1468,7 +1469,7 @@ static void resolve_our_htlcs(struct peer *peer,
|
||||
* preimage. Otherwise, the other node could spend it once it as *timed out*
|
||||
* as above.
|
||||
*/
|
||||
bool resolve_one_htlc(struct peer *peer, u64 id, const struct sha256 *preimage)
|
||||
bool resolve_one_htlc(struct peer *peer, u64 id, const struct rval *preimage)
|
||||
{
|
||||
FIXME_STUB(peer);
|
||||
}
|
||||
@@ -2497,7 +2498,7 @@ static void json_fulfillhtlc(struct command *cmd,
|
||||
{
|
||||
struct peer *peer;
|
||||
jsmntok_t *peeridtok, *rtok;
|
||||
struct sha256 r;
|
||||
struct rval r;
|
||||
struct sha256 rhash;
|
||||
size_t i;
|
||||
u64 id;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "funding.h"
|
||||
#include "lightning.pb-c.h"
|
||||
#include "netaddr.h"
|
||||
#include "protobuf_convert.h"
|
||||
#include "state.h"
|
||||
#include <ccan/crypto/sha256/sha256.h>
|
||||
#include <ccan/crypto/shachain/shachain.h>
|
||||
@@ -29,7 +30,7 @@ struct htlc_add {
|
||||
struct htlc_fulfill {
|
||||
enum htlc_stage_type fulfill;
|
||||
u64 id;
|
||||
struct sha256 r;
|
||||
struct rval r;
|
||||
};
|
||||
|
||||
struct htlc_fail {
|
||||
@@ -241,5 +242,5 @@ struct bitcoin_tx *peer_create_close_tx(struct peer *peer, u64 fee);
|
||||
uint64_t commit_tx_fee(const struct bitcoin_tx *commit,
|
||||
uint64_t anchor_satoshis);
|
||||
|
||||
bool resolve_one_htlc(struct peer *peer, u64 id, const struct sha256 *preimage);
|
||||
bool resolve_one_htlc(struct peer *peer, u64 id, const struct rval *preimage);
|
||||
#endif /* LIGHTNING_DAEMON_PEER_H */
|
||||
|
||||
Reference in New Issue
Block a user