| 1107 | } |
| 1108 | |
| 1109 | static struct channel_inflight * |
| 1110 | wallet_stmt2inflight(struct wallet *w, struct db_stmt *stmt, |
| 1111 | struct channel *chan) |
| 1112 | { |
| 1113 | struct amount_sat funding_sat, our_funding_sat; |
| 1114 | struct amount_msat lease_fee; |
| 1115 | struct bitcoin_outpoint funding; |
| 1116 | struct bitcoin_signature last_sig; |
| 1117 | struct bitcoin_tx *last_tx; |
| 1118 | struct channel_inflight *inflight; |
| 1119 | |
| 1120 | secp256k1_ecdsa_signature *lease_commit_sig; |
| 1121 | u32 lease_blockheight_start; |
| 1122 | u64 lease_chan_max_msat; |
| 1123 | u16 lease_chan_max_ppt; |
| 1124 | |
| 1125 | db_col_txid(stmt, "funding_tx_id", &funding.txid); |
| 1126 | funding.n = db_col_int(stmt, "funding_tx_outnum"), |
| 1127 | db_col_amount_sat(stmt, "funding_satoshi", &funding_sat); |
| 1128 | db_col_amount_sat(stmt, "our_funding_satoshi", &our_funding_sat); |
| 1129 | if (!db_col_signature(stmt, "last_sig", &last_sig.s)) |
| 1130 | return NULL; |
| 1131 | |
| 1132 | last_sig.sighash_type = SIGHASH_ALL; |
| 1133 | |
| 1134 | if (!db_col_is_null(stmt, "lease_commit_sig")) { |
| 1135 | lease_commit_sig = tal(tmpctx, secp256k1_ecdsa_signature); |
| 1136 | db_col_signature(stmt, "lease_commit_sig", lease_commit_sig); |
| 1137 | lease_chan_max_msat = db_col_u64(stmt, "lease_chan_max_msat"); |
| 1138 | lease_chan_max_ppt = db_col_int(stmt, "lease_chan_max_ppt"); |
| 1139 | lease_blockheight_start = db_col_int(stmt, "lease_blockheight_start"); |
| 1140 | db_col_amount_msat(stmt, "lease_fee", &lease_fee); |
| 1141 | } else { |
| 1142 | lease_commit_sig = NULL; |
| 1143 | lease_chan_max_msat = 0; |
| 1144 | lease_chan_max_ppt = 0; |
| 1145 | lease_blockheight_start = 0; |
| 1146 | lease_fee = AMOUNT_MSAT(0); |
| 1147 | |
| 1148 | db_col_ignore(stmt, "lease_chan_max_msat"); |
| 1149 | db_col_ignore(stmt, "lease_chan_max_ppt"); |
| 1150 | db_col_ignore(stmt, "lease_blockheight_start"); |
| 1151 | db_col_ignore(stmt, "lease_fee"); |
| 1152 | } |
| 1153 | |
| 1154 | /* last_tx is null for stub channels used for recovering funds through |
| 1155 | * Static channel backups. */ |
| 1156 | if (!db_col_is_null(stmt, "last_tx")) |
| 1157 | last_tx = db_col_psbt_to_tx(tmpctx, stmt, "last_tx"); |
| 1158 | else |
| 1159 | last_tx = NULL; |
| 1160 | |
| 1161 | inflight = new_inflight(chan, &funding, |
| 1162 | db_col_int(stmt, "funding_feerate"), |
| 1163 | funding_sat, |
| 1164 | our_funding_sat, |
| 1165 | db_col_psbt(tmpctx, stmt, "funding_psbt"), |
| 1166 | last_tx, |
no test coverage detected