mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 23:54:22 +01:00
bitcoin/preimage: struct preimage.
We had a hack for 'struct rval' in protobuf_convert.h; make an explicit header and put it in bitcoin/preimage.h. It's not really bitcoin-specific, but it's better than having bitcoin/script depend on an external header. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include "bitcoin/preimage.h"
|
||||
#include "bitcoin/script.h"
|
||||
#include "bitcoin/tx.h"
|
||||
#include "chaintopology.h"
|
||||
@@ -151,7 +152,7 @@ void queue_pkt_htlc_fulfill(struct peer *peer, struct htlc *htlc)
|
||||
|
||||
update_fulfill_htlc__init(f);
|
||||
f->id = htlc->id;
|
||||
f->r = rval_to_proto(f, htlc->r);
|
||||
f->r = preimage_to_proto(f, htlc->r);
|
||||
|
||||
queue_pkt(peer, PKT__PKT_UPDATE_FULFILL_HTLC, f);
|
||||
}
|
||||
@@ -476,7 +477,7 @@ Pkt *accept_pkt_htlc_fail(struct peer *peer, const Pkt *pkt, struct htlc **h,
|
||||
}
|
||||
|
||||
Pkt *accept_pkt_htlc_fulfill(struct peer *peer, const Pkt *pkt, struct htlc **h,
|
||||
struct rval *r)
|
||||
struct preimage *r)
|
||||
{
|
||||
const UpdateFulfillHtlc *f = pkt->update_fulfill_htlc;
|
||||
struct sha256 rhash;
|
||||
@@ -487,7 +488,7 @@ Pkt *accept_pkt_htlc_fulfill(struct peer *peer, const Pkt *pkt, struct htlc **h,
|
||||
return err;
|
||||
|
||||
/* Now, it must solve the HTLC rhash puzzle. */
|
||||
proto_to_rval(f->r, r);
|
||||
proto_to_preimage(f->r, r);
|
||||
sha256(&rhash, r, sizeof(*r));
|
||||
|
||||
if (!structeq(&rhash, &(*h)->rhash))
|
||||
|
||||
Reference in New Issue
Block a user