@@ -159,7 +159,7 @@ impl Store {
159159 dbg ! ( & row) ;
160160
161161 if let Some ( row) = row {
162- Self :: changeset_from_row ( & mut tx, & mut changeset, row) . await ?;
162+ Self :: changeset_from_row ( & mut tx, & mut changeset, row, & self . wallet_name ) . await ?;
163163 }
164164
165165 Ok ( changeset)
@@ -170,6 +170,7 @@ impl Store {
170170 tx : & mut Transaction < ' _ , Postgres > ,
171171 changeset : & mut ChangeSet ,
172172 row : PgRow ,
173+ wallet_name : & str ,
173174 ) -> Result < ( ) , BdkSqlxError > {
174175 info ! ( "changeset from row" ) ;
175176
@@ -199,8 +200,8 @@ impl Store {
199200 }
200201 }
201202
202- changeset. tx_graph = tx_graph_changeset_from_postgres ( tx) . await ?;
203- changeset. local_chain = local_chain_changeset_from_postgres ( tx) . await ?;
203+ changeset. tx_graph = tx_graph_changeset_from_postgres ( tx, wallet_name ) . await ?;
204+ changeset. local_chain = local_chain_changeset_from_postgres ( tx, wallet_name ) . await ?;
204205 Ok ( ( ) )
205206 }
206207
@@ -317,12 +318,14 @@ async fn update_last_revealed(
317318#[ tracing:: instrument]
318319pub async fn tx_graph_changeset_from_postgres (
319320 db_tx : & mut Transaction < ' _ , Postgres > ,
321+ wallet_name : & str ,
320322) -> Result < tx_graph:: ChangeSet < ConfirmationBlockTime > , BdkSqlxError > {
321323 info ! ( "tx graph changeset from postgres" ) ;
322324 let mut changeset = tx_graph:: ChangeSet :: default ( ) ;
323325
324326 // Fetch transactions
325- let rows = sqlx:: query ( "SELECT txid, whole_tx, last_seen FROM tx" )
327+ let rows = sqlx:: query ( "SELECT txid, whole_tx, last_seen FROM tx WHERE wallet_name = $1" )
328+ . bind ( wallet_name)
326329 . fetch_all ( & mut * * db_tx)
327330 . await ?;
328331
@@ -343,7 +346,8 @@ pub async fn tx_graph_changeset_from_postgres(
343346 }
344347
345348 // Fetch txouts
346- let rows = sqlx:: query ( "SELECT txid, vout, value, script FROM txout" )
349+ let rows = sqlx:: query ( "SELECT txid, vout, value, script FROM txout WHERE wallet_name = $1" )
350+ . bind ( wallet_name)
347351 . fetch_all ( & mut * * db_tx)
348352 . await ?;
349353
@@ -367,7 +371,8 @@ pub async fn tx_graph_changeset_from_postgres(
367371 }
368372
369373 // Fetch anchors
370- let rows = sqlx:: query ( "SELECT anchor, txid FROM anchor_tx" )
374+ let rows = sqlx:: query ( "SELECT anchor, txid FROM anchor_tx WHERE wallet_name = $1" )
375+ . bind ( wallet_name)
371376 . fetch_all ( & mut * * db_tx)
372377 . await ?;
373378
@@ -449,11 +454,13 @@ pub async fn tx_graph_changeset_persist_to_postgres(
449454#[ tracing:: instrument]
450455pub async fn local_chain_changeset_from_postgres (
451456 db_tx : & mut Transaction < ' _ , Postgres > ,
457+ wallet_name : & str ,
452458) -> Result < local_chain:: ChangeSet , BdkSqlxError > {
453459 info ! ( "local chain changeset from postgres" ) ;
454460 let mut changeset = local_chain:: ChangeSet :: default ( ) ;
455461
456- let rows = sqlx:: query ( "SELECT hash, height FROM block" )
462+ let rows = sqlx:: query ( "SELECT hash, height FROM block WHERE wallet_name = $1" )
463+ . bind ( wallet_name)
457464 . fetch_all ( & mut * * db_tx)
458465 . await ?;
459466
0 commit comments