void towire_shachain(u8 **pptr, const struct shachain *shachain) { size_t i; towire_u64(pptr, shachain->min_index); towire_u32(pptr, shachain->num_valid); for (i = 0; i < shachain->num_valid; i++) { towire_u64(pptr, shachain->known[i].index); towire_sha256(pptr, &shachain->known[i].hash); } }
/* FIXME: We could adapt tools/generate-wire.py to generate structures * and code like this. */ void towire_added_htlc(u8 **pptr, const struct added_htlc *added) { towire_u64(pptr, added->id); towire_amount_msat(pptr, added->amount); towire_sha256(pptr, &added->payment_hash); towire_u32(pptr, added->cltv_expiry); towire(pptr, added->onion_routing_packet, sizeof(added->onion_routing_packet)); }
void towire_utxo(u8 **pptr, const struct utxo *utxo) { /* Is this a unilateral close output and needs the * close_info? */ bool is_unilateral_close = utxo->close_info != NULL; towire_bitcoin_txid(pptr, &utxo->txid); towire_u32(pptr, utxo->outnum); towire_u64(pptr, utxo->amount); towire_u32(pptr, utxo->keyindex); towire_bool(pptr, utxo->is_p2sh); towire_bool(pptr, is_unilateral_close); if (is_unilateral_close) { towire_u64(pptr, utxo->close_info->channel_id); towire_pubkey(pptr, &utxo->close_info->peer_id); towire_pubkey(pptr, &utxo->close_info->commitment_point); } }
void towire_failed_htlc(u8 **pptr, const struct failed_htlc *failed) { /* Only one can be set. */ assert(failed->failcode || tal_count(failed->failreason)); assert(!failed->failcode || !tal_count(failed->failreason)); towire_u64(pptr, failed->id); towire_u16(pptr, failed->failcode); if (failed->failcode & UPDATE) { assert(!failed->failreason); towire_short_channel_id(pptr, failed->scid); } else { assert(!failed->scid); if (!failed->failcode) { assert(failed->failreason); towire_u16(pptr, tal_count(failed->failreason)); towire_u8_array(pptr, failed->failreason, tal_count(failed->failreason)); } } }
void towire_changed_htlc(u8 **pptr, const struct changed_htlc *changed) { towire_htlc_state(pptr, changed->newstate); towire_u64(pptr, changed->id); }
void towire_fulfilled_htlc(u8 **pptr, const struct fulfilled_htlc *fulfilled) { towire_u64(pptr, fulfilled->id); towire_preimage(pptr, &fulfilled->payment_preimage); }