MCPcopy Create free account
hub / github.com/ElementsProject/lightning / check_channel_announcement

Function check_channel_announcement

gossipd/routing.c:655–718  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

653}
654
655static u8 *check_channel_announcement(const tal_t *ctx,
656 const struct node_id *node1_id, const struct node_id *node2_id,
657 const struct pubkey *bitcoin1_key, const struct pubkey *bitcoin2_key,
658 const secp256k1_ecdsa_signature *node1_sig,
659 const secp256k1_ecdsa_signature *node2_sig,
660 const secp256k1_ecdsa_signature *bitcoin1_sig,
661 const secp256k1_ecdsa_signature *bitcoin2_sig, const u8 *announcement)
662{
663 /* 2 byte msg type + 256 byte signatures */
664 int offset = 258;
665 struct sha256_double hash;
666 sha256_double(&hash, announcement + offset,
667 tal_count(announcement) - offset);
668
669 if (!check_signed_hash_nodeid(&hash, node1_sig, node1_id)) {
670 return towire_warningfmt(ctx, NULL,
671 "Bad node_signature_1 %s hash %s"
672 " on channel_announcement %s",
673 type_to_string(tmpctx,
674 secp256k1_ecdsa_signature,
675 node1_sig),
676 type_to_string(tmpctx,
677 struct sha256_double,
678 &hash),
679 tal_hex(tmpctx, announcement));
680 }
681 if (!check_signed_hash_nodeid(&hash, node2_sig, node2_id)) {
682 return towire_warningfmt(ctx, NULL,
683 "Bad node_signature_2 %s hash %s"
684 " on channel_announcement %s",
685 type_to_string(tmpctx,
686 secp256k1_ecdsa_signature,
687 node2_sig),
688 type_to_string(tmpctx,
689 struct sha256_double,
690 &hash),
691 tal_hex(tmpctx, announcement));
692 }
693 if (!check_signed_hash(&hash, bitcoin1_sig, bitcoin1_key)) {
694 return towire_warningfmt(ctx, NULL,
695 "Bad bitcoin_signature_1 %s hash %s"
696 " on channel_announcement %s",
697 type_to_string(tmpctx,
698 secp256k1_ecdsa_signature,
699 bitcoin1_sig),
700 type_to_string(tmpctx,
701 struct sha256_double,
702 &hash),
703 tal_hex(tmpctx, announcement));
704 }
705 if (!check_signed_hash(&hash, bitcoin2_sig, bitcoin2_key)) {
706 return towire_warningfmt(ctx, NULL,
707 "Bad bitcoin_signature_2 %s hash %s"
708 " on channel_announcement %s",
709 type_to_string(tmpctx,
710 secp256k1_ecdsa_signature,
711 bitcoin2_sig),
712 type_to_string(tmpctx,

Callers 2

mainFunction · 0.85

Calls 6

check_signed_hash_nodeidFunction · 0.85
tal_hexFunction · 0.85
check_signed_hashFunction · 0.85
sha256_doubleClass · 0.70
towire_warningfmtFunction · 0.50
type_to_stringClass · 0.50

Tested by 1

mainFunction · 0.68