From 2a0a83cc14f8e1e04983167dddd470a0de3dfbf3 Mon Sep 17 00:00:00 2001 From: github-actions Date: Wed, 30 Nov 2022 17:42:09 +0000 Subject: [PATCH] Publish autogenerated nightly docs --- .../bdk/database/struct.SqliteDatabase.html | 64 +++++------ .../bdk/database/trait.BatchDatabase.html | 2 +- .../bdk/database/trait.BatchOperations.html | 2 +- .../latest/bdk/database/trait.Database.html | 2 +- .../latest/src/bdk/database/sqlite.rs.html | 104 +++++++++++++++++- 5 files changed, 137 insertions(+), 37 deletions(-) diff --git a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/database/struct.SqliteDatabase.html b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/database/struct.SqliteDatabase.html index 593cd783ae..5db4e8545d 100644 --- a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/database/struct.SqliteDatabase.html +++ b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/database/struct.SqliteDatabase.html @@ -6,7 +6,7 @@ logo

SqliteDatabase

logo
pub struct SqliteDatabase {
+    

Struct bdk::database::SqliteDatabase

source · []
pub struct SqliteDatabase {
     pub path: PathBuf,
     pub connection: Connection,
 }
Expand description

Sqlite database stored on filesystem

@@ -14,41 +14,41 @@ crate::database

Fields

path: PathBuf

Path on the local filesystem to store the sqlite file

connection: Connection

A rusqlite connection object to the sqlite database

-

Implementations

Instantiate a new SqliteDatabase instance by creating a connection +

Implementations

Instantiate a new SqliteDatabase instance by creating a connection to the database stored at path

-

Trait Implementations

Container for the operations

-

Create a new batch container

-

Consume and apply a batch of operations

-

Store a script_pubkey along with its keychain and child number.

-

Store a LocalUtxo

-

Store a raw transaction

-

Store the metadata of a transaction

-

Store the last derivation index for a given keychain.

-

Store the sync time

-

Delete a script_pubkey given the keychain and its child number.

-

Delete the data related to a specific script_pubkey, meaning the keychain and the child +

Trait Implementations

Container for the operations

+

Create a new batch container

+

Consume and apply a batch of operations

+

Store a script_pubkey along with its keychain and child number.

+

Store a LocalUtxo

+

Store a raw transaction

+

Store the metadata of a transaction

+

Store the last derivation index for a given keychain.

+

Store the sync time

+

Delete a script_pubkey given the keychain and its child number.

+

Delete the data related to a specific script_pubkey, meaning the keychain and the child number. Read more

-

Delete a LocalUtxo given its [OutPoint]

-

Delete a raw transaction given its [Txid]

-

Delete the metadata of a transaction and optionally the raw transaction itself

-

Delete the last derivation index for a keychain.

-

Reset the sync time to None Read more

+

Delete a LocalUtxo given its [OutPoint]

+

Delete a raw transaction given its [Txid]

+

Delete the metadata of a transaction and optionally the raw transaction itself

+

Delete the last derivation index for a keychain.

+

Reset the sync time to None Read more

Type that contains the configuration

Create a new instance given a configuration

-

Read and checks the descriptor checksum for a given keychain. Read more

-

Return the list of script_pubkeys

-

Return the list of LocalUtxos

-

Return the list of raw transactions

-

Return the list of transactions metadata

-

Fetch a script_pubkey given the child number of a keychain.

-

Fetch the keychain and child number of a given script_pubkey

-

Fetch a LocalUtxo given its [OutPoint]

-

Fetch a raw transaction given its [Txid]

-

Fetch the transaction metadata and optionally also the raw transaction

-

Return the last derivation index for a keychain.

-

Return the sync time, if present

-

Increment the last derivation index for a keychain and return it Read more

-

Formats the value using the given formatter. Read more

+

Read and checks the descriptor checksum for a given keychain. Read more

+

Return the list of script_pubkeys

+

Return the list of LocalUtxos

+

Return the list of raw transactions

+

Return the list of transactions metadata

+

Fetch a script_pubkey given the child number of a keychain.

+

Fetch the keychain and child number of a given script_pubkey

+

Fetch a LocalUtxo given its [OutPoint]

+

Fetch a raw transaction given its [Txid]

+

Fetch the transaction metadata and optionally also the raw transaction

+

Return the last derivation index for a keychain.

+

Return the sync time, if present

+

Increment the last derivation index for a keychain and return it Read more

+

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

diff --git a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/database/trait.BatchDatabase.html b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/database/trait.BatchDatabase.html index cf16ab2af9..08eecbd1bb 100644 --- a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/database/trait.BatchDatabase.html +++ b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/database/trait.BatchDatabase.html @@ -15,5 +15,5 @@

Associated Types

Container for the operations

Required methods

Create a new batch container

Consume and apply a batch of operations

-

Implementations on Foreign Types

Implementors

+

Implementations on Foreign Types

Implementors

\ No newline at end of file diff --git a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/database/trait.BatchOperations.html b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/database/trait.BatchOperations.html index b85568ebbc..540aee3720 100644 --- a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/database/trait.BatchOperations.html +++ b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/database/trait.BatchOperations.html @@ -38,5 +38,5 @@ number.

Delete the last derivation index for a keychain.

Reset the sync time to None

Returns the removed value

-

Implementations on Foreign Types

Implementors

+

Implementations on Foreign Types

Implementors

\ No newline at end of file diff --git a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/database/trait.Database.html b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/database/trait.Database.html index 3a49d6f2df..745230828f 100644 --- a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/database/trait.Database.html +++ b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/database/trait.Database.html @@ -39,5 +39,5 @@ next time.

Return the sync time, if present

Increment the last derivation index for a keychain and return it

It should insert and return 0 if not present in the database

-

Implementations on Foreign Types

Implementors

+

Implementations on Foreign Types

Implementors

\ No newline at end of file diff --git a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/src/bdk/database/sqlite.rs.html b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/src/bdk/database/sqlite.rs.html index 65e4a986be..528c87d8d8 100644 --- a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/src/bdk/database/sqlite.rs.html +++ b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/src/bdk/database/sqlite.rs.html @@ -1104,6 +1104,56 @@ 1097 1098 1099 +1100 +1101 +1102 +1103 +1104 +1105 +1106 +1107 +1108 +1109 +1110 +1111 +1112 +1113 +1114 +1115 +1116 +1117 +1118 +1119 +1120 +1121 +1122 +1123 +1124 +1125 +1126 +1127 +1128 +1129 +1130 +1131 +1132 +1133 +1134 +1135 +1136 +1137 +1138 +1139 +1140 +1141 +1142 +1143 +1144 +1145 +1146 +1147 +1148 +1149
// Bitcoin Dev Kit
 // Written in 2020 by Alekos Filini <alekos.filini@gmail.com>
 //
@@ -1163,7 +1213,17 @@
     "CREATE TABLE utxos (value INTEGER, keychain TEXT, vout INTEGER, txid BLOB, script BLOB, is_spent BOOLEAN DEFAULT 0);",
     "INSERT INTO utxos SELECT value, keychain, vout, txid, script, is_spent FROM utxos_old;",
     "DROP TABLE utxos_old;",
-    "CREATE UNIQUE INDEX idx_utxos_txid_vout ON utxos(txid, vout);"
+    "CREATE UNIQUE INDEX idx_utxos_txid_vout ON utxos(txid, vout);",
+    // Fix issue https://github.com/bitcoindevkit/bdk/issues/801: drop duplicated script_pubkeys
+    "ALTER TABLE script_pubkeys RENAME TO script_pubkeys_old;",
+    "DROP INDEX idx_keychain_child;",
+    "DROP INDEX idx_script;",
+    "CREATE TABLE script_pubkeys (keychain TEXT, child INTEGER, script BLOB);",
+    "CREATE INDEX idx_keychain_child ON script_pubkeys(keychain, child);",
+    "CREATE INDEX idx_script ON script_pubkeys(script);",
+    "CREATE UNIQUE INDEX idx_script_pks_unique ON script_pubkeys(keychain, child);",
+    "INSERT OR REPLACE INTO script_pubkeys SELECT keychain, child, script FROM script_pubkeys_old;",
+    "DROP TABLE script_pubkeys_old;"
 ];
 
 /// Sqlite database stored on filesystem
