diff --git a/app/cli/src/main/scala/org/bitcoins/cli/ConsoleCli.scala b/app/cli/src/main/scala/org/bitcoins/cli/ConsoleCli.scala index b93b657f1d..6c6ea24ca5 100644 --- a/app/cli/src/main/scala/org/bitcoins/cli/ConsoleCli.scala +++ b/app/cli/src/main/scala/org/bitcoins/cli/ConsoleCli.scala @@ -733,20 +733,6 @@ object ConsoleCli { case other => other })) ), - cmd("backupwallet") - .action((_, conf) => conf.copy(command = BackupWallet(null))) - .text("Backs up the wallet SQLite database") - .children( - arg[String]("dest") - .text("Destination file name") - .required() - .action((dest, conf) => - conf.copy(command = conf.command match { - case wps: BackupWallet => - wps.copy(destination = dest) - case other => other - })) - ), note(sys.props("line.separator") + "=== DLC ==="), cmd("decodecontractinfo") .action((_, conf) => conf.copy(command = DecodeContractInfo(null))) @@ -1885,8 +1871,6 @@ object ConsoleCli { Seq(up.writeJs(walletName), up.writeJs(xprv), up.writeJs(passwordOpt))) - case BackupWallet(location) => - RequestParam("backupwallet", Seq(up.writeJs(location))) case GetBlockHeader(hash) => RequestParam("getblockheader", Seq(up.writeJs(hash))) @@ -2319,7 +2303,6 @@ object CliCommand { case class GetBalances(isSats: Boolean) extends AppServerCliCommand case class GetAddressInfo(address: BitcoinAddress) extends AppServerCliCommand case object GetDLCWalletAccounting extends AppServerCliCommand - case class BackupWallet(destination: String) extends AppServerCliCommand case class GetTransaction(txId: DoubleSha256DigestBE) extends AppServerCliCommand diff --git a/app/oracle-server-test/src/test/scala/org/bitcoins/oracle/server/OracleRoutesSpec.scala b/app/oracle-server-test/src/test/scala/org/bitcoins/oracle/server/OracleRoutesSpec.scala index 7c472060fd..a665f91d16 100644 --- a/app/oracle-server-test/src/test/scala/org/bitcoins/oracle/server/OracleRoutesSpec.scala +++ b/app/oracle-server-test/src/test/scala/org/bitcoins/oracle/server/OracleRoutesSpec.scala @@ -21,7 +21,6 @@ import org.scalamock.scalatest.MockFactory import org.scalatest.wordspec.AnyWordSpec import ujson._ -import java.nio.file.{FileSystems, Path} import java.time.Instant import scala.concurrent.Future @@ -399,23 +398,6 @@ class OracleRoutesSpec } } - "backup" in { - val dest = FileSystems.getDefault.getPath("/tmp/location") - (mockOracleApi - .backup(_: Path)) - .expects(dest) - .returning(Future.unit) - - val route = - oracleRoutes.handleCommand( - ServerCommand("backuporacle", Arr(Str("/tmp/location")))) - - Post() ~> route ~> check { - assert(contentType == `application/json`) - assert(responseAs[String] == s"""{"result":"done","error":null}""") - } - } - "get oracle name" in { (mockOracleApi.oracleName: () => Future[Option[String]]) .expects() diff --git a/app/oracle-server/src/main/scala/org/bitcoins/oracle/server/OracleRoutes.scala b/app/oracle-server/src/main/scala/org/bitcoins/oracle/server/OracleRoutes.scala index ed7c4bd8e2..ff64e37236 100644 --- a/app/oracle-server/src/main/scala/org/bitcoins/oracle/server/OracleRoutes.scala +++ b/app/oracle-server/src/main/scala/org/bitcoins/oracle/server/OracleRoutes.scala @@ -12,7 +12,6 @@ import org.bitcoins.keymanager.WalletStorage import org.bitcoins.server.routes.{Server, ServerCommand, ServerRoute} import ujson._ -import java.nio.file.FileSystems import scala.util.{Failure, Success} case class OracleRoutes(oracle: DLCOracleApi)(implicit @@ -314,13 +313,6 @@ case class OracleRoutes(oracle: DLCOracleApi)(implicit } } } - case ServerCommand("backuporacle", arr) => - complete { - val dest = FileSystems.getDefault.getPath(arr.arr.head.str) - oracle.backup(dest).map { _ => - Server.httpSuccess("done") - } - } case ServerCommand("getoraclename", _) => complete { oracle.oracleName().map { name => diff --git a/app/server-test/src/test/scala/org/bitcoins/server/RoutesSpec.scala b/app/server-test/src/test/scala/org/bitcoins/server/RoutesSpec.scala index 53fcec9a84..fc81ba085f 100644 --- a/app/server-test/src/test/scala/org/bitcoins/server/RoutesSpec.scala +++ b/app/server-test/src/test/scala/org/bitcoins/server/RoutesSpec.scala @@ -49,7 +49,6 @@ import scodec.bits.ByteVector import ujson.Value.InvalidData import ujson._ -import java.nio.file.{FileSystems, Path} import java.time.{ZoneId, ZonedDateTime} import scala.collection.mutable import scala.concurrent.duration.DurationInt @@ -1788,22 +1787,5 @@ class RoutesSpec extends AnyWordSpec with ScalatestRouteTest with MockFactory { assert(str == expected) } } - - "backup wallet" in { - val dest = FileSystems.getDefault.getPath("location") - (mockWalletApi - .backup(_: Path)) - .expects(dest) - .returning(Future.unit) - - val route = - walletRoutes.handleCommand( - ServerCommand("backupwallet", Arr(Str("location")))) - - Post() ~> route ~> check { - assert(contentType == `application/json`) - assert(responseAs[String] == s"""{"result":"done","error":null}""") - } - } } } diff --git a/app/server/src/main/scala/org/bitcoins/server/WalletRoutes.scala b/app/server/src/main/scala/org/bitcoins/server/WalletRoutes.scala index d14c6663e3..2e983cbd1a 100644 --- a/app/server/src/main/scala/org/bitcoins/server/WalletRoutes.scala +++ b/app/server/src/main/scala/org/bitcoins/server/WalletRoutes.scala @@ -19,7 +19,7 @@ import org.bitcoins.wallet.config.WalletAppConfig import ujson._ import upickle.default._ -import java.nio.file.{FileSystems, Files, Path} +import java.nio.file.{Files, Path} import java.time.Instant import scala.concurrent.Future import scala.util.{Failure, Success} @@ -821,14 +821,6 @@ case class WalletRoutes(wallet: AnyDLCHDWalletApi)(implicit Server.httpSuccess(writeJs(accounting)) } } - - case ServerCommand("backupwallet", arr) => - complete { - val dest = FileSystems.getDefault.getPath(arr.arr.head.str) - wallet.backup(dest).map { _ => - Server.httpSuccess("done") - } - } } /** Returns information about the state of our wallet */ diff --git a/core/src/main/scala/org/bitcoins/core/api/dlcoracle/DLCOracleApi.scala b/core/src/main/scala/org/bitcoins/core/api/dlcoracle/DLCOracleApi.scala index 028626d3f2..cd2e3ad32c 100644 --- a/core/src/main/scala/org/bitcoins/core/api/dlcoracle/DLCOracleApi.scala +++ b/core/src/main/scala/org/bitcoins/core/api/dlcoracle/DLCOracleApi.scala @@ -8,8 +8,6 @@ import org.bitcoins.core.protocol.dlc.compute.SigningVersion import org.bitcoins.core.protocol.tlv._ import org.bitcoins.crypto._ import scodec.bits.ByteVector - -import java.nio.file.Path import java.time.Instant import scala.concurrent.Future @@ -170,9 +168,4 @@ trait DLCOracleApi { /** Signs the SHA256 hash of the given bytes using the oracle's signing key */ def signMessage(message: ByteVector): SchnorrDigitalSignature - - /** Backup oracle database. Works only for the SQLite database driver. - * @param location backup file location - */ - def backup(location: Path): Future[Unit] } diff --git a/core/src/main/scala/org/bitcoins/core/api/wallet/WalletApi.scala b/core/src/main/scala/org/bitcoins/core/api/wallet/WalletApi.scala index 580332e76a..f10d310459 100644 --- a/core/src/main/scala/org/bitcoins/core/api/wallet/WalletApi.scala +++ b/core/src/main/scala/org/bitcoins/core/api/wallet/WalletApi.scala @@ -20,7 +20,6 @@ import org.bitcoins.core.wallet.fee.FeeUnit import org.bitcoins.core.wallet.utxo.{AddressTag, AddressTagType, TxoState} import org.bitcoins.crypto.DoubleSha256DigestBE -import java.nio.file.Path import java.time.Instant import scala.concurrent.{ExecutionContext, Future} import scala.util.{Failure, Success} @@ -403,11 +402,6 @@ trait WalletApi extends StartStopAsync[WalletApi] { def isChange(output: TransactionOutput): Future[Boolean] def getSyncState(): Future[BlockSyncState] - - /** Backup oracle database. Works only for the SQLite database driver. - * @param location backup file location - */ - def backup(location: Path): Future[Unit] } /** An HDWallet that uses Neutrino to sync */ diff --git a/dlc-oracle/src/main/scala/org/bitcoins/dlc/oracle/DLCOracle.scala b/dlc-oracle/src/main/scala/org/bitcoins/dlc/oracle/DLCOracle.scala index 10fb330c77..fddf12da99 100644 --- a/dlc-oracle/src/main/scala/org/bitcoins/dlc/oracle/DLCOracle.scala +++ b/dlc-oracle/src/main/scala/org/bitcoins/dlc/oracle/DLCOracle.scala @@ -16,7 +16,6 @@ import org.bitcoins.core.protocol.tlv._ import org.bitcoins.core.util.sorted.OrderedNonces import org.bitcoins.core.util.{FutureUtil, NumberUtil, TimeUtil} import org.bitcoins.crypto._ -import org.bitcoins.db.{DatabaseDriver, SQLiteUtil} import org.bitcoins.db.models.MasterXPubDAO import org.bitcoins.db.util.MasterXPubUtil import org.bitcoins.dlc.oracle.config.DLCOracleAppConfig @@ -461,20 +460,6 @@ case class DLCOracle()(implicit val conf: DLCOracleAppConfig) } yield OracleEvent.fromEventDbs(eventDbs) } - /** Backup oracle database - * - * @param location baclup file location - */ - override def backup(location: Path): Future[Unit] = conf.driver match { - case DatabaseDriver.SQLite => - val jdbcUrl = conf.jdbcUrl.replace("\"", "") - Future { SQLiteUtil.backup(jdbcUrl, location) } - case _: DatabaseDriver => - Future.failed( - new IllegalArgumentException( - "Backup is supported only for SQLite database backend")) - } - override def oracleName(): Future[Option[String]] = { masterXpubDAO.findXPub().map(_.name) } diff --git a/docs/applications/server.md b/docs/applications/server.md index b9badbb146..d576d8db43 100644 --- a/docs/applications/server.md +++ b/docs/applications/server.md @@ -140,6 +140,8 @@ the `-p 9999:9999` port mapping on the docker container to adjust for this. ### Common - `getversion` - The version of our application you are using + - `zipdatadir` `location` - Backs up the datadir in a safe and consistent manner. + - `location` - The locations of the backup zip ### Blockchain - `getblockcount` - Get the current block height @@ -227,8 +229,6 @@ the `-p 9999:9999` port mapping on the docker container to adjust for this. - `newpassphrase` - The new passphrase - `keymanagerpassphraseset` `passphrase` - Encrypts the wallet with the given passphrase - `passphrase` - The passphrase to encrypt the wallet with -- `backupwallet` `location` - Backs up the wallet database in a safe and consistent manner. - - `location` - The locations of the backup file ### DLC - `createcontractinfo` `announcement` `totalCollateral` `payouts` diff --git a/docs/oracle/oracle-server.md b/docs/oracle/oracle-server.md index cfa8347d6e..604f841747 100644 --- a/docs/oracle/oracle-server.md +++ b/docs/oracle/oracle-server.md @@ -50,8 +50,6 @@ checkout [this page](build-oracle-server.md). - `eventName` - The event's name - `signmessage` `message` - Signs the SHA256 hash of the given string using the oracle's signing key - `message` - Message to hash and sign -- `backuporacle` `location` - Backs up the oracle database in a safe and consistent manner. - - `location` - The locations of the backup file - `setoraclename` `oraclename` Sets the oracle name in the database - `getoraclename` gets the oraclename for the database diff --git a/wallet/src/main/scala/org/bitcoins/wallet/Wallet.scala b/wallet/src/main/scala/org/bitcoins/wallet/Wallet.scala index c2d90fa8b5..d8b5e8f4e1 100644 --- a/wallet/src/main/scala/org/bitcoins/wallet/Wallet.scala +++ b/wallet/src/main/scala/org/bitcoins/wallet/Wallet.scala @@ -32,15 +32,13 @@ import org.bitcoins.core.wallet.utxo.TxoState._ import org.bitcoins.core.wallet.utxo._ import org.bitcoins.crypto._ import org.bitcoins.db.models.MasterXPubDAO -import org.bitcoins.db.{DatabaseDriver, SQLiteUtil, SafeDatabase} +import org.bitcoins.db.SafeDatabase import org.bitcoins.keymanager.bip39.BIP39KeyManager import org.bitcoins.wallet.config.WalletAppConfig import org.bitcoins.wallet.internal._ import org.bitcoins.wallet.models._ import scodec.bits.ByteVector import slick.dbio.{DBIOAction, Effect, NoStream} - -import java.nio.file.Path import java.time.Instant import scala.concurrent.{ExecutionContext, Future} import scala.util.{Failure, Random, Success} @@ -951,17 +949,6 @@ abstract class Wallet this } } - - override def backup(location: Path): Future[Unit] = - walletConfig.driver match { - case DatabaseDriver.SQLite => - val jdbcUrl = walletConfig.jdbcUrl.replace("\"", "") - Future { SQLiteUtil.backup(jdbcUrl, location) } - case _: DatabaseDriver => - Future.failed( - new IllegalArgumentException( - "Backup is supported only for SQLite database backend")) - } } // todo: create multiple wallets, need to maintain multiple databases