From a19dc94bef3f041b51918e0e504162cb4158e374 Mon Sep 17 00:00:00 2001 From: Torkel Rogstad Date: Fri, 31 May 2019 16:59:34 +0200 Subject: [PATCH] Doc: Add stable and unstable version, try bitcoin-s script --- build.sbt | 3 ++- docs/getting-started.md | 53 ++++++++++++++++++++++++++++++----------- try-bitcoin-s.sh | 14 +++++++---- 3 files changed, 51 insertions(+), 19 deletions(-) diff --git a/build.sbt b/build.sbt index 4f07d32953..ac74e31c41 100644 --- a/build.sbt +++ b/build.sbt @@ -284,7 +284,8 @@ lazy val docs = project mdocExtraArguments := List("--no-link-hygiene"), name := "bitcoin-s-docs", mdocVariables := Map( - "VERSION" -> version.value + "STABLE_VERSION" -> previousStableVersion.value.get, + "UNSTABLE_VERSION" -> version.value ), publishWebsite := Def .sequential( diff --git a/docs/getting-started.md b/docs/getting-started.md index 8244a482c5..18e79b6056 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -12,15 +12,18 @@ downloads and installs [Coursier](https://get-coursier.io/) and uses it to fetch the [Ammonite](https://ammonite.io) REPL and the latest version of Bitcoin-S. It then drops you into immediately into a REPL session. -``` -% curl -s https://raw.githubusercontent.com/bitcoin-s/bitcoin-s-core/master/try-bitcoin-s.sh | bash +```bash +$ curl -s https://raw.githubusercontent.com/bitcoin-s/bitcoin-s/master/try-bitcoin-s.sh | bash Loading... -Welcome to the Ammonite Repl 1.0.3 -(Scala 2.12.4 Java 1.8.0_152) -If you like Ammonite, please support our development at www.patreon.com/lihaoyi -@ 23 :: "foo" :: true :: HNil -res0: Int :: String :: Boolean :: HNil = 23 :: "foo" :: true :: HNil -% +Welcome the Bitcoin-S REPL, powered by Ammonite +Check out our documentation and examples at +https://bitcoin-s.org/docs/getting-started +@ val priv = ECPrivateKey() +@ val pub = priv.publicKey +@ val spk = P2WPKHWitnessSPKV0(pub) +@ val address = Bech32Address(spk, MainNet) +@ address.value # Tada! You've just made a Bech32 address +res4: String = "bc1q7ynsz7tamtnvlmts4snrl7e98jc9d8gqwsjsr5" ``` ## Build tools @@ -33,17 +36,39 @@ instructions for your build tool Add this to your `build.sbt`: ```scala -libraryDependencies +="org.bitcoins" % "bitcoin-s-secp256k1jni" % "@VERSION@" +libraryDependencies +="org.bitcoin-s" % "bitcoin-s-secp256k1jni" % "@STABLE_VERSION@" -libraryDependencies += "org.bitcoins" %% "bitcoin-s-core" % "@VERSION@" withSources() withJavadoc() +libraryDependencies += "org.bitcoin-s" %% "bitcoin-s-core" % "@STABLE_VERSION@" -libraryDependencies += "org.bitcoins" %% "bitcoin-s-bitcoind-rpc" % "@VERSION@" withSources() withJavadoc() +libraryDependencies += "org.bitcoin-s" %% "bitcoin-s-bitcoind-rpc" % "@STABLE_VERSION@" -libraryDependencies += "org.bitcoins" %% "bitcoin-s-eclair-rpc" % "@VERSION@" withSources() withJavadoc() +libraryDependencies += "org.bitcoin-s" %% "bitcoin-s-eclair-rpc" % "@STABLE_VERSION@" -libraryDependencies += "org.bitcoins" %% "bitcoin-s-testkit" % "@VERSION@" withSources() withJavadoc() +libraryDependencies += "org.bitcoin-s" %% "bitcoin-s-testkit" % "@STABLE_VERSION@" + +libraryDependencies += "org.bitcoin-s" %% "bitcoin-s-zmq" % "@STABLE_VERSION@" +``` + +```scala mdoc:passthrough +val isUnstable = "@UNSTABLE_VERSION" != "@STABLE_VERSION@" +if (isUnstable) { + println(s""" +### Nightly builds + +You can also run on the bleeding edge of Bitcoin-S, by +adding a snapshot build to your `build.sbt`. The most +recent snapshot published is `@UNSTABLE_VERSION@`. + +To fetch snapshot, you will need to add the correct +resolver in your `build.sbt`: + +```sbt +resolvers += Resolver.sonatypeRepo("snapshots") +${List.fill(3)("`").mkString /* Hacky solution to get around nesting backticks */ } + +""") +} -libraryDependencies += "org.bitcoins" %% "bitcoin-s-zmq" % "@VERSION@" withSources() withJavadoc() ``` ### Mill diff --git a/try-bitcoin-s.sh b/try-bitcoin-s.sh index d0351c2376..d85060475d 100644 --- a/try-bitcoin-s.sh +++ b/try-bitcoin-s.sh @@ -11,9 +11,15 @@ test -e ~/.coursier/coursier || \ (mkdir -p ~/.coursier && curl -L -s --output ~/.coursier/coursier $COURSIER_URL && chmod +x ~/.coursier/coursier) MSG="Welcome the Bitcoin-S REPL, powered by Ammonite -Check out our documentation at https://bitcoin-s.org" +Check out our documentation and examples at +https://bitcoin-s.org/docs/getting-started" +IMPORT_STATEMENT="import org.bitcoins.core._; import currency._, \ +protocol.blockchain._, number._, crypto._, hd._, protocol.script._, \ +protocol.ln, wallet.builder._, protocol.transaction._, \ +script._, config._, protocol._ " # launch Ammonite with bitcoin-s on the classpath ~/.coursier/coursier launch -q -P \ - com.lihaoyi:ammonite_2.12.4:latest.release \ - org.bitcoin-s:core.12:latest.release \ --- --predef-code 'import org.bitcoins.core._' --banner $MSG < /dev/tty \ No newline at end of file + com.lihaoyi:ammonite_2.12.8:1.6.0 \ + org.bitcoin-s:bitcoin-s-core_2.12:latest.release \ + -M ammonite.Main -- --banner "$MSG" \ + --predef-code "$IMPORT_STATEMENT" < /dev/tty \ No newline at end of file