@@ -1194,7 +1254,7 @@
         child: u32,
         script: &[u8],
     ) -> Result<i64, Error> {
-        let mut statement = self.connection.prepare_cached("INSERT INTO script_pubkeys (keychain, child, script) VALUES (:keychain, :child, :script)")?;
+        let mut statement = self.connection.prepare_cached("INSERT OR REPLACE INTO script_pubkeys (keychain, child, script) VALUES (:keychain, :child, :script)")?;
         statement.execute(named_params! {
             ":keychain": keychain,
             ":child": child,
@@ -2202,6 +2262,46 @@
     fn test_check_descriptor_checksum() {
         crate::database::test::test_check_descriptor_checksum(get_database());
     }
+
+    // Issue 801: https://github.com/bitcoindevkit/bdk/issues/801
+    #[test]
+    fn test_unique_spks() {
+        use crate::bitcoin::hashes::hex::FromHex;
+        use crate::database::*;
+
+        let mut db = get_database();
+
+        let script = Script::from(
+            Vec::<u8>::from_hex("76a91402306a7c23f3e8010de41e9e591348bb83f11daa88ac").unwrap(),
+        );
+        let path = 42;
+        let keychain = KeychainKind::External;
+
+        for _ in 0..100 {
+            db.set_script_pubkey(&script, keychain, path).unwrap();
+        }
+
+        let mut statement = db
+            .connection
+            .prepare_cached(
+                "select keychain,child,count(child) from script_pubkeys group by keychain,child;",
+            )
+            .unwrap();
+        let mut rows = statement.query([]).unwrap();
+        while let Some(row) = rows.next().unwrap() {
+            let keychain: String = row.get(0).unwrap();
+            let child: u32 = row.get(1).unwrap();
+            let count: usize = row.get(2).unwrap();
+
+            assert!(
+                count == 1,
+                "keychain={}, child={}, count={}",
+                keychain,
+                child,
+                count
+            );
+        }
+    }
 }
 
-- 2.49.0