1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-02-22 14:22:39 +01:00

Filter out non-spendable outputs from bitcoind 'listunspent' call during setup (#605)

Fixes #599
This commit is contained in:
araspitzu 2018-05-22 12:36:01 +02:00 committed by Fabrice Drouin
parent 644b4a2a98
commit db43747d2b

View file

@ -99,7 +99,11 @@ class Setup(datadir: File, overrideDefaults: Config = ConfigFactory.empty(), act
progress = (json \ "verificationprogress").extract[Double]
chainHash <- bitcoinClient.invoke("getblockhash", 0).map(_.extract[String]).map(BinaryData(_)).map(x => BinaryData(x.reverse))
bitcoinVersion <- bitcoinClient.invoke("getnetworkinfo").map(json => (json \ "version")).map(_.extract[String])
unspentAddresses <- bitcoinClient.invoke("listunspent").collect { case JArray(values) => values.map(value => (value \ "address").extract[String]) }
unspentAddresses <- bitcoinClient.invoke("listunspent").collect { case JArray(values) =>
values
.filter(value => (value \ "spendable").extract[Boolean])
.map(value => (value \ "address").extract[String])
}
} yield (progress, chainHash, bitcoinVersion, unspentAddresses)
// blocking sanity checks
val (progress, chainHash, bitcoinVersion, unspentAddresses) = Await.result(future, 30 seconds)