mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-22 14:33:06 +01:00
wallet: Refactor {UTXOHandlingApi,AccountHandlingApi,AddressHandlingApi} to use 'get' prefix rather than 'list' prefix for method names (#5828)
This commit is contained in:
parent
43efce500d
commit
b9616066f2
34 changed files with 196 additions and 199 deletions
|
@ -246,8 +246,8 @@ object ConsoleCli extends BitcoinSLogger {
|
||||||
cmd("getutxos")
|
cmd("getutxos")
|
||||||
.action((_, conf) => conf.copy(command = GetUtxos))
|
.action((_, conf) => conf.copy(command = GetUtxos))
|
||||||
.text("Returns list of all wallet utxos"),
|
.text("Returns list of all wallet utxos"),
|
||||||
cmd("listreservedutxos")
|
cmd("getreservedutxos")
|
||||||
.action((_, conf) => conf.copy(command = ListReservedUtxos))
|
.action((_, conf) => conf.copy(command = GetReservedUtxos))
|
||||||
.text("Returns list of all reserved wallet utxos"),
|
.text("Returns list of all reserved wallet utxos"),
|
||||||
cmd("getaddresses")
|
cmd("getaddresses")
|
||||||
.action((_, conf) => conf.copy(command = GetAddresses))
|
.action((_, conf) => conf.copy(command = GetAddresses))
|
||||||
|
@ -2159,8 +2159,8 @@ object CliCommand {
|
||||||
RequestParam("getmediantimepast")
|
RequestParam("getmediantimepast")
|
||||||
case GetUtxos =>
|
case GetUtxos =>
|
||||||
RequestParam("getutxos")
|
RequestParam("getutxos")
|
||||||
case ListReservedUtxos =>
|
case GetReservedUtxos =>
|
||||||
RequestParam("listreservedutxos")
|
RequestParam("getreservedutxos")
|
||||||
case GetAddresses =>
|
case GetAddresses =>
|
||||||
RequestParam("getaddresses")
|
RequestParam("getaddresses")
|
||||||
case GetSpentAddresses =>
|
case GetSpentAddresses =>
|
||||||
|
@ -2673,7 +2673,7 @@ object CliCommand {
|
||||||
|
|
||||||
case object GetAddressLabels extends AppServerCliCommand
|
case object GetAddressLabels extends AppServerCliCommand
|
||||||
case object GetUtxos extends AppServerCliCommand
|
case object GetUtxos extends AppServerCliCommand
|
||||||
case object ListReservedUtxos extends AppServerCliCommand
|
case object GetReservedUtxos extends AppServerCliCommand
|
||||||
case object GetAddresses extends AppServerCliCommand
|
case object GetAddresses extends AppServerCliCommand
|
||||||
case object GetSpentAddresses extends AppServerCliCommand
|
case object GetSpentAddresses extends AppServerCliCommand
|
||||||
case object GetFundedAddresses extends AppServerCliCommand
|
case object GetFundedAddresses extends AppServerCliCommand
|
||||||
|
|
|
@ -471,7 +471,7 @@ class RoutesSpec extends AnyWordSpec with ScalatestRouteTest with MockFactory {
|
||||||
.returning(Future.successful(Bitcoins(50)))
|
.returning(Future.successful(Bitcoins(50)))
|
||||||
|
|
||||||
(mockWalletApi.utxoHandling
|
(mockWalletApi.utxoHandling
|
||||||
.listUtxos(_: TxoState))
|
.getUtxos(_: TxoState))
|
||||||
.expects(TxoState.Reserved)
|
.expects(TxoState.Reserved)
|
||||||
.returning(Future.successful(Vector(spendingInfoDb)))
|
.returning(Future.successful(Vector(spendingInfoDb)))
|
||||||
|
|
||||||
|
@ -503,7 +503,7 @@ class RoutesSpec extends AnyWordSpec with ScalatestRouteTest with MockFactory {
|
||||||
.anyNumberOfTimes()
|
.anyNumberOfTimes()
|
||||||
|
|
||||||
(mockWalletApi.utxoHandling
|
(mockWalletApi.utxoHandling
|
||||||
.listUtxos(_: TxoState))
|
.getUtxos(_: TxoState))
|
||||||
.expects(TxoState.Reserved)
|
.expects(TxoState.Reserved)
|
||||||
.returning(Future.successful(Vector(spendingInfoDb)))
|
.returning(Future.successful(Vector(spendingInfoDb)))
|
||||||
|
|
||||||
|
@ -556,7 +556,7 @@ class RoutesSpec extends AnyWordSpec with ScalatestRouteTest with MockFactory {
|
||||||
.returning(mockUtxoHandlingApi)
|
.returning(mockUtxoHandlingApi)
|
||||||
.anyNumberOfTimes()
|
.anyNumberOfTimes()
|
||||||
|
|
||||||
(() => mockWalletApi.utxoHandling.listUtxos())
|
(() => mockWalletApi.utxoHandling.getUtxos())
|
||||||
.expects()
|
.expects()
|
||||||
.returning(Future.successful(Vector(spendingInfoDb)))
|
.returning(Future.successful(Vector(spendingInfoDb)))
|
||||||
|
|
||||||
|
@ -577,12 +577,12 @@ class RoutesSpec extends AnyWordSpec with ScalatestRouteTest with MockFactory {
|
||||||
.returning(mockUtxoHandlingApi)
|
.returning(mockUtxoHandlingApi)
|
||||||
.anyNumberOfTimes()
|
.anyNumberOfTimes()
|
||||||
(mockWalletApi.utxoHandling
|
(mockWalletApi.utxoHandling
|
||||||
.listUtxos(_: TxoState))
|
.getUtxos(_: TxoState))
|
||||||
.expects(TxoState.Reserved)
|
.expects(TxoState.Reserved)
|
||||||
.returning(Future.successful(Vector(spendingInfoDb)))
|
.returning(Future.successful(Vector(spendingInfoDb)))
|
||||||
|
|
||||||
val route =
|
val route =
|
||||||
walletRoutes.handleCommand(ServerCommand("listreservedutxos", Arr()))
|
walletRoutes.handleCommand(ServerCommand("getreservedutxos", Arr()))
|
||||||
|
|
||||||
Get() ~> route ~> check {
|
Get() ~> route ~> check {
|
||||||
assert(contentType == `application/json`)
|
assert(contentType == `application/json`)
|
||||||
|
@ -606,7 +606,7 @@ class RoutesSpec extends AnyWordSpec with ScalatestRouteTest with MockFactory {
|
||||||
.returning(mockAddressHandlingApi)
|
.returning(mockAddressHandlingApi)
|
||||||
.anyNumberOfTimes()
|
.anyNumberOfTimes()
|
||||||
|
|
||||||
(() => mockWalletApi.addressHandling.listAddresses())
|
(() => mockWalletApi.addressHandling.getAddresses())
|
||||||
.expects()
|
.expects()
|
||||||
.returning(Future.successful(Vector(addressDb)))
|
.returning(Future.successful(Vector(addressDb)))
|
||||||
|
|
||||||
|
@ -637,7 +637,7 @@ class RoutesSpec extends AnyWordSpec with ScalatestRouteTest with MockFactory {
|
||||||
.returning(mockAddressHandlingApi)
|
.returning(mockAddressHandlingApi)
|
||||||
.anyNumberOfTimes()
|
.anyNumberOfTimes()
|
||||||
|
|
||||||
(() => mockWalletApi.addressHandling.listSpentAddresses())
|
(() => mockWalletApi.addressHandling.getSpentAddresses())
|
||||||
.expects()
|
.expects()
|
||||||
.returning(Future.successful(Vector(addressDb)))
|
.returning(Future.successful(Vector(addressDb)))
|
||||||
|
|
||||||
|
@ -668,7 +668,7 @@ class RoutesSpec extends AnyWordSpec with ScalatestRouteTest with MockFactory {
|
||||||
.returning(mockAddressHandlingApi)
|
.returning(mockAddressHandlingApi)
|
||||||
.anyNumberOfTimes()
|
.anyNumberOfTimes()
|
||||||
|
|
||||||
(() => mockWalletApi.addressHandling.listFundedAddresses())
|
(() => mockWalletApi.addressHandling.getFundedAddresses())
|
||||||
.expects()
|
.expects()
|
||||||
.returning(Future.successful(Vector((addressDb, Satoshis.zero))))
|
.returning(Future.successful(Vector((addressDb, Satoshis.zero))))
|
||||||
|
|
||||||
|
@ -698,7 +698,7 @@ class RoutesSpec extends AnyWordSpec with ScalatestRouteTest with MockFactory {
|
||||||
.returning(mockAddressHandlingApi)
|
.returning(mockAddressHandlingApi)
|
||||||
.anyNumberOfTimes()
|
.anyNumberOfTimes()
|
||||||
|
|
||||||
(() => mockWalletApi.addressHandling.listUnusedAddresses())
|
(() => mockWalletApi.addressHandling.getUnusedAddresses())
|
||||||
.expects()
|
.expects()
|
||||||
.returning(Future.successful(Vector(addressDb)))
|
.returning(Future.successful(Vector(addressDb)))
|
||||||
|
|
||||||
|
@ -722,7 +722,7 @@ class RoutesSpec extends AnyWordSpec with ScalatestRouteTest with MockFactory {
|
||||||
.returning(mockAccountHandlingApi)
|
.returning(mockAccountHandlingApi)
|
||||||
.anyNumberOfTimes()
|
.anyNumberOfTimes()
|
||||||
|
|
||||||
(() => mockWalletApi.accountHandling.listAccounts())
|
(() => mockWalletApi.accountHandling.getAccounts())
|
||||||
.expects()
|
.expects()
|
||||||
.returning(Future.successful(Vector(accountDb)))
|
.returning(Future.successful(Vector(accountDb)))
|
||||||
|
|
||||||
|
@ -825,13 +825,13 @@ class RoutesSpec extends AnyWordSpec with ScalatestRouteTest with MockFactory {
|
||||||
.returning(mockUtxoHandlingApi)
|
.returning(mockUtxoHandlingApi)
|
||||||
.anyNumberOfTimes()
|
.anyNumberOfTimes()
|
||||||
|
|
||||||
(() => mockWalletApi.utxoHandling.listUtxos())
|
(() => mockWalletApi.utxoHandling.getUtxos())
|
||||||
.expects()
|
.expects()
|
||||||
.returning(Future.successful(Vector(spendingInfoDb)))
|
.returning(Future.successful(Vector(spendingInfoDb)))
|
||||||
.anyNumberOfTimes()
|
.anyNumberOfTimes()
|
||||||
|
|
||||||
(mockWalletApi.utxoHandling
|
(mockWalletApi.utxoHandling
|
||||||
.listUtxos(_: TxoState))
|
.getUtxos(_: TxoState))
|
||||||
.expects(TxoState.Reserved)
|
.expects(TxoState.Reserved)
|
||||||
.returning(Future.successful(Vector(spendingInfoDb)))
|
.returning(Future.successful(Vector(spendingInfoDb)))
|
||||||
.anyNumberOfTimes()
|
.anyNumberOfTimes()
|
||||||
|
@ -1925,7 +1925,7 @@ class RoutesSpec extends AnyWordSpec with ScalatestRouteTest with MockFactory {
|
||||||
.returning(mockUtxoHandlingApi)
|
.returning(mockUtxoHandlingApi)
|
||||||
.anyNumberOfTimes()
|
.anyNumberOfTimes()
|
||||||
|
|
||||||
(() => mockWalletApi.sendFundsHandling.utxoHandling.listUtxos())
|
(() => mockWalletApi.sendFundsHandling.utxoHandling.getUtxos())
|
||||||
.expects()
|
.expects()
|
||||||
.returning(Future.successful(Vector.empty))
|
.returning(Future.successful(Vector.empty))
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,7 @@ class WalletRoutesSpec
|
||||||
.expects(HDPurpose.default)
|
.expects(HDPurpose.default)
|
||||||
.returning(Future.successful(extPubKey))
|
.returning(Future.successful(extPubKey))
|
||||||
|
|
||||||
(() => mockWalletApi.accountHandling.listAccounts())
|
(() => mockWalletApi.accountHandling.getAccounts())
|
||||||
.expects()
|
.expects()
|
||||||
.returning(Future.successful(Vector(accountDb)))
|
.returning(Future.successful(Vector(accountDb)))
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,7 @@ case class WalletRoutes(loadWalletApi: DLCWalletLoaderApi)(implicit
|
||||||
for {
|
for {
|
||||||
confirmed <- wallet.getConfirmedBalance()
|
confirmed <- wallet.getConfirmedBalance()
|
||||||
unconfirmed <- wallet.getUnconfirmedBalance()
|
unconfirmed <- wallet.getUnconfirmedBalance()
|
||||||
reservedUtxos <- wallet.utxoHandling.listUtxos(TxoState.Reserved)
|
reservedUtxos <- wallet.utxoHandling.getUtxos(TxoState.Reserved)
|
||||||
} yield {
|
} yield {
|
||||||
|
|
||||||
val reserved = reservedUtxos.map(_.output.value).sum
|
val reserved = reservedUtxos.map(_.output.value).sum
|
||||||
|
@ -195,7 +195,6 @@ case class WalletRoutes(loadWalletApi: DLCWalletLoaderApi)(implicit
|
||||||
case Some(txDb) =>
|
case Some(txDb) =>
|
||||||
Server.httpSuccess(txDb.transaction.hex)
|
Server.httpSuccess(txDb.transaction.hex)
|
||||||
}
|
}
|
||||||
resultF.failed.foreach(err => logger.error(s"resultF", err))
|
|
||||||
resultF
|
resultF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,8 +212,8 @@ case class WalletRoutes(loadWalletApi: DLCWalletLoaderApi)(implicit
|
||||||
for {
|
for {
|
||||||
utxos <-
|
utxos <-
|
||||||
if (unlock) {
|
if (unlock) {
|
||||||
wallet.utxoHandling.listUtxos(TxoState.Reserved)
|
wallet.utxoHandling.getUtxos(TxoState.Reserved)
|
||||||
} else wallet.utxoHandling.listUtxos()
|
} else wallet.utxoHandling.getUtxos()
|
||||||
|
|
||||||
filtered =
|
filtered =
|
||||||
if (outputParams.nonEmpty) {
|
if (outputParams.nonEmpty) {
|
||||||
|
@ -794,15 +793,15 @@ case class WalletRoutes(loadWalletApi: DLCWalletLoaderApi)(implicit
|
||||||
|
|
||||||
case ServerCommand("getutxos", _) =>
|
case ServerCommand("getutxos", _) =>
|
||||||
complete {
|
complete {
|
||||||
wallet.utxoHandling.listUtxos().map { utxos =>
|
wallet.utxoHandling.getUtxos().map { utxos =>
|
||||||
val json = utxos.map(spendingInfoDbToJson)
|
val json = utxos.map(spendingInfoDbToJson)
|
||||||
Server.httpSuccess(json)
|
Server.httpSuccess(json)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case ServerCommand("listreservedutxos", _) =>
|
case ServerCommand("getreservedutxos", _) =>
|
||||||
complete {
|
complete {
|
||||||
wallet.utxoHandling.listUtxos(TxoState.Reserved).map { utxos =>
|
wallet.utxoHandling.getUtxos(TxoState.Reserved).map { utxos =>
|
||||||
val json = utxos.map(spendingInfoDbToJson)
|
val json = utxos.map(spendingInfoDbToJson)
|
||||||
Server.httpSuccess(json)
|
Server.httpSuccess(json)
|
||||||
}
|
}
|
||||||
|
@ -810,7 +809,7 @@ case class WalletRoutes(loadWalletApi: DLCWalletLoaderApi)(implicit
|
||||||
|
|
||||||
case ServerCommand("getaddresses", _) =>
|
case ServerCommand("getaddresses", _) =>
|
||||||
complete {
|
complete {
|
||||||
wallet.addressHandling.listAddresses().map { addressDbs =>
|
wallet.addressHandling.getAddresses().map { addressDbs =>
|
||||||
val addresses = addressDbs.map(_.address)
|
val addresses = addressDbs.map(_.address)
|
||||||
Server.httpSuccess(addresses)
|
Server.httpSuccess(addresses)
|
||||||
}
|
}
|
||||||
|
@ -818,7 +817,7 @@ case class WalletRoutes(loadWalletApi: DLCWalletLoaderApi)(implicit
|
||||||
|
|
||||||
case ServerCommand("getspentaddresses", _) =>
|
case ServerCommand("getspentaddresses", _) =>
|
||||||
complete {
|
complete {
|
||||||
wallet.addressHandling.listSpentAddresses().map { addressDbs =>
|
wallet.addressHandling.getSpentAddresses().map { addressDbs =>
|
||||||
val addresses = addressDbs.map(_.address)
|
val addresses = addressDbs.map(_.address)
|
||||||
Server.httpSuccess(addresses)
|
Server.httpSuccess(addresses)
|
||||||
}
|
}
|
||||||
|
@ -826,7 +825,7 @@ case class WalletRoutes(loadWalletApi: DLCWalletLoaderApi)(implicit
|
||||||
|
|
||||||
case ServerCommand("getfundedaddresses", _) =>
|
case ServerCommand("getfundedaddresses", _) =>
|
||||||
complete {
|
complete {
|
||||||
wallet.addressHandling.listFundedAddresses().map { addressDbs =>
|
wallet.addressHandling.getFundedAddresses().map { addressDbs =>
|
||||||
val addressAndValues = addressDbs.map { case (addressDb, value) =>
|
val addressAndValues = addressDbs.map { case (addressDb, value) =>
|
||||||
Obj(
|
Obj(
|
||||||
"address" -> Str(addressDb.address.value),
|
"address" -> Str(addressDb.address.value),
|
||||||
|
@ -840,7 +839,7 @@ case class WalletRoutes(loadWalletApi: DLCWalletLoaderApi)(implicit
|
||||||
|
|
||||||
case ServerCommand("getunusedaddresses", _) =>
|
case ServerCommand("getunusedaddresses", _) =>
|
||||||
complete {
|
complete {
|
||||||
wallet.addressHandling.listUnusedAddresses().map { addressDbs =>
|
wallet.addressHandling.getUnusedAddresses().map { addressDbs =>
|
||||||
val addresses = addressDbs.map(_.address)
|
val addresses = addressDbs.map(_.address)
|
||||||
Server.httpSuccess(addresses)
|
Server.httpSuccess(addresses)
|
||||||
}
|
}
|
||||||
|
@ -848,7 +847,7 @@ case class WalletRoutes(loadWalletApi: DLCWalletLoaderApi)(implicit
|
||||||
|
|
||||||
case ServerCommand("getaccounts", _) =>
|
case ServerCommand("getaccounts", _) =>
|
||||||
complete {
|
complete {
|
||||||
wallet.accountHandling.listAccounts().map { accounts =>
|
wallet.accountHandling.getAccounts().map { accounts =>
|
||||||
val xpubs = accounts.map(_.xpub)
|
val xpubs = accounts.map(_.xpub)
|
||||||
Server.httpSuccess(xpubs)
|
Server.httpSuccess(xpubs)
|
||||||
}
|
}
|
||||||
|
@ -877,7 +876,7 @@ case class WalletRoutes(loadWalletApi: DLCWalletLoaderApi)(implicit
|
||||||
complete {
|
complete {
|
||||||
for {
|
for {
|
||||||
_ <- wallet.accountHandling.createNewAccount(purpose)
|
_ <- wallet.accountHandling.createNewAccount(purpose)
|
||||||
accounts <- wallet.accountHandling.listAccounts()
|
accounts <- wallet.accountHandling.getAccounts()
|
||||||
} yield {
|
} yield {
|
||||||
val xpubs = accounts.map(_.xpub)
|
val xpubs = accounts.map(_.xpub)
|
||||||
val json =
|
val json =
|
||||||
|
|
|
@ -41,10 +41,10 @@ trait AccountHandlingApi {
|
||||||
def getUnconfirmedBalance(account: HDAccount): Future[CurrencyUnit]
|
def getUnconfirmedBalance(account: HDAccount): Future[CurrencyUnit]
|
||||||
|
|
||||||
def getDefaultAccount(): Future[AccountDb]
|
def getDefaultAccount(): Future[AccountDb]
|
||||||
def listAccounts(): Future[Vector[AccountDb]]
|
def getAccounts(): Future[Vector[AccountDb]]
|
||||||
def listAccounts(purpose: HDPurpose)(implicit
|
def getAccounts(purpose: HDPurpose)(implicit
|
||||||
ec: ExecutionContext): Future[Vector[AccountDb]] = {
|
ec: ExecutionContext): Future[Vector[AccountDb]] = {
|
||||||
listAccounts().map(_.filter(_.hdAccount.purpose == purpose))
|
getAccounts().map(_.filter(_.hdAccount.purpose == purpose))
|
||||||
}
|
}
|
||||||
def getDefaultAccountForType(addressType: AddressType): Future[AccountDb]
|
def getDefaultAccountForType(addressType: AddressType): Future[AccountDb]
|
||||||
def getNewAddress(
|
def getNewAddress(
|
||||||
|
@ -88,14 +88,14 @@ trait AccountHandlingApi {
|
||||||
addressBatchSize: Int,
|
addressBatchSize: Int,
|
||||||
forceGenerateSpks: Boolean
|
forceGenerateSpks: Boolean
|
||||||
): Future[Vector[ScriptPubKey]]
|
): Future[Vector[ScriptPubKey]]
|
||||||
def listUnusedAddresses(
|
def getUnusedAddresses(
|
||||||
account: HDAccount
|
account: HDAccount
|
||||||
): Future[Vector[AddressDb]]
|
): Future[Vector[AddressDb]]
|
||||||
def listSpentAddresses(
|
def getSpentAddresses(
|
||||||
account: HDAccount
|
account: HDAccount
|
||||||
): Future[Vector[AddressDb]]
|
): Future[Vector[AddressDb]]
|
||||||
def listAddresses(account: HDAccount): Future[Vector[AddressDb]]
|
def getAddresses(account: HDAccount): Future[Vector[AddressDb]]
|
||||||
def listFundedAddresses(
|
def getFundedAddresses(
|
||||||
account: HDAccount
|
account: HDAccount
|
||||||
): Future[Vector[(AddressDb, CurrencyUnit)]]
|
): Future[Vector[(AddressDb, CurrencyUnit)]]
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,9 @@ trait AddressHandlingApi {
|
||||||
)(implicit ec: ExecutionContext): Future[Boolean] = {
|
)(implicit ec: ExecutionContext): Future[Boolean] = {
|
||||||
val possibleAddressesF = accountOpt match {
|
val possibleAddressesF = accountOpt match {
|
||||||
case Some((ah, account)) =>
|
case Some((ah, account)) =>
|
||||||
ah.listAddresses(account)
|
ah.getAddresses(account)
|
||||||
case None =>
|
case None =>
|
||||||
listAddresses()
|
getAddresses()
|
||||||
}
|
}
|
||||||
|
|
||||||
possibleAddressesF.map { possibleAddresses =>
|
possibleAddressesF.map { possibleAddresses =>
|
||||||
|
@ -86,11 +86,11 @@ trait AddressHandlingApi {
|
||||||
* from this wallet
|
* from this wallet
|
||||||
*/
|
*/
|
||||||
def isChange(output: TransactionOutput): Future[Boolean]
|
def isChange(output: TransactionOutput): Future[Boolean]
|
||||||
def listAddresses(): Future[Vector[AddressDb]]
|
def getAddresses(): Future[Vector[AddressDb]]
|
||||||
def listUnusedAddresses(): Future[Vector[AddressDb]]
|
def getUnusedAddresses(): Future[Vector[AddressDb]]
|
||||||
def listScriptPubKeys(): Future[Vector[ScriptPubKeyDb]]
|
def getScriptPubKeys(): Future[Vector[ScriptPubKeyDb]]
|
||||||
def listSpentAddresses(): Future[Vector[AddressDb]]
|
def getSpentAddresses(): Future[Vector[AddressDb]]
|
||||||
def listFundedAddresses(): Future[Vector[(AddressDb, CurrencyUnit)]]
|
def getFundedAddresses(): Future[Vector[(AddressDb, CurrencyUnit)]]
|
||||||
def tagAddress(
|
def tagAddress(
|
||||||
address: BitcoinAddress,
|
address: BitcoinAddress,
|
||||||
tag: AddressTag
|
tag: AddressTag
|
||||||
|
|
|
@ -402,7 +402,7 @@ trait SendFundsHandlingApi {
|
||||||
ec: ExecutionContext
|
ec: ExecutionContext
|
||||||
): Future[Transaction] = {
|
): Future[Transaction] = {
|
||||||
for {
|
for {
|
||||||
utxos <- utxoHandling.listUtxos()
|
utxos <- utxoHandling.getUtxos()
|
||||||
outpoints = utxos.map(_.outPoint)
|
outpoints = utxos.map(_.outPoint)
|
||||||
tx <- sendFromOutPoints(outpoints, address, feeRate)
|
tx <- sendFromOutPoints(outpoints, address, feeRate)
|
||||||
} yield tx
|
} yield tx
|
||||||
|
|
|
@ -62,23 +62,23 @@ trait UtxoHandlingApi {
|
||||||
* @return
|
* @return
|
||||||
* Vector[SpendingInfoDb]
|
* Vector[SpendingInfoDb]
|
||||||
*/
|
*/
|
||||||
def listUtxos(): Future[Vector[SpendingInfoDb]]
|
def getUtxos(): Future[Vector[SpendingInfoDb]]
|
||||||
|
|
||||||
def listUtxos(tag: AddressTag): Future[Vector[SpendingInfoDb]]
|
def getUtxos(tag: AddressTag): Future[Vector[SpendingInfoDb]]
|
||||||
|
|
||||||
def listUtxos(state: TxoState): Future[Vector[SpendingInfoDb]]
|
def getUtxos(state: TxoState): Future[Vector[SpendingInfoDb]]
|
||||||
|
|
||||||
def listUtxos(account: HDAccount): Future[Vector[SpendingInfoDb]]
|
def getUtxos(account: HDAccount): Future[Vector[SpendingInfoDb]]
|
||||||
|
|
||||||
def listUtxos(
|
def getUtxos(
|
||||||
hdAccount: HDAccount,
|
hdAccount: HDAccount,
|
||||||
tag: AddressTag): Future[Vector[SpendingInfoDb]]
|
tag: AddressTag): Future[Vector[SpendingInfoDb]]
|
||||||
|
|
||||||
def listUtxos(
|
def getUtxos(
|
||||||
hdAccount: HDAccount,
|
hdAccount: HDAccount,
|
||||||
state: TxoState): Future[Vector[SpendingInfoDb]]
|
state: TxoState): Future[Vector[SpendingInfoDb]]
|
||||||
|
|
||||||
def listUtxos(
|
def getUtxos(
|
||||||
outPoints: Vector[TransactionOutPoint]
|
outPoints: Vector[TransactionOutPoint]
|
||||||
): Future[Vector[SpendingInfoDb]]
|
): Future[Vector[SpendingInfoDb]]
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ class MultiWalletDLCTest extends BitcoinSWalletTest {
|
||||||
// now unreserve the utxo
|
// now unreserve the utxo
|
||||||
val reservedUtxoF = for {
|
val reservedUtxoF = for {
|
||||||
_ <- offerF
|
_ <- offerF
|
||||||
utxos <- wallet.utxoHandling.listUtxos(TxoState.Reserved)
|
utxos <- wallet.utxoHandling.getUtxos(TxoState.Reserved)
|
||||||
_ <- wallet.utxoHandling.unmarkUTXOsAsReserved(utxos)
|
_ <- wallet.utxoHandling.unmarkUTXOsAsReserved(utxos)
|
||||||
} yield ()
|
} yield ()
|
||||||
|
|
||||||
|
|
|
@ -557,7 +557,7 @@ class WalletDLCSetupTest extends BitcoinSDualWalletTest {
|
||||||
|
|
||||||
for {
|
for {
|
||||||
oldBalance <- dlcWalletA.getBalance()
|
oldBalance <- dlcWalletA.getBalance()
|
||||||
oldReserved <- walletApiA.utxoHandling.listUtxos(TxoState.Reserved)
|
oldReserved <- walletApiA.utxoHandling.getUtxos(TxoState.Reserved)
|
||||||
_ = assert(oldReserved.isEmpty)
|
_ = assert(oldReserved.isEmpty)
|
||||||
|
|
||||||
offer <- dlcWalletA.createDLCOffer(
|
offer <- dlcWalletA.createDLCOffer(
|
||||||
|
@ -583,7 +583,7 @@ class WalletDLCSetupTest extends BitcoinSDualWalletTest {
|
||||||
)
|
)
|
||||||
|
|
||||||
balance <- dlcWalletA.getBalance()
|
balance <- dlcWalletA.getBalance()
|
||||||
reserved <- walletApiA.utxoHandling.listUtxos(TxoState.Reserved)
|
reserved <- walletApiA.utxoHandling.getUtxos(TxoState.Reserved)
|
||||||
dlcOpt <- dlcWalletA.findDLC(dlcId)
|
dlcOpt <- dlcWalletA.findDLC(dlcId)
|
||||||
} yield {
|
} yield {
|
||||||
assert(balance == oldBalance)
|
assert(balance == oldBalance)
|
||||||
|
@ -607,7 +607,7 @@ class WalletDLCSetupTest extends BitcoinSDualWalletTest {
|
||||||
|
|
||||||
for {
|
for {
|
||||||
oldBalance <- dlcWalletB.getBalance()
|
oldBalance <- dlcWalletB.getBalance()
|
||||||
oldReserved <- walletApiB.utxoHandling.listUtxos(TxoState.Reserved)
|
oldReserved <- walletApiB.utxoHandling.getUtxos(TxoState.Reserved)
|
||||||
_ = assert(oldReserved.isEmpty)
|
_ = assert(oldReserved.isEmpty)
|
||||||
|
|
||||||
offer <- dlcWalletA.createDLCOffer(
|
offer <- dlcWalletA.createDLCOffer(
|
||||||
|
@ -627,7 +627,7 @@ class WalletDLCSetupTest extends BitcoinSDualWalletTest {
|
||||||
_ <- dlcWalletB.cancelDLC(dlcId)
|
_ <- dlcWalletB.cancelDLC(dlcId)
|
||||||
|
|
||||||
balance <- dlcWalletB.getBalance()
|
balance <- dlcWalletB.getBalance()
|
||||||
reserved <- walletApiB.utxoHandling.listUtxos(TxoState.Reserved)
|
reserved <- walletApiB.utxoHandling.getUtxos(TxoState.Reserved)
|
||||||
dlcOpt <- dlcWalletB.findDLC(dlcId)
|
dlcOpt <- dlcWalletB.findDLC(dlcId)
|
||||||
} yield {
|
} yield {
|
||||||
assert(balance == oldBalance)
|
assert(balance == oldBalance)
|
||||||
|
@ -648,13 +648,13 @@ class WalletDLCSetupTest extends BitcoinSDualWalletTest {
|
||||||
|
|
||||||
for {
|
for {
|
||||||
oldBalanceA <- dlcWalletA.getBalance()
|
oldBalanceA <- dlcWalletA.getBalance()
|
||||||
oldReservedA <- walletApiA.utxoHandling.listUtxos(
|
oldReservedA <- walletApiA.utxoHandling.getUtxos(
|
||||||
TxoState.Reserved
|
TxoState.Reserved
|
||||||
)
|
)
|
||||||
_ = assert(oldReservedA.isEmpty)
|
_ = assert(oldReservedA.isEmpty)
|
||||||
|
|
||||||
oldBalanceB <- dlcWalletB.getBalance()
|
oldBalanceB <- dlcWalletB.getBalance()
|
||||||
oldReservedB <- walletApiB.utxoHandling.listUtxos(
|
oldReservedB <- walletApiB.utxoHandling.getUtxos(
|
||||||
TxoState.Reserved
|
TxoState.Reserved
|
||||||
)
|
)
|
||||||
_ = assert(oldReservedB.isEmpty)
|
_ = assert(oldReservedB.isEmpty)
|
||||||
|
@ -679,11 +679,11 @@ class WalletDLCSetupTest extends BitcoinSDualWalletTest {
|
||||||
_ <- dlcWalletB.cancelDLC(dlcId)
|
_ <- dlcWalletB.cancelDLC(dlcId)
|
||||||
|
|
||||||
balanceA <- dlcWalletA.getBalance()
|
balanceA <- dlcWalletA.getBalance()
|
||||||
reservedA <- walletApiA.utxoHandling.listUtxos(TxoState.Reserved)
|
reservedA <- walletApiA.utxoHandling.getUtxos(TxoState.Reserved)
|
||||||
dlcAOpt <- dlcWalletA.findDLC(dlcId)
|
dlcAOpt <- dlcWalletA.findDLC(dlcId)
|
||||||
|
|
||||||
balanceB <- dlcWalletB.getBalance()
|
balanceB <- dlcWalletB.getBalance()
|
||||||
reservedB <- walletApiB.utxoHandling.listUtxos(TxoState.Reserved)
|
reservedB <- walletApiB.utxoHandling.getUtxos(TxoState.Reserved)
|
||||||
dlcBOpt <- dlcWalletB.findDLC(dlcId)
|
dlcBOpt <- dlcWalletB.findDLC(dlcId)
|
||||||
} yield {
|
} yield {
|
||||||
assert(balanceA == oldBalanceA)
|
assert(balanceA == oldBalanceA)
|
||||||
|
|
|
@ -502,7 +502,7 @@ case class DLCTransactionProcessing(
|
||||||
): Future[Vector[ScriptSignatureParams[InputInfo]]] = {
|
): Future[Vector[ScriptSignatureParams[InputInfo]]] = {
|
||||||
val outPoints =
|
val outPoints =
|
||||||
fundingInputs.filter(_.isInitiator == dlcDb.isInitiator).map(_.outPoint)
|
fundingInputs.filter(_.isInitiator == dlcDb.isInitiator).map(_.outPoint)
|
||||||
val utxosF = utxoHandling.listUtxos(outPoints)
|
val utxosF = utxoHandling.getUtxos(outPoints)
|
||||||
for {
|
for {
|
||||||
utxos <- utxosF
|
utxos <- utxosF
|
||||||
map = SpendingInfoDb.toPreviousOutputMap(utxos)
|
map = SpendingInfoDb.toPreviousOutputMap(utxos)
|
||||||
|
|
|
@ -189,7 +189,7 @@ the `-p 9999:9999` port mapping on the docker container to adjust for this.
|
||||||
- `getaddressinfo` `address` - Returns list of all wallet accounts
|
- `getaddressinfo` `address` - Returns list of all wallet accounts
|
||||||
- `address` - Address to get information about
|
- `address` - Address to get information about
|
||||||
- `getnewaddress` - Get a new address
|
- `getnewaddress` - Get a new address
|
||||||
- `listreservedutxos` - lists all utxos that are reserved in the wallet
|
- `getreservedutxos` - lists all utxos that are reserved in the wallet
|
||||||
- `sendtoaddress` `address` `amount` `[options]` - Send money to the given address
|
- `sendtoaddress` `address` `amount` `[options]` - Send money to the given address
|
||||||
- `address` - Address to send to
|
- `address` - Address to send to
|
||||||
- `amount` - Amount to send in BTC
|
- `amount` - Amount to send in BTC
|
||||||
|
|
|
@ -3,14 +3,14 @@ title: Wallet RPC Examples
|
||||||
id: wallet-rpc
|
id: wallet-rpc
|
||||||
---
|
---
|
||||||
|
|
||||||
### `listreservedutxos`
|
### `getreservedutxos`
|
||||||
|
|
||||||
Lists all reserved utxos in the wallet.
|
Lists all reserved utxos in the wallet.
|
||||||
These utxos will not be unreserved unless you manually
|
These utxos will not be unreserved unless you manually
|
||||||
unreserve them with `lockunspent` or they are spent in the blockchain
|
unreserve them with `lockunspent` or they are spent in the blockchain
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bitcoin-s-cli listreservedutxos
|
bitcoin-s-cli getreservedutxos
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"outpoint": {
|
"outpoint": {
|
||||||
|
|
|
@ -60,8 +60,8 @@ class NeutrinoNodeWithWalletTest extends NodeTestWithCachedBitcoindNewest {
|
||||||
): Future[Boolean] = {
|
): Future[Boolean] = {
|
||||||
for {
|
for {
|
||||||
balance <- wallet.getBalance()
|
balance <- wallet.getBalance()
|
||||||
addresses <- wallet.addressHandling.listAddresses()
|
addresses <- wallet.addressHandling.getAddresses()
|
||||||
utxos <- wallet.utxoHandling.listUtxos()
|
utxos <- wallet.utxoHandling.getUtxos()
|
||||||
} yield {
|
} yield {
|
||||||
// +- fee rate because signatures could vary in size
|
// +- fee rate because signatures could vary in size
|
||||||
(expectedBalance === balance +- FeeRate.currencyUnit) &&
|
(expectedBalance === balance +- FeeRate.currencyUnit) &&
|
||||||
|
@ -174,8 +174,8 @@ class NeutrinoNodeWithWalletTest extends NodeTestWithCachedBitcoindNewest {
|
||||||
for {
|
for {
|
||||||
rescan <- wallet.isRescanning()
|
rescan <- wallet.isRescanning()
|
||||||
balance <- wallet.getBalance()
|
balance <- wallet.getBalance()
|
||||||
addresses <- wallet.addressHandling.listAddresses()
|
addresses <- wallet.addressHandling.getAddresses()
|
||||||
utxos <- wallet.utxoHandling.listUtxos()
|
utxos <- wallet.utxoHandling.getUtxos()
|
||||||
spks = utxos
|
spks = utxos
|
||||||
.map(_.output.scriptPubKey)
|
.map(_.output.scriptPubKey)
|
||||||
} yield {
|
} yield {
|
||||||
|
@ -187,8 +187,8 @@ class NeutrinoNodeWithWalletTest extends NodeTestWithCachedBitcoindNewest {
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
addresses <- wallet.addressHandling.listAddresses()
|
addresses <- wallet.addressHandling.getAddresses()
|
||||||
utxos <- wallet.utxoHandling.listUtxos()
|
utxos <- wallet.utxoHandling.getUtxos()
|
||||||
_ = assert(addresses.size == 3)
|
_ = assert(addresses.size == 3)
|
||||||
_ = assert(utxos.size == 3)
|
_ = assert(utxos.size == 3)
|
||||||
|
|
||||||
|
@ -197,8 +197,8 @@ class NeutrinoNodeWithWalletTest extends NodeTestWithCachedBitcoindNewest {
|
||||||
bitcoind
|
bitcoind
|
||||||
.sendToAddress(address, TestAmount)
|
.sendToAddress(address, TestAmount)
|
||||||
|
|
||||||
addresses <- wallet.addressHandling.listAddresses()
|
addresses <- wallet.addressHandling.getAddresses()
|
||||||
utxos <- wallet.utxoHandling.listUtxos()
|
utxos <- wallet.utxoHandling.getUtxos()
|
||||||
_ = assert(addresses.size == 4)
|
_ = assert(addresses.size == 4)
|
||||||
_ = assert(utxos.size == 3)
|
_ = assert(utxos.size == 3)
|
||||||
_ <-
|
_ <-
|
||||||
|
@ -213,8 +213,8 @@ class NeutrinoNodeWithWalletTest extends NodeTestWithCachedBitcoindNewest {
|
||||||
.map(_.get.height == bitcoindHeight)
|
.map(_.get.height == bitcoindHeight)
|
||||||
})
|
})
|
||||||
_ <- wallet.utxoHandling.clearAllUtxos()
|
_ <- wallet.utxoHandling.clearAllUtxos()
|
||||||
addresses <- wallet.addressHandling.listAddresses()
|
addresses <- wallet.addressHandling.getAddresses()
|
||||||
utxos <- wallet.utxoHandling.listUtxos()
|
utxos <- wallet.utxoHandling.getUtxos()
|
||||||
_ = assert(addresses.nonEmpty)
|
_ = assert(addresses.nonEmpty)
|
||||||
_ = assert(utxos.isEmpty)
|
_ = assert(utxos.isEmpty)
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ class AddressHandlingTest extends BitcoinSWalletTest {
|
||||||
val addressF = wallet.accountHandling.getNewAddress(account1)
|
val addressF = wallet.accountHandling.getNewAddress(account1)
|
||||||
for {
|
for {
|
||||||
address <- addressF
|
address <- addressF
|
||||||
listAddressesForAcct <- wallet.accountHandling.listAddresses(account1)
|
listAddressesForAcct <- wallet.accountHandling.getAddresses(account1)
|
||||||
exists <- wallet.addressHandling.contains(
|
exists <- wallet.addressHandling.contains(
|
||||||
address,
|
address,
|
||||||
Some((wallet.accountHandling, account1)))
|
Some((wallet.accountHandling, account1)))
|
||||||
|
@ -109,7 +109,7 @@ class AddressHandlingTest extends BitcoinSWalletTest {
|
||||||
val wallet = fundedWallet.wallet
|
val wallet = fundedWallet.wallet
|
||||||
|
|
||||||
for {
|
for {
|
||||||
emptySpentAddresses <- wallet.addressHandling.listSpentAddresses()
|
emptySpentAddresses <- wallet.addressHandling.getSpentAddresses()
|
||||||
_ = assert(
|
_ = assert(
|
||||||
emptySpentAddresses.isEmpty,
|
emptySpentAddresses.isEmpty,
|
||||||
s"Wallet did not start with empty spent addresses, got $emptySpentAddresses"
|
s"Wallet did not start with empty spent addresses, got $emptySpentAddresses"
|
||||||
|
@ -120,7 +120,7 @@ class AddressHandlingTest extends BitcoinSWalletTest {
|
||||||
Bitcoins(1),
|
Bitcoins(1),
|
||||||
None)
|
None)
|
||||||
spentDbs <- wallet.utxoHandling.findOutputsBeingSpent(tx)
|
spentDbs <- wallet.utxoHandling.findOutputsBeingSpent(tx)
|
||||||
spentAddresses <- wallet.addressHandling.listSpentAddresses()
|
spentAddresses <- wallet.addressHandling.getSpentAddresses()
|
||||||
} yield {
|
} yield {
|
||||||
val diff = spentDbs
|
val diff = spentDbs
|
||||||
.map(_.output.scriptPubKey)
|
.map(_.output.scriptPubKey)
|
||||||
|
@ -134,8 +134,8 @@ class AddressHandlingTest extends BitcoinSWalletTest {
|
||||||
val wallet = fundedWallet.wallet
|
val wallet = fundedWallet.wallet
|
||||||
|
|
||||||
for {
|
for {
|
||||||
unspentDbs <- wallet.utxoHandling.listUtxos()
|
unspentDbs <- wallet.utxoHandling.getUtxos()
|
||||||
fundedAddresses <- wallet.addressHandling.listFundedAddresses()
|
fundedAddresses <- wallet.addressHandling.getFundedAddresses()
|
||||||
} yield {
|
} yield {
|
||||||
val diff = unspentDbs
|
val diff = unspentDbs
|
||||||
.map(_.output)
|
.map(_.output)
|
||||||
|
@ -154,7 +154,7 @@ class AddressHandlingTest extends BitcoinSWalletTest {
|
||||||
SpendingInfoDAO()(executionContext, fundedWallet.walletConfig)
|
SpendingInfoDAO()(executionContext, fundedWallet.walletConfig)
|
||||||
for {
|
for {
|
||||||
addrDbs <- spendingInfoDAO.findAllSpendingInfos()
|
addrDbs <- spendingInfoDAO.findAllSpendingInfos()
|
||||||
fundedAddresses <- wallet.addressHandling.listUnusedAddresses()
|
fundedAddresses <- wallet.addressHandling.getUnusedAddresses()
|
||||||
} yield {
|
} yield {
|
||||||
val intersect = addrDbs
|
val intersect = addrDbs
|
||||||
.map(_.output.scriptPubKey)
|
.map(_.output.scriptPubKey)
|
||||||
|
@ -241,9 +241,9 @@ class AddressHandlingTest extends BitcoinSWalletTest {
|
||||||
val wallet = fundedWallet.wallet
|
val wallet = fundedWallet.wallet
|
||||||
val spk = EmptyScriptPubKey
|
val spk = EmptyScriptPubKey
|
||||||
for {
|
for {
|
||||||
before <- wallet.addressHandling.listScriptPubKeys()
|
before <- wallet.addressHandling.getScriptPubKeys()
|
||||||
spkDb <- wallet.addressHandling.watchScriptPubKey(spk)
|
spkDb <- wallet.addressHandling.watchScriptPubKey(spk)
|
||||||
after <- wallet.addressHandling.listScriptPubKeys()
|
after <- wallet.addressHandling.getScriptPubKeys()
|
||||||
} yield {
|
} yield {
|
||||||
assert(before.size + 1 == after.size)
|
assert(before.size + 1 == after.size)
|
||||||
assert(spkDb.scriptPubKey == spk)
|
assert(spkDb.scriptPubKey == spk)
|
||||||
|
@ -302,7 +302,7 @@ class AddressHandlingTest extends BitcoinSWalletTest {
|
||||||
|
|
||||||
for {
|
for {
|
||||||
addr <- addrF
|
addr <- addrF
|
||||||
addresses <- wallet.addressHandling.listAddresses()
|
addresses <- wallet.addressHandling.getAddresses()
|
||||||
} yield {
|
} yield {
|
||||||
assert(!addresses.exists(_.address == addr))
|
assert(!addresses.exists(_.address == addr))
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ class AddressTagIntegrationTest extends BitcoinSWalletTest {
|
||||||
tx <- bitcoind.getRawTransactionRaw(txId)
|
tx <- bitcoind.getRawTransactionRaw(txId)
|
||||||
|
|
||||||
// before processing TX, wallet should be completely empty
|
// before processing TX, wallet should be completely empty
|
||||||
_ <- wallet.utxoHandling.listUtxos().map(utxos => assert(utxos.isEmpty))
|
_ <- wallet.utxoHandling.getUtxos().map(utxos => assert(utxos.isEmpty))
|
||||||
_ <- wallet.getBalance().map(confirmed => assert(confirmed == 0.bitcoin))
|
_ <- wallet.getBalance().map(confirmed => assert(confirmed == 0.bitcoin))
|
||||||
_ <-
|
_ <-
|
||||||
wallet
|
wallet
|
||||||
|
@ -60,7 +60,7 @@ class AddressTagIntegrationTest extends BitcoinSWalletTest {
|
||||||
|
|
||||||
// we should now have one UTXO in the wallet
|
// we should now have one UTXO in the wallet
|
||||||
// it should not be confirmed
|
// it should not be confirmed
|
||||||
utxosPostAdd <- wallet.utxoHandling.listUtxos()
|
utxosPostAdd <- wallet.utxoHandling.getUtxos()
|
||||||
_ = assert(utxosPostAdd.length == 2)
|
_ = assert(utxosPostAdd.length == 2)
|
||||||
_ <-
|
_ <-
|
||||||
wallet
|
wallet
|
||||||
|
@ -74,7 +74,7 @@ class AddressTagIntegrationTest extends BitcoinSWalletTest {
|
||||||
_ = assert(incomingTx.isDefined)
|
_ = assert(incomingTx.isDefined)
|
||||||
_ = assert(incomingTx.get.incomingAmount == valueFromBitcoind * 2)
|
_ = assert(incomingTx.get.incomingAmount == valueFromBitcoind * 2)
|
||||||
|
|
||||||
taggedUtxosPostAdd <- wallet.utxoHandling.listUtxos(exampleTag)
|
taggedUtxosPostAdd <- wallet.utxoHandling.getUtxos(exampleTag)
|
||||||
_ = assert(taggedUtxosPostAdd.length == 1)
|
_ = assert(taggedUtxosPostAdd.length == 1)
|
||||||
_ <-
|
_ <-
|
||||||
wallet.utxoHandling
|
wallet.utxoHandling
|
||||||
|
@ -95,7 +95,7 @@ class AddressTagIntegrationTest extends BitcoinSWalletTest {
|
||||||
signedTx = rawTxHelper.signedTx
|
signedTx = rawTxHelper.signedTx
|
||||||
_ <- wallet.transactionProcessing.processTransaction(signedTx, None)
|
_ <- wallet.transactionProcessing.processTransaction(signedTx, None)
|
||||||
|
|
||||||
utxos <- wallet.utxoHandling.listUtxos()
|
utxos <- wallet.utxoHandling.getUtxos()
|
||||||
balancePostSend <- wallet.getBalance()
|
balancePostSend <- wallet.getBalance()
|
||||||
tagBalancePostSend <- wallet.utxoHandling.getBalance(exampleTag)
|
tagBalancePostSend <- wallet.utxoHandling.getBalance(exampleTag)
|
||||||
} yield {
|
} yield {
|
||||||
|
|
|
@ -109,7 +109,7 @@ class BitcoindBackendTest extends WalletAppConfigWithBitcoindNewestFixtures {
|
||||||
|
|
||||||
_ <- BitcoindRpcBackendUtil.syncWalletToBitcoind(bitcoind, wallet, None)
|
_ <- BitcoindRpcBackendUtil.syncWalletToBitcoind(bitcoind, wallet, None)
|
||||||
|
|
||||||
utxos <- wallet.utxoHandling.listUtxos(TxoState.ConfirmedReceived)
|
utxos <- wallet.utxoHandling.getUtxos(TxoState.ConfirmedReceived)
|
||||||
} yield {
|
} yield {
|
||||||
assert(utxos.size == 1)
|
assert(utxos.size == 1)
|
||||||
val utxo = utxos.head
|
val utxo = utxos.head
|
||||||
|
|
|
@ -218,7 +218,7 @@ class FundTransactionHandlingTest
|
||||||
val bitcoind = fundedWallet.bitcoind
|
val bitcoind = fundedWallet.bitcoind
|
||||||
val fundedTxF = for {
|
val fundedTxF = for {
|
||||||
feeRate <- wallet.getFeeRate()
|
feeRate <- wallet.getFeeRate()
|
||||||
accounts <- wallet.accountHandling.listAccounts()
|
accounts <- wallet.accountHandling.getAccounts()
|
||||||
account2 = accounts.find(_.hdAccount.index == 2).get
|
account2 = accounts.find(_.hdAccount.index == 2).get
|
||||||
|
|
||||||
addr <- wallet.accountHandling.getNewAddress(account2)
|
addr <- wallet.accountHandling.getNewAddress(account2)
|
||||||
|
@ -227,7 +227,7 @@ class FundTransactionHandlingTest
|
||||||
block <- bitcoind.getBlockRaw(hash)
|
block <- bitcoind.getBlockRaw(hash)
|
||||||
_ <- wallet.transactionProcessing.processBlock(block)
|
_ <- wallet.transactionProcessing.processBlock(block)
|
||||||
|
|
||||||
utxos <- wallet.utxoHandling.listUtxos(account2.hdAccount)
|
utxos <- wallet.utxoHandling.getUtxos(account2.hdAccount)
|
||||||
_ = assert(utxos.size == 1)
|
_ = assert(utxos.size == 1)
|
||||||
|
|
||||||
fundedTx <-
|
fundedTx <-
|
||||||
|
@ -259,7 +259,7 @@ class FundTransactionHandlingTest
|
||||||
spendingInfos <- wallet.utxoHandling.findOutputsBeingSpent(
|
spendingInfos <- wallet.utxoHandling.findOutputsBeingSpent(
|
||||||
fundRawTxHelper.unsignedTx
|
fundRawTxHelper.unsignedTx
|
||||||
)
|
)
|
||||||
reserved <- wallet.utxoHandling.listUtxos(TxoState.Reserved)
|
reserved <- wallet.utxoHandling.getUtxos(TxoState.Reserved)
|
||||||
} yield {
|
} yield {
|
||||||
assert(spendingInfos.exists(_.state == TxoState.Reserved))
|
assert(spendingInfos.exists(_.state == TxoState.Reserved))
|
||||||
assert(reserved.size == spendingInfos.size)
|
assert(reserved.size == spendingInfos.size)
|
||||||
|
@ -280,7 +280,7 @@ class FundTransactionHandlingTest
|
||||||
taggedBalance <- wallet.utxoHandling.getBalance(tag)
|
taggedBalance <- wallet.utxoHandling.getBalance(tag)
|
||||||
_ = assert(taggedBalance == destination.value * 2)
|
_ = assert(taggedBalance == destination.value * 2)
|
||||||
|
|
||||||
expectedUtxos <- wallet.utxoHandling.listUtxos(tag)
|
expectedUtxos <- wallet.utxoHandling.getUtxos(tag)
|
||||||
fundRawTxHelper <-
|
fundRawTxHelper <-
|
||||||
wallet.fundTxHandling
|
wallet.fundTxHandling
|
||||||
.fundRawTransaction(
|
.fundRawTransaction(
|
||||||
|
|
|
@ -18,7 +18,7 @@ class LegacyWalletTest extends BitcoinSWalletTest {
|
||||||
account <- wallet.accountHandling.getDefaultAccount()
|
account <- wallet.accountHandling.getDefaultAccount()
|
||||||
otherAddr <- wallet.getNewAddress()
|
otherAddr <- wallet.getNewAddress()
|
||||||
thirdAddr <- wallet.addressHandling.getNewAddress(AddressType.Legacy)
|
thirdAddr <- wallet.addressHandling.getNewAddress(AddressType.Legacy)
|
||||||
allAddrs <- wallet.addressHandling.listAddresses()
|
allAddrs <- wallet.addressHandling.getAddresses()
|
||||||
} yield {
|
} yield {
|
||||||
assert(account.hdAccount.purpose == HDPurpose.Legacy)
|
assert(account.hdAccount.purpose == HDPurpose.Legacy)
|
||||||
assert(allAddrs.forall(_.address.isInstanceOf[P2PKHAddress]))
|
assert(allAddrs.forall(_.address.isInstanceOf[P2PKHAddress]))
|
||||||
|
|
|
@ -42,7 +42,7 @@ class ProcessBlockTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
val bitcoind = param.bitcoind
|
val bitcoind = param.bitcoind
|
||||||
|
|
||||||
for {
|
for {
|
||||||
startingUtxos <- wallet.utxoHandling.listUtxos()
|
startingUtxos <- wallet.utxoHandling.getUtxos()
|
||||||
_ = assert(startingUtxos.isEmpty)
|
_ = assert(startingUtxos.isEmpty)
|
||||||
|
|
||||||
addr <- wallet.getNewAddress()
|
addr <- wallet.getNewAddress()
|
||||||
|
@ -54,7 +54,7 @@ class ProcessBlockTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
block <- bitcoind.getBlockRaw(hash)
|
block <- bitcoind.getBlockRaw(hash)
|
||||||
|
|
||||||
_ <- wallet.transactionProcessing.processBlock(block)
|
_ <- wallet.transactionProcessing.processBlock(block)
|
||||||
utxos <- wallet.utxoHandling.listUtxos()
|
utxos <- wallet.utxoHandling.getUtxos()
|
||||||
height <- bitcoind.getBlockCount()
|
height <- bitcoind.getBlockCount()
|
||||||
bestHash <- bitcoind.getBestBlockHash()
|
bestHash <- bitcoind.getBestBlockHash()
|
||||||
syncHeightOpt <- wallet.getSyncDescriptorOpt()
|
syncHeightOpt <- wallet.getSyncDescriptorOpt()
|
||||||
|
@ -74,7 +74,7 @@ class ProcessBlockTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
val wallet = param.wallet
|
val wallet = param.wallet
|
||||||
val bitcoind = param.bitcoind
|
val bitcoind = param.bitcoind
|
||||||
for {
|
for {
|
||||||
startingUtxos <- wallet.utxoHandling.listUtxos(TxoState.ImmatureCoinbase)
|
startingUtxos <- wallet.utxoHandling.getUtxos(TxoState.ImmatureCoinbase)
|
||||||
startingBalance <- wallet.getBalance()
|
startingBalance <- wallet.getBalance()
|
||||||
_ = assert(startingUtxos.isEmpty)
|
_ = assert(startingUtxos.isEmpty)
|
||||||
_ = assert(startingBalance == Satoshis.zero)
|
_ = assert(startingBalance == Satoshis.zero)
|
||||||
|
@ -83,9 +83,8 @@ class ProcessBlockTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
blocks <- FutureUtil.sequentially(hashes)(bitcoind.getBlockRaw)
|
blocks <- FutureUtil.sequentially(hashes)(bitcoind.getBlockRaw)
|
||||||
_ <- FutureUtil.sequentially(blocks)(
|
_ <- FutureUtil.sequentially(blocks)(
|
||||||
wallet.transactionProcessing.processBlock)
|
wallet.transactionProcessing.processBlock)
|
||||||
coinbaseUtxos <- wallet.utxoHandling.listUtxos(TxoState.ImmatureCoinbase)
|
coinbaseUtxos <- wallet.utxoHandling.getUtxos(TxoState.ImmatureCoinbase)
|
||||||
confirmedUtxos <- wallet.utxoHandling.listUtxos(
|
confirmedUtxos <- wallet.utxoHandling.getUtxos(TxoState.ConfirmedReceived)
|
||||||
TxoState.ConfirmedReceived)
|
|
||||||
balance <- wallet.getConfirmedBalance()
|
balance <- wallet.getConfirmedBalance()
|
||||||
|
|
||||||
height <- bitcoind.getBlockCount()
|
height <- bitcoind.getBlockCount()
|
||||||
|
@ -108,7 +107,7 @@ class ProcessBlockTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
val bitcoind = param.bitcoind
|
val bitcoind = param.bitcoind
|
||||||
|
|
||||||
for {
|
for {
|
||||||
startingUtxos <- wallet.utxoHandling.listUtxos(TxoState.ImmatureCoinbase)
|
startingUtxos <- wallet.utxoHandling.getUtxos(TxoState.ImmatureCoinbase)
|
||||||
startingBalance <- wallet.getBalance()
|
startingBalance <- wallet.getBalance()
|
||||||
_ = assert(startingUtxos.isEmpty)
|
_ = assert(startingUtxos.isEmpty)
|
||||||
_ = assert(startingBalance == Satoshis.zero)
|
_ = assert(startingBalance == Satoshis.zero)
|
||||||
|
@ -119,9 +118,8 @@ class ProcessBlockTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
)
|
)
|
||||||
filtersWithBlockHash = hashes.zip(filters.map(_.filter))
|
filtersWithBlockHash = hashes.zip(filters.map(_.filter))
|
||||||
_ <- wallet.processCompactFilters(filtersWithBlockHash)
|
_ <- wallet.processCompactFilters(filtersWithBlockHash)
|
||||||
coinbaseUtxos <- wallet.utxoHandling.listUtxos(TxoState.ImmatureCoinbase)
|
coinbaseUtxos <- wallet.utxoHandling.getUtxos(TxoState.ImmatureCoinbase)
|
||||||
confirmedUtxos <- wallet.utxoHandling.listUtxos(
|
confirmedUtxos <- wallet.utxoHandling.getUtxos(TxoState.ConfirmedReceived)
|
||||||
TxoState.ConfirmedReceived)
|
|
||||||
balance <- wallet.getConfirmedBalance()
|
balance <- wallet.getConfirmedBalance()
|
||||||
|
|
||||||
height <- bitcoind.getBlockCount()
|
height <- bitcoind.getBlockCount()
|
||||||
|
|
|
@ -34,12 +34,12 @@ class ProcessTransactionTest extends BitcoinSWalletTest {
|
||||||
)(action: => Future[_]): Future[Assertion] =
|
)(action: => Future[_]): Future[Assertion] =
|
||||||
for {
|
for {
|
||||||
oldTransactions <- wallet.transactionProcessing.listTransactions()
|
oldTransactions <- wallet.transactionProcessing.listTransactions()
|
||||||
oldUtxos <- wallet.utxoHandling.listUtxos()
|
oldUtxos <- wallet.utxoHandling.getUtxos()
|
||||||
oldUnconfirmed <- wallet.getUnconfirmedBalance()
|
oldUnconfirmed <- wallet.getUnconfirmedBalance()
|
||||||
oldConfirmed <- wallet.getBalance()
|
oldConfirmed <- wallet.getBalance()
|
||||||
_ <- action // by name
|
_ <- action // by name
|
||||||
newTransactions <- wallet.transactionProcessing.listTransactions()
|
newTransactions <- wallet.transactionProcessing.listTransactions()
|
||||||
newUtxos <- wallet.utxoHandling.listUtxos()
|
newUtxos <- wallet.utxoHandling.getUtxos()
|
||||||
newUnconfirmed <- wallet.getUnconfirmedBalance()
|
newUnconfirmed <- wallet.getUnconfirmedBalance()
|
||||||
newConfirmed <- wallet.getBalance()
|
newConfirmed <- wallet.getBalance()
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ class ProcessTransactionTest extends BitcoinSWalletTest {
|
||||||
)
|
)
|
||||||
newConfirmed <- wallet.getConfirmedBalance()
|
newConfirmed <- wallet.getConfirmedBalance()
|
||||||
newUnconfirmed <- wallet.getUnconfirmedBalance()
|
newUnconfirmed <- wallet.getUnconfirmedBalance()
|
||||||
utxosPostAdd <- wallet.utxoHandling.listUtxos()
|
utxosPostAdd <- wallet.utxoHandling.getUtxos()
|
||||||
|
|
||||||
// repeating the action should not make a difference
|
// repeating the action should not make a difference
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ class ProcessTransactionTest extends BitcoinSWalletTest {
|
||||||
_ <- wallet.transactionProcessing.processTransaction(tx, None)
|
_ <- wallet.transactionProcessing.processTransaction(tx, None)
|
||||||
newConfirmed <- wallet.getConfirmedBalance()
|
newConfirmed <- wallet.getConfirmedBalance()
|
||||||
newUnconfirmed <- wallet.getUnconfirmedBalance()
|
newUnconfirmed <- wallet.getUnconfirmedBalance()
|
||||||
utxosPostAdd <- wallet.utxoHandling.listUtxos()
|
utxosPostAdd <- wallet.utxoHandling.getUtxos()
|
||||||
|
|
||||||
// repeating the action should not make a difference
|
// repeating the action should not make a difference
|
||||||
_ <- checkUtxosAndBalance(wallet) {
|
_ <- checkUtxosAndBalance(wallet) {
|
||||||
|
|
|
@ -28,16 +28,16 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
for {
|
for {
|
||||||
accountDb <- wallet.accountHandling.getDefaultAccount()
|
accountDb <- wallet.accountHandling.getDefaultAccount()
|
||||||
account = accountDb.hdAccount
|
account = accountDb.hdAccount
|
||||||
utxos <- wallet.utxoHandling.listUtxos(account)
|
utxos <- wallet.utxoHandling.getUtxos(account)
|
||||||
_ = assert(utxos.nonEmpty)
|
_ = assert(utxos.nonEmpty)
|
||||||
|
|
||||||
addresses <- wallet.accountHandling.listAddresses(account)
|
addresses <- wallet.accountHandling.getAddresses(account)
|
||||||
_ = assert(addresses.nonEmpty)
|
_ = assert(addresses.nonEmpty)
|
||||||
|
|
||||||
_ <- wallet.accountHandling.clearUtxos(account)
|
_ <- wallet.accountHandling.clearUtxos(account)
|
||||||
|
|
||||||
clearedUtxos <- wallet.utxoHandling.listUtxos(account)
|
clearedUtxos <- wallet.utxoHandling.getUtxos(account)
|
||||||
clearedAddresses <- wallet.accountHandling.listAddresses(account)
|
clearedAddresses <- wallet.accountHandling.getAddresses(account)
|
||||||
} yield {
|
} yield {
|
||||||
assert(clearedUtxos.isEmpty)
|
assert(clearedUtxos.isEmpty)
|
||||||
assert(clearedAddresses.nonEmpty)
|
assert(clearedAddresses.nonEmpty)
|
||||||
|
@ -51,16 +51,16 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
for {
|
for {
|
||||||
balance <- wallet.getBalance()
|
balance <- wallet.getBalance()
|
||||||
_ = assert(balance != Satoshis.zero)
|
_ = assert(balance != Satoshis.zero)
|
||||||
utxos <- wallet.utxoHandling.listUtxos()
|
utxos <- wallet.utxoHandling.getUtxos()
|
||||||
_ = assert(utxos.nonEmpty)
|
_ = assert(utxos.nonEmpty)
|
||||||
|
|
||||||
addresses <- wallet.addressHandling.listAddresses()
|
addresses <- wallet.addressHandling.getAddresses()
|
||||||
_ = assert(addresses.nonEmpty)
|
_ = assert(addresses.nonEmpty)
|
||||||
|
|
||||||
_ <- wallet.utxoHandling.clearAllUtxos()
|
_ <- wallet.utxoHandling.clearAllUtxos()
|
||||||
|
|
||||||
clearedUtxos <- wallet.utxoHandling.listUtxos()
|
clearedUtxos <- wallet.utxoHandling.getUtxos()
|
||||||
clearedAddresses <- wallet.addressHandling.listAddresses()
|
clearedAddresses <- wallet.addressHandling.getAddresses()
|
||||||
} yield {
|
} yield {
|
||||||
assert(clearedUtxos.isEmpty)
|
assert(clearedUtxos.isEmpty)
|
||||||
assert(clearedAddresses.nonEmpty)
|
assert(clearedAddresses.nonEmpty)
|
||||||
|
@ -200,7 +200,7 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
account <- defaultAccountF
|
account <- defaultAccountF
|
||||||
txIds <-
|
txIds <-
|
||||||
wallet.utxoHandling
|
wallet.utxoHandling
|
||||||
.listUtxos(account.hdAccount)
|
.getUtxos(account.hdAccount)
|
||||||
.map(_.map(_.txid))
|
.map(_.map(_.txid))
|
||||||
_ <- wallet.transactionProcessing
|
_ <- wallet.transactionProcessing
|
||||||
.findByTxIds(txIds)
|
.findByTxIds(txIds)
|
||||||
|
@ -285,7 +285,7 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
val initBalanceF = wallet.getBalance()
|
val initBalanceF = wallet.getBalance()
|
||||||
|
|
||||||
// find the first block a utxo was created in
|
// find the first block a utxo was created in
|
||||||
val utxosF = wallet.utxoHandling.listUtxos()
|
val utxosF = wallet.utxoHandling.getUtxos()
|
||||||
val oldestHeightF = for {
|
val oldestHeightF = for {
|
||||||
utxos <- utxosF
|
utxos <- utxosF
|
||||||
blockhashes <- wallet.transactionProcessing
|
blockhashes <- wallet.transactionProcessing
|
||||||
|
@ -373,7 +373,7 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
force = false
|
force = false
|
||||||
)
|
)
|
||||||
|
|
||||||
usedAddresses <- wallet.addressHandling.listFundedAddresses()
|
usedAddresses <- wallet.addressHandling.getFundedAddresses()
|
||||||
|
|
||||||
_ = assert(
|
_ = assert(
|
||||||
!usedAddresses.exists(_._1.address == address),
|
!usedAddresses.exists(_._1.address == address),
|
||||||
|
@ -383,8 +383,8 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
hashes <- bitcoind.generateToAddress(1, address)
|
hashes <- bitcoind.generateToAddress(1, address)
|
||||||
block <- bitcoind.getBlockRaw(hashes.head)
|
block <- bitcoind.getBlockRaw(hashes.head)
|
||||||
_ <- wallet.transactionProcessing.processBlock(block)
|
_ <- wallet.transactionProcessing.processBlock(block)
|
||||||
fundedAddresses <- wallet.addressHandling.listFundedAddresses()
|
fundedAddresses <- wallet.addressHandling.getFundedAddresses()
|
||||||
utxos <- wallet.utxoHandling.listUtxos(TxoState.ImmatureCoinbase)
|
utxos <- wallet.utxoHandling.getUtxos(TxoState.ImmatureCoinbase)
|
||||||
_ <- RescanState.awaitRescanDone(state)
|
_ <- RescanState.awaitRescanDone(state)
|
||||||
} yield {
|
} yield {
|
||||||
// note 25 bitcoin reward from coinbase tx here
|
// note 25 bitcoin reward from coinbase tx here
|
||||||
|
@ -561,7 +561,7 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
account <- defaultAccountF
|
account <- defaultAccountF
|
||||||
txIds <-
|
txIds <-
|
||||||
wallet.utxoHandling
|
wallet.utxoHandling
|
||||||
.listUtxos(account.hdAccount)
|
.getUtxos(account.hdAccount)
|
||||||
.map(_.map(_.txid))
|
.map(_.map(_.txid))
|
||||||
_ <- wallet.transactionProcessing
|
_ <- wallet.transactionProcessing
|
||||||
.findByTxIds(txIds)
|
.findByTxIds(txIds)
|
||||||
|
@ -597,7 +597,7 @@ class RescanHandlingTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
DEFAULT_ADDR_BATCH_SIZE)
|
DEFAULT_ADDR_BATCH_SIZE)
|
||||||
_ = assert(rescanState.isInstanceOf[RescanState.RescanStarted])
|
_ = assert(rescanState.isInstanceOf[RescanState.RescanStarted])
|
||||||
_ <- RescanState.awaitRescanDone(rescanState)
|
_ <- RescanState.awaitRescanDone(rescanState)
|
||||||
addresses <- wallet.addressHandling.listAddresses()
|
addresses <- wallet.addressHandling.getAddresses()
|
||||||
} yield {
|
} yield {
|
||||||
assert(addresses.exists(_.isChange))
|
assert(addresses.exists(_.isChange))
|
||||||
assert(addresses.exists(!_.isChange))
|
assert(addresses.exists(!_.isChange))
|
||||||
|
|
|
@ -19,7 +19,7 @@ class SegwitWalletTest extends BitcoinSWalletTest {
|
||||||
account <- wallet.accountHandling.getDefaultAccount()
|
account <- wallet.accountHandling.getDefaultAccount()
|
||||||
otherAddr <- wallet.getNewAddress()
|
otherAddr <- wallet.getNewAddress()
|
||||||
thirdAddr <- wallet.addressHandling.getNewAddress(AddressType.SegWit)
|
thirdAddr <- wallet.addressHandling.getNewAddress(AddressType.SegWit)
|
||||||
allAddrs <- wallet.addressHandling.listAddresses()
|
allAddrs <- wallet.addressHandling.getAddresses()
|
||||||
} yield {
|
} yield {
|
||||||
assert(account.hdAccount.purpose == HDPurpose.SegWit)
|
assert(account.hdAccount.purpose == HDPurpose.SegWit)
|
||||||
assert(allAddrs.forall(_.address.isInstanceOf[Bech32Address]))
|
assert(allAddrs.forall(_.address.isInstanceOf[Bech32Address]))
|
||||||
|
|
|
@ -243,14 +243,14 @@ class TrezorAddressTest extends BitcoinSWalletTest with EmptyFixture {
|
||||||
|
|
||||||
val assertionsF: Future[Seq[Assertion]] = for {
|
val assertionsF: Future[Seq[Assertion]] = for {
|
||||||
wallet <- getWallet(conf)
|
wallet <- getWallet(conf)
|
||||||
existingAccounts <- wallet.accountHandling.listAccounts(purpose)
|
existingAccounts <- wallet.accountHandling.getAccounts(purpose)
|
||||||
_ <- createNeededAccounts(
|
_ <- createNeededAccounts(
|
||||||
wallet,
|
wallet,
|
||||||
existingAccounts,
|
existingAccounts,
|
||||||
conf.kmParams,
|
conf.kmParams,
|
||||||
testVectors
|
testVectors
|
||||||
)
|
)
|
||||||
accounts <- wallet.accountHandling.listAccounts(purpose)
|
accounts <- wallet.accountHandling.getAccounts(purpose)
|
||||||
// we want to find all accounts for the given account type,
|
// we want to find all accounts for the given account type,
|
||||||
// and match it with its corresponding test vector
|
// and match it with its corresponding test vector
|
||||||
accountsWithVectors = {
|
accountsWithVectors = {
|
||||||
|
|
|
@ -127,7 +127,7 @@ class UTXOLifeCycleTest
|
||||||
addr2 <- wallet.getNewAddress()
|
addr2 <- wallet.getNewAddress()
|
||||||
addr3 <- wallet.getNewAddress()
|
addr3 <- wallet.getNewAddress()
|
||||||
|
|
||||||
oldUtxos <- wallet.utxoHandling.listUtxos()
|
oldUtxos <- wallet.utxoHandling.getUtxos()
|
||||||
|
|
||||||
txid1 <- bitcoind.sendToAddress(addr1, Satoshis(1000))
|
txid1 <- bitcoind.sendToAddress(addr1, Satoshis(1000))
|
||||||
txid2 <- bitcoind.sendToAddress(addr2, Satoshis(2000))
|
txid2 <- bitcoind.sendToAddress(addr2, Satoshis(2000))
|
||||||
|
@ -153,7 +153,7 @@ class UTXOLifeCycleTest
|
||||||
}
|
}
|
||||||
_ = assert(tx3.nonEmpty)
|
_ = assert(tx3.nonEmpty)
|
||||||
|
|
||||||
utxos <- wallet.utxoHandling.listUtxos()
|
utxos <- wallet.utxoHandling.getUtxos()
|
||||||
_ = assert(oldUtxos == utxos)
|
_ = assert(oldUtxos == utxos)
|
||||||
|
|
||||||
// process the transactions from mempool
|
// process the transactions from mempool
|
||||||
|
@ -161,7 +161,7 @@ class UTXOLifeCycleTest
|
||||||
_ <- wallet.transactionProcessing.processTransaction(tx2.get, None)
|
_ <- wallet.transactionProcessing.processTransaction(tx2.get, None)
|
||||||
_ <- wallet.transactionProcessing.processTransaction(tx3.get, None)
|
_ <- wallet.transactionProcessing.processTransaction(tx3.get, None)
|
||||||
|
|
||||||
utxos <- wallet.utxoHandling.listUtxos()
|
utxos <- wallet.utxoHandling.getUtxos()
|
||||||
_ = assert(oldUtxos.size + 3 == utxos.size)
|
_ = assert(oldUtxos.size + 3 == utxos.size)
|
||||||
|
|
||||||
_ = checkState(utxos, txid1, txid2, txid3, TxoState.BroadcastReceived)
|
_ = checkState(utxos, txid1, txid2, txid3, TxoState.BroadcastReceived)
|
||||||
|
@ -176,7 +176,7 @@ class UTXOLifeCycleTest
|
||||||
_ <- wallet.transactionProcessing.processBlock(block)
|
_ <- wallet.transactionProcessing.processBlock(block)
|
||||||
_ <- wallet.utxoHandling.updateUtxoPendingStates()
|
_ <- wallet.utxoHandling.updateUtxoPendingStates()
|
||||||
|
|
||||||
utxos <- wallet.utxoHandling.listUtxos()
|
utxos <- wallet.utxoHandling.getUtxos()
|
||||||
_ = assert(oldUtxos.size + 3 == utxos.size)
|
_ = assert(oldUtxos.size + 3 == utxos.size)
|
||||||
|
|
||||||
// mine the second block
|
// mine the second block
|
||||||
|
@ -187,7 +187,7 @@ class UTXOLifeCycleTest
|
||||||
_ <- wallet.transactionProcessing.processBlock(block)
|
_ <- wallet.transactionProcessing.processBlock(block)
|
||||||
_ <- wallet.utxoHandling.updateUtxoPendingStates()
|
_ <- wallet.utxoHandling.updateUtxoPendingStates()
|
||||||
|
|
||||||
utxos <- wallet.utxoHandling.listUtxos()
|
utxos <- wallet.utxoHandling.getUtxos()
|
||||||
_ = assert(oldUtxos.size + 3 == utxos.size)
|
_ = assert(oldUtxos.size + 3 == utxos.size)
|
||||||
|
|
||||||
_ = checkState(
|
_ = checkState(
|
||||||
|
@ -206,7 +206,7 @@ class UTXOLifeCycleTest
|
||||||
_ <- wallet.transactionProcessing.processBlock(block)
|
_ <- wallet.transactionProcessing.processBlock(block)
|
||||||
_ <- wallet.utxoHandling.updateUtxoPendingStates()
|
_ <- wallet.utxoHandling.updateUtxoPendingStates()
|
||||||
|
|
||||||
utxos <- wallet.utxoHandling.listUtxos()
|
utxos <- wallet.utxoHandling.getUtxos()
|
||||||
_ = assert(oldUtxos.size + 3 == utxos.size)
|
_ = assert(oldUtxos.size + 3 == utxos.size)
|
||||||
|
|
||||||
_ = checkState(
|
_ = checkState(
|
||||||
|
@ -225,7 +225,7 @@ class UTXOLifeCycleTest
|
||||||
_ <- wallet.transactionProcessing.processBlock(block)
|
_ <- wallet.transactionProcessing.processBlock(block)
|
||||||
_ <- wallet.utxoHandling.updateUtxoPendingStates()
|
_ <- wallet.utxoHandling.updateUtxoPendingStates()
|
||||||
|
|
||||||
utxos <- wallet.utxoHandling.listUtxos()
|
utxos <- wallet.utxoHandling.getUtxos()
|
||||||
_ = assert(oldUtxos.size + 3 == utxos.size)
|
_ = assert(oldUtxos.size + 3 == utxos.size)
|
||||||
|
|
||||||
_ = checkState(
|
_ = checkState(
|
||||||
|
@ -244,7 +244,7 @@ class UTXOLifeCycleTest
|
||||||
_ <- wallet.transactionProcessing.processBlock(block)
|
_ <- wallet.transactionProcessing.processBlock(block)
|
||||||
_ <- wallet.utxoHandling.updateUtxoPendingStates()
|
_ <- wallet.utxoHandling.updateUtxoPendingStates()
|
||||||
|
|
||||||
utxos <- wallet.utxoHandling.listUtxos()
|
utxos <- wallet.utxoHandling.getUtxos()
|
||||||
_ = assert(oldUtxos.size + 3 == utxos.size)
|
_ = assert(oldUtxos.size + 3 == utxos.size)
|
||||||
|
|
||||||
_ = checkState(
|
_ = checkState(
|
||||||
|
@ -263,7 +263,7 @@ class UTXOLifeCycleTest
|
||||||
_ <- wallet.transactionProcessing.processBlock(block)
|
_ <- wallet.transactionProcessing.processBlock(block)
|
||||||
_ <- wallet.utxoHandling.updateUtxoPendingStates()
|
_ <- wallet.utxoHandling.updateUtxoPendingStates()
|
||||||
|
|
||||||
utxos <- wallet.utxoHandling.listUtxos()
|
utxos <- wallet.utxoHandling.getUtxos()
|
||||||
_ = assert(oldUtxos.size + 3 == utxos.size)
|
_ = assert(oldUtxos.size + 3 == utxos.size)
|
||||||
|
|
||||||
utxo1 = utxos.find(_.txid == txid1).get
|
utxo1 = utxos.find(_.txid == txid1).get
|
||||||
|
@ -508,7 +508,7 @@ class UTXOLifeCycleTest
|
||||||
|
|
||||||
tx = rawTxHelper.unsignedTx
|
tx = rawTxHelper.unsignedTx
|
||||||
updatedCoins <- wallet.utxoHandling.findOutputsBeingSpent(tx)
|
updatedCoins <- wallet.utxoHandling.findOutputsBeingSpent(tx)
|
||||||
reserved <- wallet.utxoHandling.listUtxos(TxoState.Reserved)
|
reserved <- wallet.utxoHandling.getUtxos(TxoState.Reserved)
|
||||||
newTransactions <- wallet.transactionProcessing.listTransactions()
|
newTransactions <- wallet.transactionProcessing.listTransactions()
|
||||||
} yield {
|
} yield {
|
||||||
assert(updatedCoins.forall(_.state == TxoState.Reserved))
|
assert(updatedCoins.forall(_.state == TxoState.Reserved))
|
||||||
|
@ -537,13 +537,13 @@ class UTXOLifeCycleTest
|
||||||
|
|
||||||
tx = rawTxHelper.unsignedTx
|
tx = rawTxHelper.unsignedTx
|
||||||
reservedUtxos <- wallet.utxoHandling.findOutputsBeingSpent(tx)
|
reservedUtxos <- wallet.utxoHandling.findOutputsBeingSpent(tx)
|
||||||
allReserved <- wallet.utxoHandling.listUtxos(TxoState.Reserved)
|
allReserved <- wallet.utxoHandling.getUtxos(TxoState.Reserved)
|
||||||
_ = assert(reservedUtxos.forall(_.state == TxoState.Reserved))
|
_ = assert(reservedUtxos.forall(_.state == TxoState.Reserved))
|
||||||
_ = assert(reservedUtxos.forall(allReserved.contains))
|
_ = assert(reservedUtxos.forall(allReserved.contains))
|
||||||
|
|
||||||
unreservedUtxos <- wallet.utxoHandling.unmarkUTXOsAsReserved(
|
unreservedUtxos <- wallet.utxoHandling.unmarkUTXOsAsReserved(
|
||||||
reservedUtxos)
|
reservedUtxos)
|
||||||
newReserved <- wallet.utxoHandling.listUtxos(TxoState.Reserved)
|
newReserved <- wallet.utxoHandling.getUtxos(TxoState.Reserved)
|
||||||
newTransactions <- wallet.transactionProcessing.listTransactions()
|
newTransactions <- wallet.transactionProcessing.listTransactions()
|
||||||
} yield {
|
} yield {
|
||||||
assert(unreservedUtxos.forall(_.state != TxoState.Reserved))
|
assert(unreservedUtxos.forall(_.state != TxoState.Reserved))
|
||||||
|
@ -570,7 +570,7 @@ class UTXOLifeCycleTest
|
||||||
)
|
)
|
||||||
|
|
||||||
tx = rawTxHelper.unsignedTx
|
tx = rawTxHelper.unsignedTx
|
||||||
allReserved <- wallet.utxoHandling.listUtxos(TxoState.Reserved)
|
allReserved <- wallet.utxoHandling.getUtxos(TxoState.Reserved)
|
||||||
_ = assert(
|
_ = assert(
|
||||||
tx.inputs
|
tx.inputs
|
||||||
.map(_.previousOutput)
|
.map(_.previousOutput)
|
||||||
|
@ -610,7 +610,7 @@ class UTXOLifeCycleTest
|
||||||
builderResult
|
builderResult
|
||||||
)
|
)
|
||||||
tx = RawTxSigner.sign(unsignedTx, rawTxHelper.scriptSigParams)
|
tx = RawTxSigner.sign(unsignedTx, rawTxHelper.scriptSigParams)
|
||||||
allReserved <- wallet.utxoHandling.listUtxos(TxoState.Reserved)
|
allReserved <- wallet.utxoHandling.getUtxos(TxoState.Reserved)
|
||||||
_ = assert(
|
_ = assert(
|
||||||
tx.inputs
|
tx.inputs
|
||||||
.map(_.previousOutput)
|
.map(_.previousOutput)
|
||||||
|
@ -626,7 +626,7 @@ class UTXOLifeCycleTest
|
||||||
block <- bitcoind.getBlockRaw(hash)
|
block <- bitcoind.getBlockRaw(hash)
|
||||||
_ <- wallet.transactionProcessing.processBlock(block)
|
_ <- wallet.transactionProcessing.processBlock(block)
|
||||||
|
|
||||||
newReserved <- wallet.utxoHandling.listUtxos(TxoState.Reserved)
|
newReserved <- wallet.utxoHandling.getUtxos(TxoState.Reserved)
|
||||||
newTransactions <- wallet.transactionProcessing.listTransactions()
|
newTransactions <- wallet.transactionProcessing.listTransactions()
|
||||||
} yield {
|
} yield {
|
||||||
assert(newReserved.isEmpty)
|
assert(newReserved.isEmpty)
|
||||||
|
@ -641,7 +641,7 @@ class UTXOLifeCycleTest
|
||||||
val bitcoind = param.bitcoind
|
val bitcoind = param.bitcoind
|
||||||
|
|
||||||
for {
|
for {
|
||||||
utxo <- wallet.utxoHandling.listUtxos().map(_.head)
|
utxo <- wallet.utxoHandling.getUtxos().map(_.head)
|
||||||
changeAddr <- wallet.getNewChangeAddress()
|
changeAddr <- wallet.getNewChangeAddress()
|
||||||
unsignedPSBT = {
|
unsignedPSBT = {
|
||||||
val input =
|
val input =
|
||||||
|
@ -690,7 +690,7 @@ class UTXOLifeCycleTest
|
||||||
it must "fail to mark utxos as reserved if one of the utxos is already reserved" in {
|
it must "fail to mark utxos as reserved if one of the utxos is already reserved" in {
|
||||||
param =>
|
param =>
|
||||||
val wallet = param.wallet
|
val wallet = param.wallet
|
||||||
val utxosF = wallet.utxoHandling.listUtxos()
|
val utxosF = wallet.utxoHandling.getUtxos()
|
||||||
|
|
||||||
val reservedUtxoF: Future[SpendingInfoDb] = for {
|
val reservedUtxoF: Future[SpendingInfoDb] = for {
|
||||||
utxos <- utxosF
|
utxos <- utxosF
|
||||||
|
@ -712,7 +712,7 @@ class UTXOLifeCycleTest
|
||||||
for {
|
for {
|
||||||
_ <- assertionF
|
_ <- assertionF
|
||||||
reserved <- reservedUtxoF
|
reserved <- reservedUtxoF
|
||||||
utxos <- wallet.utxoHandling.listUtxos(TxoState.Reserved)
|
utxos <- wallet.utxoHandling.getUtxos(TxoState.Reserved)
|
||||||
} yield {
|
} yield {
|
||||||
// make sure only 1 utxo is still reserved
|
// make sure only 1 utxo is still reserved
|
||||||
assert(utxos.length == 1)
|
assert(utxos.length == 1)
|
||||||
|
@ -737,7 +737,7 @@ class UTXOLifeCycleTest
|
||||||
_ <- wallet.transactionProcessing.processBlock(block)
|
_ <- wallet.transactionProcessing.processBlock(block)
|
||||||
|
|
||||||
// make sure the utxo is pending confirmations received
|
// make sure the utxo is pending confirmations received
|
||||||
utxos <- wallet.utxoHandling.listUtxos(
|
utxos <- wallet.utxoHandling.getUtxos(
|
||||||
TxoState.PendingConfirmationsReceived)
|
TxoState.PendingConfirmationsReceived)
|
||||||
_ = assert(utxos.length == 1)
|
_ = assert(utxos.length == 1)
|
||||||
utxo = utxos.head
|
utxo = utxos.head
|
||||||
|
@ -747,7 +747,7 @@ class UTXOLifeCycleTest
|
||||||
_ <- wallet.utxoHandling.markUTXOsAsReserved(Vector(utxo))
|
_ <- wallet.utxoHandling.markUTXOsAsReserved(Vector(utxo))
|
||||||
// confirm it is reserved
|
// confirm it is reserved
|
||||||
_ <- wallet.utxoHandling
|
_ <- wallet.utxoHandling
|
||||||
.listUtxos(TxoState.Reserved)
|
.getUtxos(TxoState.Reserved)
|
||||||
.map(utxos =>
|
.map(utxos =>
|
||||||
assert(utxos.contains(utxo.copyWithState(TxoState.Reserved))))
|
assert(utxos.contains(utxo.copyWithState(TxoState.Reserved))))
|
||||||
|
|
||||||
|
@ -757,7 +757,7 @@ class UTXOLifeCycleTest
|
||||||
_ <- wallet.transactionProcessing.processBlock(block2)
|
_ <- wallet.transactionProcessing.processBlock(block2)
|
||||||
|
|
||||||
// the utxo should still be reserved
|
// the utxo should still be reserved
|
||||||
reservedUtxos <- wallet.utxoHandling.listUtxos(TxoState.Reserved)
|
reservedUtxos <- wallet.utxoHandling.getUtxos(TxoState.Reserved)
|
||||||
reservedUtxo = reservedUtxos.head
|
reservedUtxo = reservedUtxos.head
|
||||||
} yield {
|
} yield {
|
||||||
assert(reservedUtxo.txid == txId)
|
assert(reservedUtxo.txid == txId)
|
||||||
|
@ -771,7 +771,7 @@ class UTXOLifeCycleTest
|
||||||
val bitcoind = param.bitcoind
|
val bitcoind = param.bitcoind
|
||||||
val bitcoindAddrF = bitcoind.getNewAddress
|
val bitcoindAddrF = bitcoind.getNewAddress
|
||||||
val amt = Satoshis(100000)
|
val amt = Satoshis(100000)
|
||||||
val utxoCountF = wallet.utxoHandling.listUtxos()
|
val utxoCountF = wallet.utxoHandling.getUtxos()
|
||||||
for {
|
for {
|
||||||
bitcoindAdr <- bitcoindAddrF
|
bitcoindAdr <- bitcoindAddrF
|
||||||
utxoCount <- utxoCountF
|
utxoCount <- utxoCountF
|
||||||
|
@ -779,34 +779,34 @@ class UTXOLifeCycleTest
|
||||||
tx <- wallet.sendFundsHandling.sendToAddress(bitcoindAdr,
|
tx <- wallet.sendFundsHandling.sendToAddress(bitcoindAdr,
|
||||||
amt,
|
amt,
|
||||||
SatoshisPerVirtualByte.one)
|
SatoshisPerVirtualByte.one)
|
||||||
c <- wallet.utxoHandling.listUtxos()
|
c <- wallet.utxoHandling.getUtxos()
|
||||||
_ = assert(c.length == utxoCount.length)
|
_ = assert(c.length == utxoCount.length)
|
||||||
txIdBE <- bitcoind.sendRawTransaction(tx)
|
txIdBE <- bitcoind.sendRawTransaction(tx)
|
||||||
|
|
||||||
// find all utxos that we can use to fund a transaction
|
// find all utxos that we can use to fund a transaction
|
||||||
utxos <- wallet.utxoHandling
|
utxos <- wallet.utxoHandling
|
||||||
.listUtxos()
|
.getUtxos()
|
||||||
.map(_.filter(u => TxoState.receivedStates.contains(u.state)))
|
.map(_.filter(u => TxoState.receivedStates.contains(u.state)))
|
||||||
broadcastReceived <- wallet.utxoHandling.listUtxos(
|
broadcastReceived <- wallet.utxoHandling.getUtxos(
|
||||||
TxoState.BroadcastReceived)
|
TxoState.BroadcastReceived)
|
||||||
_ = assert(broadcastReceived.length == 1) // change output
|
_ = assert(broadcastReceived.length == 1) // change output
|
||||||
|
|
||||||
// mark all utxos as reserved
|
// mark all utxos as reserved
|
||||||
_ <- wallet.utxoHandling.markUTXOsAsReserved(utxos)
|
_ <- wallet.utxoHandling.markUTXOsAsReserved(utxos)
|
||||||
newReservedUtxos <- wallet.utxoHandling.listUtxos(TxoState.Reserved)
|
newReservedUtxos <- wallet.utxoHandling.getUtxos(TxoState.Reserved)
|
||||||
|
|
||||||
// make sure all utxos are reserved
|
// make sure all utxos are reserved
|
||||||
_ = assert(newReservedUtxos.length == utxoCount.length)
|
_ = assert(newReservedUtxos.length == utxoCount.length)
|
||||||
blockHash <- bitcoind.generateToAddress(1, bitcoindAdr).map(_.head)
|
blockHash <- bitcoind.generateToAddress(1, bitcoindAdr).map(_.head)
|
||||||
block <- bitcoind.getBlockRaw(blockHash)
|
block <- bitcoind.getBlockRaw(blockHash)
|
||||||
_ <- wallet.transactionProcessing.processBlock(block)
|
_ <- wallet.transactionProcessing.processBlock(block)
|
||||||
broadcastSpentUtxo <- wallet.utxoHandling.listUtxos(
|
broadcastSpentUtxo <- wallet.utxoHandling.getUtxos(
|
||||||
TxoState.PendingConfirmationsSpent
|
TxoState.PendingConfirmationsSpent
|
||||||
)
|
)
|
||||||
pendingConfirmationsReceivedUtxos <- wallet.utxoHandling.listUtxos(
|
pendingConfirmationsReceivedUtxos <- wallet.utxoHandling.getUtxos(
|
||||||
TxoState.PendingConfirmationsReceived
|
TxoState.PendingConfirmationsReceived
|
||||||
)
|
)
|
||||||
finalReservedUtxos <- wallet.utxoHandling.listUtxos(TxoState.Reserved)
|
finalReservedUtxos <- wallet.utxoHandling.getUtxos(TxoState.Reserved)
|
||||||
} yield {
|
} yield {
|
||||||
assert(newReservedUtxos == finalReservedUtxos)
|
assert(newReservedUtxos == finalReservedUtxos)
|
||||||
assert(pendingConfirmationsReceivedUtxos.isEmpty)
|
assert(pendingConfirmationsReceivedUtxos.isEmpty)
|
||||||
|
|
|
@ -160,7 +160,7 @@ class WalletCallbackTest extends BitcoinSWalletTest {
|
||||||
val wallet = fundedWallet.wallet
|
val wallet = fundedWallet.wallet
|
||||||
|
|
||||||
for {
|
for {
|
||||||
utxos <- wallet.utxoHandling.listUtxos()
|
utxos <- wallet.utxoHandling.getUtxos()
|
||||||
_ <- wallet.utxoHandling.markUTXOsAsReserved(Vector(utxos.head))
|
_ <- wallet.utxoHandling.markUTXOsAsReserved(Vector(utxos.head))
|
||||||
result <- resultP.future
|
result <- resultP.future
|
||||||
} yield assert(
|
} yield assert(
|
||||||
|
@ -185,7 +185,7 @@ class WalletCallbackTest extends BitcoinSWalletTest {
|
||||||
val wallet = fundedWallet.wallet
|
val wallet = fundedWallet.wallet
|
||||||
|
|
||||||
for {
|
for {
|
||||||
utxos <- wallet.utxoHandling.listUtxos()
|
utxos <- wallet.utxoHandling.getUtxos()
|
||||||
reserved <- wallet.utxoHandling.markUTXOsAsReserved(Vector(utxos.head))
|
reserved <- wallet.utxoHandling.markUTXOsAsReserved(Vector(utxos.head))
|
||||||
_ = fundedWallet.walletConfig.addCallbacks(callbacks)
|
_ = fundedWallet.walletConfig.addCallbacks(callbacks)
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ class WalletIntegrationTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
tx <- bitcoind.getRawTransactionRaw(txId)
|
tx <- bitcoind.getRawTransactionRaw(txId)
|
||||||
|
|
||||||
// before processing TX, wallet should be completely empty
|
// before processing TX, wallet should be completely empty
|
||||||
_ <- wallet.utxoHandling.listUtxos().map(utxos => assert(utxos.isEmpty))
|
_ <- wallet.utxoHandling.getUtxos().map(utxos => assert(utxos.isEmpty))
|
||||||
_ <- wallet.getBalance().map(confirmed => assert(confirmed == 0.bitcoin))
|
_ <- wallet.getBalance().map(confirmed => assert(confirmed == 0.bitcoin))
|
||||||
_ <-
|
_ <-
|
||||||
wallet
|
wallet
|
||||||
|
@ -75,7 +75,7 @@ class WalletIntegrationTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
|
|
||||||
// we should now have one UTXO in the wallet
|
// we should now have one UTXO in the wallet
|
||||||
// it should not be confirmed
|
// it should not be confirmed
|
||||||
utxosPostAdd <- wallet.utxoHandling.listUtxos()
|
utxosPostAdd <- wallet.utxoHandling.getUtxos()
|
||||||
_ = assert(utxosPostAdd.length == 1)
|
_ = assert(utxosPostAdd.length == 1)
|
||||||
_ <-
|
_ <-
|
||||||
wallet
|
wallet
|
||||||
|
@ -100,7 +100,7 @@ class WalletIntegrationTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
blockHashWithConfsOpt)
|
blockHashWithConfsOpt)
|
||||||
_ <-
|
_ <-
|
||||||
wallet.utxoHandling
|
wallet.utxoHandling
|
||||||
.listUtxos()
|
.getUtxos()
|
||||||
.map { utxos =>
|
.map { utxos =>
|
||||||
// we want to make sure no new utxos were added,
|
// we want to make sure no new utxos were added,
|
||||||
// i.e. that we only modified an existing one
|
// i.e. that we only modified an existing one
|
||||||
|
@ -131,7 +131,7 @@ class WalletIntegrationTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
_ <- bitcoind.generate(1)
|
_ <- bitcoind.generate(1)
|
||||||
tx <- bitcoind.getRawTransaction(txid)
|
tx <- bitcoind.getRawTransaction(txid)
|
||||||
|
|
||||||
utxos <- wallet.utxoHandling.listUtxos()
|
utxos <- wallet.utxoHandling.getUtxos()
|
||||||
_ = utxos match {
|
_ = utxos match {
|
||||||
case utxo +: Vector() =>
|
case utxo +: Vector() =>
|
||||||
assert(utxo.privKeyPath.chain.chainType == HDChainType.Change)
|
assert(utxo.privKeyPath.chain.chainType == HDChainType.Change)
|
||||||
|
@ -356,9 +356,9 @@ class WalletIntegrationTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
_ <- wallet.transactionProcessing.processBlock(block)
|
_ <- wallet.transactionProcessing.processBlock(block)
|
||||||
|
|
||||||
// Verify we funded the wallet
|
// Verify we funded the wallet
|
||||||
allUtxos <- wallet.utxoHandling.listUtxos()
|
allUtxos <- wallet.utxoHandling.getUtxos()
|
||||||
_ = assert(allUtxos.size == 1)
|
_ = assert(allUtxos.size == 1)
|
||||||
utxos <- wallet.utxoHandling.listUtxos(TxoState.ImmatureCoinbase)
|
utxos <- wallet.utxoHandling.getUtxos(TxoState.ImmatureCoinbase)
|
||||||
_ = assert(utxos.size == 1)
|
_ = assert(utxos.size == 1)
|
||||||
|
|
||||||
bitcoindAddr <- bitcoind.getNewAddress
|
bitcoindAddr <- bitcoind.getNewAddress
|
||||||
|
@ -396,10 +396,10 @@ class WalletIntegrationTest extends BitcoinSWalletTestCachedBitcoindNewest {
|
||||||
|
|
||||||
// Process tx, validate correctly moved to
|
// Process tx, validate correctly moved to
|
||||||
_ <- wallet.transactionProcessing.processTransaction(signedTx, None)
|
_ <- wallet.transactionProcessing.processTransaction(signedTx, None)
|
||||||
newCoinbaseUtxos <- wallet.utxoHandling.listUtxos(
|
newCoinbaseUtxos <- wallet.utxoHandling.getUtxos(
|
||||||
TxoState.ImmatureCoinbase)
|
TxoState.ImmatureCoinbase)
|
||||||
_ = assert(newCoinbaseUtxos.isEmpty)
|
_ = assert(newCoinbaseUtxos.isEmpty)
|
||||||
spentUtxos <- wallet.utxoHandling.listUtxos(TxoState.BroadcastSpent)
|
spentUtxos <- wallet.utxoHandling.getUtxos(TxoState.BroadcastSpent)
|
||||||
_ = assert(spentUtxos.size == 1)
|
_ = assert(spentUtxos.size == 1)
|
||||||
|
|
||||||
// Assert spending tx valid to bitcoind
|
// Assert spending tx valid to bitcoind
|
||||||
|
|
|
@ -245,7 +245,7 @@ class WalletSendingTest extends BitcoinSWalletTest {
|
||||||
it should "correctly send entire outpoints" in { fundedWallet =>
|
it should "correctly send entire outpoints" in { fundedWallet =>
|
||||||
val wallet = fundedWallet.wallet
|
val wallet = fundedWallet.wallet
|
||||||
for {
|
for {
|
||||||
allUtxos <- wallet.utxoHandling.listUtxos()
|
allUtxos <- wallet.utxoHandling.getUtxos()
|
||||||
// use half of them
|
// use half of them
|
||||||
utxos = allUtxos.drop(allUtxos.size / 2)
|
utxos = allUtxos.drop(allUtxos.size / 2)
|
||||||
outPoints = utxos.map(_.outPoint)
|
outPoints = utxos.map(_.outPoint)
|
||||||
|
@ -304,7 +304,7 @@ class WalletSendingTest extends BitcoinSWalletTest {
|
||||||
it should "correctly sweep the wallet" in { fundedWallet =>
|
it should "correctly sweep the wallet" in { fundedWallet =>
|
||||||
val wallet = fundedWallet.wallet
|
val wallet = fundedWallet.wallet
|
||||||
for {
|
for {
|
||||||
utxos <- wallet.utxoHandling.listUtxos()
|
utxos <- wallet.utxoHandling.getUtxos()
|
||||||
tx <- wallet.sendFundsHandling.sweepWallet(testAddress, None)
|
tx <- wallet.sendFundsHandling.sweepWallet(testAddress, None)
|
||||||
balance <- wallet.getBalance()
|
balance <- wallet.getBalance()
|
||||||
} yield {
|
} yield {
|
||||||
|
@ -408,7 +408,7 @@ class WalletSendingTest extends BitcoinSWalletTest {
|
||||||
|
|
||||||
for {
|
for {
|
||||||
addr <- wallet.getNewAddress()
|
addr <- wallet.getNewAddress()
|
||||||
utxo <- wallet.utxoHandling.listUtxos().map(_.head)
|
utxo <- wallet.utxoHandling.getUtxos().map(_.head)
|
||||||
|
|
||||||
// Create tx not signaling RBF
|
// Create tx not signaling RBF
|
||||||
input = TransactionInput(
|
input = TransactionInput(
|
||||||
|
@ -510,7 +510,7 @@ class WalletSendingTest extends BitcoinSWalletTest {
|
||||||
fundedWallet =>
|
fundedWallet =>
|
||||||
val wallet = fundedWallet.wallet
|
val wallet = fundedWallet.wallet
|
||||||
for {
|
for {
|
||||||
allUtxos <- wallet.utxoHandling.listUtxos()
|
allUtxos <- wallet.utxoHandling.getUtxos()
|
||||||
// Make one already spent
|
// Make one already spent
|
||||||
spent = allUtxos.head
|
spent = allUtxos.head
|
||||||
.copyWithSpendingTxId(
|
.copyWithSpendingTxId(
|
||||||
|
@ -539,7 +539,7 @@ class WalletSendingTest extends BitcoinSWalletTest {
|
||||||
account <- wallet.accountHandling.getDefaultAccount()
|
account <- wallet.accountHandling.getDefaultAccount()
|
||||||
feeRate <- wallet.getFeeRate()
|
feeRate <- wallet.getFeeRate()
|
||||||
allUtxos <- wallet.utxoHandling
|
allUtxos <- wallet.utxoHandling
|
||||||
.listUtxos(account.hdAccount)
|
.getUtxos(account.hdAccount)
|
||||||
.map(_.map(CoinSelectorUtxo.fromSpendingInfoDb))
|
.map(_.map(CoinSelectorUtxo.fromSpendingInfoDb))
|
||||||
|
|
||||||
output = TransactionOutput(amountToSend, testAddress.scriptPubKey)
|
output = TransactionOutput(amountToSend, testAddress.scriptPubKey)
|
||||||
|
|
|
@ -36,8 +36,8 @@ class WalletUnitTest extends BitcoinSWalletTest {
|
||||||
|
|
||||||
it should "create a new wallet" in { (wallet: Wallet) =>
|
it should "create a new wallet" in { (wallet: Wallet) =>
|
||||||
for {
|
for {
|
||||||
accounts <- wallet.accountHandling.listAccounts()
|
accounts <- wallet.accountHandling.getAccounts()
|
||||||
addresses <- wallet.addressHandling.listAddresses()
|
addresses <- wallet.addressHandling.getAddresses()
|
||||||
} yield {
|
} yield {
|
||||||
assert(accounts.length == 4) // legacy, segwit, nested segwit, taproot
|
assert(accounts.length == 4) // legacy, segwit, nested segwit, taproot
|
||||||
assert(addresses.isEmpty)
|
assert(addresses.isEmpty)
|
||||||
|
@ -48,7 +48,7 @@ class WalletUnitTest extends BitcoinSWalletTest {
|
||||||
for {
|
for {
|
||||||
addr <- wallet.getNewAddress()
|
addr <- wallet.getNewAddress()
|
||||||
otherAddr <- wallet.getNewAddress()
|
otherAddr <- wallet.getNewAddress()
|
||||||
allAddrs <- wallet.addressHandling.listAddresses()
|
allAddrs <- wallet.addressHandling.getAddresses()
|
||||||
} yield {
|
} yield {
|
||||||
assert(allAddrs.length == 2)
|
assert(allAddrs.length == 2)
|
||||||
assert(allAddrs.exists(_.address == addr))
|
assert(allAddrs.exists(_.address == addr))
|
||||||
|
|
|
@ -157,8 +157,8 @@ case class Wallet(
|
||||||
override def processCompactFilters(
|
override def processCompactFilters(
|
||||||
blockFilters: Vector[(DoubleSha256DigestBE, GolombFilter)]
|
blockFilters: Vector[(DoubleSha256DigestBE, GolombFilter)]
|
||||||
): Future[Wallet] = {
|
): Future[Wallet] = {
|
||||||
val utxosF = utxoHandling.listUtxos()
|
val utxosF = utxoHandling.getUtxos()
|
||||||
val spksF = addressHandling.listScriptPubKeys()
|
val spksF = addressHandling.getScriptPubKeys()
|
||||||
val blockHashOpt = blockFilters.lastOption.map(_._1)
|
val blockHashOpt = blockFilters.lastOption.map(_._1)
|
||||||
val heightOptF = blockHashOpt match {
|
val heightOptF = blockHashOpt match {
|
||||||
case Some(blockHash) =>
|
case Some(blockHash) =>
|
||||||
|
|
|
@ -105,7 +105,7 @@ case class AccountHandling(
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @inheritdoc */
|
/** @inheritdoc */
|
||||||
override def listAccounts(): Future[Vector[AccountDb]] =
|
override def getAccounts(): Future[Vector[AccountDb]] =
|
||||||
accountDAO.findAll()
|
accountDAO.findAll()
|
||||||
|
|
||||||
private def getOrThrowAccount(account: Option[AccountDb]): AccountDb =
|
private def getOrThrowAccount(account: Option[AccountDb]): AccountDb =
|
||||||
|
@ -332,7 +332,7 @@ case class AccountHandling(
|
||||||
safeDatabase.run(findAccountAction(account))
|
safeDatabase.run(findAccountAction(account))
|
||||||
}
|
}
|
||||||
|
|
||||||
override def listUnusedAddresses(
|
override def getUnusedAddresses(
|
||||||
account: HDAccount): Future[Vector[AddressDb]] = {
|
account: HDAccount): Future[Vector[AddressDb]] = {
|
||||||
val unusedAddressesF = addressDAO.getUnusedAddresses
|
val unusedAddressesF = addressDAO.getUnusedAddresses
|
||||||
unusedAddressesF.map { unusedAddresses =>
|
unusedAddressesF.map { unusedAddresses =>
|
||||||
|
@ -341,7 +341,7 @@ case class AccountHandling(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override def listAddresses(account: HDAccount): Future[Vector[AddressDb]] = {
|
override def getAddresses(account: HDAccount): Future[Vector[AddressDb]] = {
|
||||||
val allAddressesF: Future[Vector[AddressDb]] = addressDAO.findAllAddresses()
|
val allAddressesF: Future[Vector[AddressDb]] = addressDAO.findAllAddresses()
|
||||||
|
|
||||||
val accountAddressesF = {
|
val accountAddressesF = {
|
||||||
|
@ -356,13 +356,13 @@ case class AccountHandling(
|
||||||
accountAddressesF
|
accountAddressesF
|
||||||
}
|
}
|
||||||
|
|
||||||
override def listSpentAddresses(
|
override def getSpentAddresses(
|
||||||
account: HDAccount
|
account: HDAccount
|
||||||
): Future[Vector[AddressDb]] = {
|
): Future[Vector[AddressDb]] = {
|
||||||
addressDAO.getSpentAddresses(account)
|
addressDAO.getSpentAddresses(account)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def listFundedAddresses(
|
override def getFundedAddresses(
|
||||||
account: HDAccount
|
account: HDAccount
|
||||||
): Future[Vector[(AddressDb, CurrencyUnit)]] = {
|
): Future[Vector[(AddressDb, CurrencyUnit)]] = {
|
||||||
addressDAO.getFundedAddresses(account)
|
addressDAO.getFundedAddresses(account)
|
||||||
|
|
|
@ -50,23 +50,23 @@ case class AddressHandling(
|
||||||
private val scriptPubKeyDAO: ScriptPubKeyDAO = walletDAOs.scriptPubKeyDAO
|
private val scriptPubKeyDAO: ScriptPubKeyDAO = walletDAOs.scriptPubKeyDAO
|
||||||
private val networkParameters: NetworkParameters = walletConfig.network
|
private val networkParameters: NetworkParameters = walletConfig.network
|
||||||
|
|
||||||
override def listAddresses(): Future[Vector[AddressDb]] =
|
override def getAddresses(): Future[Vector[AddressDb]] =
|
||||||
addressDAO.findAllAddressDbForAccount(walletConfig.defaultAccount)
|
addressDAO.findAllAddressDbForAccount(walletConfig.defaultAccount)
|
||||||
|
|
||||||
override def listSpentAddresses(): Future[Vector[AddressDb]] = {
|
override def getSpentAddresses(): Future[Vector[AddressDb]] = {
|
||||||
addressDAO.getSpentAddresses(walletConfig.defaultAccount)
|
addressDAO.getSpentAddresses(walletConfig.defaultAccount)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def listFundedAddresses()
|
override def getFundedAddresses()
|
||||||
: Future[Vector[(AddressDb, CurrencyUnit)]] = {
|
: Future[Vector[(AddressDb, CurrencyUnit)]] = {
|
||||||
addressDAO.getFundedAddresses(walletConfig.defaultAccount)
|
addressDAO.getFundedAddresses(walletConfig.defaultAccount)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def listUnusedAddresses(): Future[Vector[AddressDb]] = {
|
override def getUnusedAddresses(): Future[Vector[AddressDb]] = {
|
||||||
addressDAO.getUnusedAddresses(walletConfig.defaultAccount)
|
addressDAO.getUnusedAddresses(walletConfig.defaultAccount)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def listScriptPubKeys(): Future[Vector[ScriptPubKeyDb]] = {
|
override def getScriptPubKeys(): Future[Vector[ScriptPubKeyDb]] = {
|
||||||
scriptPubKeyDAO.findAll()
|
scriptPubKeyDAO.findAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ case class AddressHandling(
|
||||||
transaction: Transaction
|
transaction: Transaction
|
||||||
): Future[Vector[(TransactionOutput, TransactionOutPoint)]] =
|
): Future[Vector[(TransactionOutput, TransactionOutPoint)]] =
|
||||||
for {
|
for {
|
||||||
spks <- listScriptPubKeys()
|
spks <- getScriptPubKeys()
|
||||||
} yield transaction.outputs.zipWithIndex.collect {
|
} yield transaction.outputs.zipWithIndex.collect {
|
||||||
case (out, index)
|
case (out, index)
|
||||||
if spks.map(_.scriptPubKey).contains(out.scriptPubKey) =>
|
if spks.map(_.scriptPubKey).contains(out.scriptPubKey) =>
|
||||||
|
|
|
@ -445,7 +445,7 @@ case class SendFundsHandlingHandling(
|
||||||
val outputs = Vector(TransactionOutput(Satoshis.zero, address.scriptPubKey))
|
val outputs = Vector(TransactionOutput(Satoshis.zero, address.scriptPubKey))
|
||||||
for {
|
for {
|
||||||
_ <- invariantF
|
_ <- invariantF
|
||||||
utxos <- utxoHandling.listUtxos(outPoints)
|
utxos <- utxoHandling.getUtxos(outPoints)
|
||||||
outputMap = SpendingInfoDb.toPreviousOutputMap(utxos)
|
outputMap = SpendingInfoDb.toPreviousOutputMap(utxos)
|
||||||
utxosWithTxs <- fundTxHandling.getPreviousTransactions(utxos)
|
utxosWithTxs <- fundTxHandling.getPreviousTransactions(utxos)
|
||||||
inputInfos = utxosWithTxs
|
inputInfos = utxosWithTxs
|
||||||
|
|
|
@ -105,18 +105,18 @@ case class UtxoHandling(
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @inheritdoc */
|
/** @inheritdoc */
|
||||||
override def listUtxos(): Future[Vector[SpendingInfoDb]] = {
|
override def getUtxos(): Future[Vector[SpendingInfoDb]] = {
|
||||||
listUtxos(walletConfig.defaultAccount)
|
getUtxos(walletConfig.defaultAccount)
|
||||||
}
|
}
|
||||||
|
|
||||||
def listUtxos(
|
def getUtxos(
|
||||||
hdAccount: HDAccount
|
hdAccount: HDAccount
|
||||||
): Future[Vector[SpendingInfoDb]] = {
|
): Future[Vector[SpendingInfoDb]] = {
|
||||||
spendingInfoDAO.findAllUnspentForAccount(hdAccount)
|
spendingInfoDAO.findAllUnspentForAccount(hdAccount)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns all the utxos originating from the given outpoints */
|
/** Returns all the utxos originating from the given outpoints */
|
||||||
override def listUtxos(
|
override def getUtxos(
|
||||||
outPoints: Vector[TransactionOutPoint]
|
outPoints: Vector[TransactionOutPoint]
|
||||||
): Future[Vector[SpendingInfoDb]] = {
|
): Future[Vector[SpendingInfoDb]] = {
|
||||||
spendingInfoDAO
|
spendingInfoDAO
|
||||||
|
@ -124,11 +124,11 @@ case class UtxoHandling(
|
||||||
.map(_.filter(spendingInfo => outPoints.contains(spendingInfo.outPoint)))
|
.map(_.filter(spendingInfo => outPoints.contains(spendingInfo.outPoint)))
|
||||||
}
|
}
|
||||||
|
|
||||||
override def listUtxos(tag: AddressTag): Future[Vector[SpendingInfoDb]] = {
|
override def getUtxos(tag: AddressTag): Future[Vector[SpendingInfoDb]] = {
|
||||||
listUtxos(walletConfig.defaultAccount, tag)
|
getUtxos(walletConfig.defaultAccount, tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def listUtxos(
|
override def getUtxos(
|
||||||
hdAccount: HDAccount,
|
hdAccount: HDAccount,
|
||||||
tag: AddressTag
|
tag: AddressTag
|
||||||
): Future[Vector[SpendingInfoDb]] = {
|
): Future[Vector[SpendingInfoDb]] = {
|
||||||
|
@ -139,11 +139,11 @@ case class UtxoHandling(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override def listUtxos(state: TxoState): Future[Vector[SpendingInfoDb]] = {
|
override def getUtxos(state: TxoState): Future[Vector[SpendingInfoDb]] = {
|
||||||
listUtxos(walletConfig.defaultAccount, state)
|
getUtxos(walletConfig.defaultAccount, state)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def listUtxos(
|
override def getUtxos(
|
||||||
hdAccount: HDAccount,
|
hdAccount: HDAccount,
|
||||||
state: TxoState
|
state: TxoState
|
||||||
): Future[Vector[SpendingInfoDb]] = {
|
): Future[Vector[SpendingInfoDb]] = {
|
||||||
|
|
Loading…
Add table
Reference in a new issue