Remove backupwallet / backup oracle (#3920)

* Remove backupwallet / backup oracle

* Add zipdatadir documentation

* Fix submodule
This commit is contained in:
Chris Stewart 2021-12-20 08:19:46 -06:00 committed by GitHub
parent f6608f49b2
commit 3cd57d37f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 4 additions and 116 deletions

View File

@ -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

View File

@ -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()

View File

@ -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 =>

View File

@ -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}""")
}
}
}
}

View File

@ -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 */

View File

@ -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]
}

View File

@ -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 */

View File

@ -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)
}

View File

@ -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`

View File

@ -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

View File

@ -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