mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2024-11-19 09:52:09 +01:00
Create BlockSyncState type (#2567)
This commit is contained in:
parent
d305dc50d5
commit
fa27fb3fb1
@ -562,7 +562,10 @@ case class WalletRoutes(wallet: AnyHDWalletApi)(implicit
|
||||
|
||||
/** Returns information about the state of our wallet */
|
||||
def getInfo: Future[Obj] = {
|
||||
wallet.getDefaultAccount().map { accountDb =>
|
||||
for {
|
||||
accountDb <- wallet.getDefaultAccount()
|
||||
walletState <- wallet.getSyncState()
|
||||
} yield {
|
||||
Obj(
|
||||
WalletAppConfig.moduleName ->
|
||||
Obj(
|
||||
@ -570,7 +573,9 @@ case class WalletRoutes(wallet: AnyHDWalletApi)(implicit
|
||||
"rootXpub" -> Str(wallet.keyManager.getRootXPub.toString)
|
||||
),
|
||||
"xpub" -> Str(accountDb.xpub.toString),
|
||||
"hdPath" -> Str(accountDb.hdAccount.toString)
|
||||
"hdPath" -> Str(accountDb.hdAccount.toString),
|
||||
"height" -> Num(walletState.height),
|
||||
"blockHash" -> Str(walletState.blockHash.hex)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -0,0 +1,5 @@
|
||||
package org.bitcoins.core.api.wallet
|
||||
|
||||
import org.bitcoins.crypto.DoubleSha256DigestBE
|
||||
|
||||
case class BlockSyncState(height: Int, blockHash: DoubleSha256DigestBE)
|
@ -396,6 +396,8 @@ trait WalletApi extends StartStopAsync[WalletApi] {
|
||||
* is a change output from this wallet
|
||||
*/
|
||||
def isChange(output: TransactionOutput): Future[Boolean]
|
||||
|
||||
def getSyncState(): Future[BlockSyncState]
|
||||
}
|
||||
|
||||
/** An HDWallet that uses Neutrino to sync */
|
||||
|
@ -5,7 +5,11 @@ import org.bitcoins.core.api.chain.ChainQueryApi
|
||||
import org.bitcoins.core.api.feeprovider.FeeRateApi
|
||||
import org.bitcoins.core.api.node.NodeApi
|
||||
import org.bitcoins.core.api.wallet.db.{AccountDb, SpendingInfoDb}
|
||||
import org.bitcoins.core.api.wallet.{AnyHDWalletApi, CoinSelectionAlgo}
|
||||
import org.bitcoins.core.api.wallet.{
|
||||
AnyHDWalletApi,
|
||||
BlockSyncState,
|
||||
CoinSelectionAlgo
|
||||
}
|
||||
import org.bitcoins.core.bloom.{BloomFilter, BloomUpdateAll}
|
||||
import org.bitcoins.core.config.NetworkParameters
|
||||
import org.bitcoins.core.crypto.ExtPublicKey
|
||||
@ -161,6 +165,15 @@ abstract class Wallet
|
||||
stateDescriptorDAO.getSyncDescriptorOpt()
|
||||
}
|
||||
|
||||
override def getSyncState(): Future[BlockSyncState] = {
|
||||
getSyncDescriptorOpt().map {
|
||||
case Some(descriptor) =>
|
||||
BlockSyncState(descriptor.height, descriptor.bestHash)
|
||||
case None =>
|
||||
BlockSyncState(0, chainParams.genesisHashBE)
|
||||
}
|
||||
}
|
||||
|
||||
override def processCompactFilters(
|
||||
blockFilters: Vector[(DoubleSha256Digest, GolombFilter)]): Future[
|
||||
Wallet] = {
|
||||
|
Loading…
Reference in New Issue
Block a user