@ -135,7 +135,7 @@ again:
/* BOLT #2:
/* BOLT #2:
*
*
* On reconnection if the node has sent a previous ` closing_signed ` it
* On reconnection if the node has sent a previous ` closing_signed ` it
* MUST then retransmit the last ` closing_signed `
* MUST send another ` closing_signed `
*/
*/
/* Since we always transmit closing_signed immediately, if
/* Since we always transmit closing_signed immediately, if
@ -218,10 +218,12 @@ int main(int argc, char *argv[])
* Nodes SHOULD send a ` closing_signed ` message after ` shutdown ` has
* Nodes SHOULD send a ` closing_signed ` message after ` shutdown ` has
* been received and no HTLCs remain in either commitment transaction .
* been received and no HTLCs remain in either commitment transaction .
*/
*/
/* BOLT #2:
/* BOLT #2:
*
*
* On reconnection , . . . if the node has sent a previous
* On reconnection , . . . if the node has sent a previous
* ` closing_signed ` it MUST then retransmit the last ` closing_signed ` .
* ` closing_signed ` it MUST send another ` closing_signed ` , otherwise
* if the node has sent a previous ` shutdown ` it MUST retransmit it .
*/
*/
for ( ; ; ) {
for ( ; ; ) {
const tal_t * tmpctx = tal_tmpctx ( ctx ) ;
const tal_t * tmpctx = tal_tmpctx ( ctx ) ;
@ -231,11 +233,8 @@ int main(int argc, char *argv[])
/* BOLT #2:
/* BOLT #2:
*
*
* The sender MUST set ` signature ` to the Bitcoin signature of
* The sender MUST set ` signature ` to the Bitcoin signature of
* the close transaction with the node responsible for paying
* the close transaction as specified in [ BOLT
* the bitcoin fee paying ` fee_satoshis ` , then removing any
* # 3 ] ( 03 - transactions . md # closing - transaction ) .
* output which is below its own ` dust_limit_satoshis ` . The
* sender MAY then also eliminate its own output from the
* mutual close transaction .
*/
*/
tx = close_tx ( tmpctx , scriptpubkey ,
tx = close_tx ( tmpctx , scriptpubkey ,
& funding_txid ,
& funding_txid ,
@ -243,10 +242,12 @@ int main(int argc, char *argv[])
funding_satoshi ,
funding_satoshi ,
satoshi_out , funder , sent_fee , our_dust_limit ) ;
satoshi_out , funder , sent_fee , our_dust_limit ) ;
/* BOLT #2 :
/* BOLT #3 :
*
*
* The sender MAY then also eliminate its own output from the
* # # Closing Transaction
* mutual close transaction .
* . . .
* Each node offering a signature . . . MAY also eliminate its
* own output .
*/
*/
/* (We don't do this). */
/* (We don't do this). */
sign_tx_input ( tx , 0 , NULL , funding_wscript ,
sign_tx_input ( tx , 0 , NULL , funding_wscript ,
@ -310,11 +311,10 @@ int main(int argc, char *argv[])
/* BOLT #2:
/* BOLT #2:
*
*
* The receiver MUST check ` signature ` is valid for either the
* The receiver MUST check ` signature ` is valid for either
* close transaction with the given ` fee_satoshis ` as detailed
* variant of close transaction specified in [ BOLT
* above and its own ` dust_limit_satoshis ` OR that same
* # 3 ] ( 03 - transactions . md # closing - transaction ) , and MUST fail
* transaction with the sender ' s output eliminated , and MUST
* the connection if it is not .
* fail the connection if it is not .
*/
*/
tx = close_tx ( tmpctx , scriptpubkey ,
tx = close_tx ( tmpctx , scriptpubkey ,
& funding_txid ,
& funding_txid ,
@ -334,6 +334,14 @@ int main(int argc, char *argv[])
trimming_satoshi_out [ REMOTE ] = 0 ;
trimming_satoshi_out [ REMOTE ] = 0 ;
trimming_satoshi_out [ LOCAL ] = satoshi_out [ LOCAL ] ;
trimming_satoshi_out [ LOCAL ] = satoshi_out [ LOCAL ] ;
/* BOLT #3:
*
* Each node offering a signature MUST subtract the
* fee given by ` fee_satoshis ` from the output to the
* funder ; it MUST then remove any output below its
* own ` dust_limit_satoshis ` , and MAY also eliminate
* its own output .
*/
trimmed = close_tx ( tmpctx , scriptpubkey ,
trimmed = close_tx ( tmpctx , scriptpubkey ,
& funding_txid ,
& funding_txid ,
funding_txout ,
funding_txout ,
@ -392,9 +400,9 @@ int main(int argc, char *argv[])
/* BOLT #2:
/* BOLT #2:
*
*
* Once a node has sent or received a ` closing_signed ` with
* If ` fee_satoshis ` is equal to its previously sent
* matching ` fee_satoshis ` it SHOULD close the connection and
* ` fee_satoshis ` , the receiver SHOULD sign and broadcast the
* SHOULD sign and broadcast the final closing transa ction.
* final closing transaction and MAY close the conne ction.
*/
*/
if ( received_fee = = sent_fee )
if ( received_fee = = sent_fee )
break ;
break ;
@ -433,7 +441,7 @@ int main(int argc, char *argv[])
/* BOLT #2:
/* BOLT #2:
*
*
* . . . otherwise it SHOULD propose a value strictly between the
* . . . otherwise it MUST propose a value strictly between the
* received ` fee_satoshis ` and its previously - sent
* received ` fee_satoshis ` and its previously - sent
* ` fee_satoshis ` .
* ` fee_satoshis ` .
*/
*/