Skip to content

Commit

Permalink
fix(wallet): don't fail reading Null change_desc column from sqlite
Browse files Browse the repository at this point in the history
If no change descriptor is persisted then `Row::get` fails with
`InvalidColumnType`. This is fixed by changing the FromSql type
to `Option<Impl<Descriptor<DescriptorPublicKey>>>`.
  • Loading branch information
ValuedMammal committed Aug 7, 2024
1 parent a723269 commit 914316f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions crates/wallet/src/wallet/changeset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,16 @@ impl ChangeSet {
.query_row([], |row| {
Ok((
row.get::<_, Impl<Descriptor<DescriptorPublicKey>>>("descriptor")?,
row.get::<_, Impl<Descriptor<DescriptorPublicKey>>>("change_descriptor")?,
row.get::<_, Option<Impl<Descriptor<DescriptorPublicKey>>>>(
"change_descriptor",
)?,
row.get::<_, Impl<bitcoin::Network>>("network")?,
))
})
.optional()?;
if let Some((Impl(desc), Impl(change_desc), Impl(network))) = row {
if let Some((Impl(desc), change_desc, Impl(network))) = row {
changeset.descriptor = Some(desc);
changeset.change_descriptor = Some(change_desc);
changeset.change_descriptor = change_desc.map(|imp| imp.0);
changeset.network = Some(network);
}

Expand Down

0 comments on commit 914316f

Please sign in to comment.