(
&self,
scid: &ShortChannelId,
peer_id: &PublicKey,
opening_fee_params: &OpeningFeeParams,
expected_payment_size: &Option<Msat>,
)
| 113 | #[async_trait] |
| 114 | impl DatastoreProvider for ClnApiRpc { |
| 115 | async fn store_buy_request( |
| 116 | &self, |
| 117 | scid: &ShortChannelId, |
| 118 | peer_id: &PublicKey, |
| 119 | opening_fee_params: &OpeningFeeParams, |
| 120 | expected_payment_size: &Option<Msat>, |
| 121 | ) -> AnyResult<bool> { |
| 122 | let mut rpc = self.create_rpc().await?; |
| 123 | #[derive(Serialize)] |
| 124 | struct BorrowedDatastoreEntry<'a> { |
| 125 | peer_id: &'a PublicKey, |
| 126 | opening_fee_params: &'a OpeningFeeParams, |
| 127 | #[serde(borrow)] |
| 128 | expected_payment_size: &'a Option<Msat>, |
| 129 | } |
| 130 | |
| 131 | let ds = BorrowedDatastoreEntry { |
| 132 | peer_id, |
| 133 | opening_fee_params, |
| 134 | expected_payment_size, |
| 135 | }; |
| 136 | let json_str = serde_json::to_string(&ds)?; |
| 137 | |
| 138 | let ds = DatastoreRequest { |
| 139 | generation: None, |
| 140 | hex: None, |
| 141 | mode: Some(DatastoreMode::MUST_CREATE), |
| 142 | string: Some(json_str), |
| 143 | key: vec![ |
| 144 | DS_MAIN_KEY.to_string(), |
| 145 | DS_SUB_KEY.to_string(), |
| 146 | scid.to_string(), |
| 147 | ], |
| 148 | }; |
| 149 | |
| 150 | let _ = rpc |
| 151 | .call_typed(&ds) |
| 152 | .await |
| 153 | .map_err(anyhow::Error::new) |
| 154 | .with_context(|| "calling datastore")?; |
| 155 | |
| 156 | Ok(true) |
| 157 | } |
| 158 | |
| 159 | async fn get_buy_request(&self, scid: &ShortChannelId) -> AnyResult<DatastoreEntry> { |
| 160 | let mut rpc = self.create_rpc().await?; |
no test coverage detected