@ -141,10 +141,12 @@ void queue_pkt_anchor(struct peer *peer)
}
/* Sign their commit sig */
peer - > them . commit - > sig . stype = SIGHASH_ALL ;
peer - > them . commit - > sig = tal ( peer - > them . commit ,
struct bitcoin_signature ) ;
peer - > them . commit - > sig - > stype = SIGHASH_ALL ;
peer_sign_theircommit ( peer , peer - > them . commit - > tx ,
& peer - > them . commit - > sig . sig ) ;
a - > commit_sig = signature_to_proto ( a , & peer - > them . commit - > sig . sig ) ;
& peer - > them . commit - > sig - > sig ) ;
a - > commit_sig = signature_to_proto ( a , & peer - > them . commit - > sig - > sig ) ;
queue_pkt ( peer , PKT__PKT_OPEN_ANCHOR , a ) ;
}
@ -158,10 +160,12 @@ void queue_pkt_open_commit_sig(struct peer *peer)
dump_tx ( " Creating sig for: " , peer - > them . commit - > tx ) ;
dump_key ( " Using key: " , & peer - > us . commitkey ) ;
peer - > them . commit - > sig . stype = SIGHASH_ALL ;
peer - > them . commit - > sig = tal ( peer - > them . commit ,
struct bitcoin_signature ) ;
peer - > them . commit - > sig - > stype = SIGHASH_ALL ;
peer_sign_theircommit ( peer , peer - > them . commit - > tx ,
& peer - > them . commit - > sig . sig ) ;
s - > sig = signature_to_proto ( s , & peer - > them . commit - > sig . sig ) ;
& peer - > them . commit - > sig - > sig ) ;
s - > sig = signature_to_proto ( s , & peer - > them . commit - > sig - > sig ) ;
queue_pkt ( peer , PKT__PKT_OPEN_COMMIT_SIG , s ) ;
}
@ -314,8 +318,9 @@ void queue_pkt_commit(struct peer *peer)
*/
assert ( ci - > prev - > cstate - > changes ! = ci - > cstate - > changes ) ;
ci - > sig . stype = SIGHASH_ALL ;
peer_sign_theircommit ( peer , ci - > tx , & ci - > sig . sig ) ;
ci - > sig = tal ( ci , struct bitcoin_signature ) ;
ci - > sig - > stype = SIGHASH_ALL ;
peer_sign_theircommit ( peer , ci - > tx , & ci - > sig - > sig ) ;
/* Switch to the new commitment. */
peer - > them . commit = ci ;
@ -324,7 +329,7 @@ void queue_pkt_commit(struct peer *peer)
/* Now send message */
update_commit__init ( u ) ;
u - > sig = signature_to_proto ( u , & ci - > sig . sig ) ;
u - > sig = signature_to_proto ( u , & ci - > sig - > sig ) ;
u - > ack = peer_outgoing_ack ( peer ) ;
queue_pkt ( peer , PKT__PKT_UPDATE_COMMIT , u ) ;
@ -344,7 +349,7 @@ void queue_pkt_revocation(struct peer *peer)
assert ( ! peer - > us . commit - > prev - > revocation_preimage ) ;
/* We have their signature on the current one, right? */
memcheck ( & pe er- > us . commit - > sig , sizeof ( peer - > us . commit - > sig ) ) ;
ass ert ( peer - > us . commit - > sig ) ;
peer - > us . commit - > prev - > revocation_preimage
= tal ( peer - > us . commit - > prev , struct sha256 ) ;
@ -477,8 +482,10 @@ static Pkt *check_and_save_commit_sig(struct peer *peer,
struct commit_info * ci ,
const Signature * pb )
{
ci - > sig . stype = SIGHASH_ALL ;
if ( ! proto_to_signature ( pb , & ci - > sig . sig ) )
assert ( ! ci - > sig ) ;
ci - > sig = tal ( ci , struct bitcoin_signature ) ;
ci - > sig - > stype = SIGHASH_ALL ;
if ( ! proto_to_signature ( pb , & ci - > sig - > sig ) )
return pkt_err ( peer , " Malformed signature " ) ;
/* Their sig should sign our commit tx. */
@ -487,7 +494,7 @@ static Pkt *check_and_save_commit_sig(struct peer *peer,
NULL , 0 ,
peer - > anchor . witnessscript ,
& peer - > them . commitkey ,
& ci - > sig ) )
ci - > sig ) )
return pkt_err ( peer , " Bad signature " ) ;
return NULL ;