mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2024-11-19 01:40:55 +01:00
Add server to sidebar.json so that it shows up (#981)
This commit is contained in:
parent
6a5918fa50
commit
78176af1e4
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: cli
|
||||
title: bitcoin-s cli
|
||||
title: cli
|
||||
---
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
---
|
||||
id: server
|
||||
title: bitcoin-s application server
|
||||
title: application server
|
||||
---
|
||||
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
"title": "Light client"
|
||||
},
|
||||
"applications/server": {
|
||||
"title": "applications/server"
|
||||
"title": "bitcoin-s application server"
|
||||
},
|
||||
"applications/wallet": {
|
||||
"title": "Wallet"
|
||||
@ -41,12 +41,18 @@
|
||||
"core/hd-keys": {
|
||||
"title": "HD key generation"
|
||||
},
|
||||
"core/sign": {
|
||||
"title": "Sign api"
|
||||
},
|
||||
"core/txbuilder": {
|
||||
"title": "TxBuilder example"
|
||||
},
|
||||
"getting-started": {
|
||||
"title": "Add Bitcoin-S to your project"
|
||||
},
|
||||
"key-manager/key-manager": {
|
||||
"title": "Key Manager"
|
||||
},
|
||||
"rpc/rpc-bitcoind": {
|
||||
"title": "bitcoind/Bitcoin Core"
|
||||
},
|
||||
@ -110,6 +116,9 @@
|
||||
"version-0.2.0/applications/version-0.2.0-node": {
|
||||
"title": "Light client"
|
||||
},
|
||||
"version-0.2.0/applications/version-0.2.0-server": {
|
||||
"title": "bitcoin-s application server"
|
||||
},
|
||||
"version-0.2.0/applications/version-0.2.0-wallet": {
|
||||
"title": "Wallet"
|
||||
},
|
||||
@ -128,12 +137,18 @@
|
||||
"version-0.2.0/core/version-0.2.0-hd-keys": {
|
||||
"title": "HD key generation"
|
||||
},
|
||||
"version-0.2.0/core/version-0.2.0-sign": {
|
||||
"title": "Sign api"
|
||||
},
|
||||
"version-0.2.0/core/version-0.2.0-txbuilder": {
|
||||
"title": "TxBuilder example"
|
||||
},
|
||||
"version-0.2.0/version-0.2.0-getting-started": {
|
||||
"title": "Add Bitcoin-S to your project"
|
||||
},
|
||||
"version-0.2.0/key-manager/version-0.2.0-key-manager": {
|
||||
"title": "Key Manager"
|
||||
},
|
||||
"version-0.2.0/rpc/version-0.2.0-rpc-bitcoind": {
|
||||
"title": "bitcoind/Bitcoin Core"
|
||||
},
|
||||
@ -143,8 +158,47 @@
|
||||
"version-0.2.0/rpc/version-0.2.0-rpc-clients-intro": {
|
||||
"title": "Introduction"
|
||||
},
|
||||
"version-0.2.0/version-0.2.0-security": {
|
||||
"title": "Security"
|
||||
},
|
||||
"version-0.2.0/version-0.2.0-windows-users": {
|
||||
"title": "windows-users"
|
||||
},
|
||||
"version-0.2/applications/version-0.2-server": {
|
||||
"title": "bitcoin-s application server"
|
||||
},
|
||||
"version-0.2/applications/version-0.2-wallet": {
|
||||
"title": "Wallet"
|
||||
},
|
||||
"version-0.2/version-0.2-contributing-website": {
|
||||
"title": "Contributing to the website"
|
||||
},
|
||||
"version-0.2/core/version-0.2-addresses": {
|
||||
"title": "Generating addresses"
|
||||
},
|
||||
"version-0.2/core/version-0.2-core-intro": {
|
||||
"title": "Core module"
|
||||
},
|
||||
"version-0.2/core/version-0.2-hd-keys": {
|
||||
"title": "HD key generation"
|
||||
},
|
||||
"version-0.2/core/version-0.2-sign": {
|
||||
"title": "Sign api"
|
||||
},
|
||||
"version-0.2/core/version-0.2-txbuilder": {
|
||||
"title": "TxBuilder example"
|
||||
},
|
||||
"version-0.2/version-0.2-getting-started": {
|
||||
"title": "Add Bitcoin-S to your project"
|
||||
},
|
||||
"version-0.2/key-manager/version-0.2-key-manager": {
|
||||
"title": "Key Manager"
|
||||
},
|
||||
"version-0.2/rpc/version-0.2-rpc-bitcoind": {
|
||||
"title": "bitcoind/Bitcoin Core"
|
||||
},
|
||||
"version-0.2/version-0.2-security": {
|
||||
"title": "Security"
|
||||
}
|
||||
},
|
||||
"links": {
|
||||
|
@ -111,22 +111,23 @@ val walletF: Future[LockedWalletApi] = configF.flatMap { _ =>
|
||||
|
||||
// when this future completes, ww have sent a transaction
|
||||
// from bitcoind to the Bitcoin-S wallet
|
||||
import org.bitcoins.core.protocol.transaction.Transaction
|
||||
import org.bitcoins.core.crypto._
|
||||
import org.bitcoins.core.protocol.transaction._
|
||||
import org.bitcoins.core.currency._
|
||||
val transactionF: Future[Transaction] = for {
|
||||
val transactionF: Future[(Transaction, Option[DoubleSha256DigestBE])] = for {
|
||||
wallet <- walletF
|
||||
address <- wallet.getNewAddress()
|
||||
txid <- bitcoind.sendToAddress(address, 3.bitcoin)
|
||||
transaction <- bitcoind.getRawTransaction(txid)
|
||||
} yield transaction.hex
|
||||
} yield (transaction.hex, transaction.blockhash)
|
||||
|
||||
// when this future completes, we have processed
|
||||
// the transaction from bitcoind, and we have
|
||||
// queried our balance for the current balance
|
||||
val balanceF: Future[CurrencyUnit] = for {
|
||||
wallet <- walletF
|
||||
tx <- transactionF
|
||||
_ <- wallet.processTransaction(tx, confirmations = 0)
|
||||
(tx, blockhash) <- transactionF
|
||||
_ <- wallet.processTransaction(tx, blockhash)
|
||||
balance <- wallet.getBalance
|
||||
} yield balance
|
||||
|
||||
|
@ -23,6 +23,7 @@ To generate Scaladocs:
|
||||
```bash
|
||||
$ sbt
|
||||
> unidoc
|
||||
> docs/mdoc
|
||||
```
|
||||
|
||||
This gets placed in `website/static/api`. When viewing the Docusaurus site the generated Scaladocs
|
||||
|
@ -36,9 +36,9 @@ import protocol.script._
|
||||
|
||||
// this generates a random private key
|
||||
val privkey = ECPrivateKey()
|
||||
// privkey: ECPrivateKey = ECPrivateKey(7f0fc482719d180ec8281100f977d6ad50ed1971b71d31026d513fb51bb95206,true)
|
||||
// privkey: ECPrivateKey = ECPrivateKey(6e7b7ba3c192ca7ecc3681f7eb1e021c9f1333a45c7ff88cace595ee5759aa69,true)
|
||||
val pubkey = privkey.publicKey
|
||||
// pubkey: crypto.ECPublicKey = ECPublicKey(03c585c7c1cd4e670683ec5f3a043a800f7f84ddf39d04a9fe4364802d85f1c756)
|
||||
// pubkey: crypto.ECPublicKey = ECPublicKey(0225ae3b07de8578ba6a9988872028f79d9cb46d703a39491dc8f91a74b93b0a8c)
|
||||
|
||||
val segwitAddress = {
|
||||
// see https://bitcoin.org/en/glossary/pubkey-script
|
||||
@ -47,7 +47,7 @@ val segwitAddress = {
|
||||
val scriptPubKey = P2WPKHWitnessSPKV0(pubkey)
|
||||
Bech32Address(scriptPubKey, TestNet3)
|
||||
}
|
||||
// segwitAddress: Bech32Address = Bech32Address(tb1q9vyukq9pt9kw0r70e5zpd06mkyk2m6qukd7uc9)
|
||||
// segwitAddress: Bech32Address = Bech32Address(tb1qydaft7sx02025te2e3hu4np87d65xg33ghzcwe)
|
||||
```
|
||||
|
||||
## Generating legacy (base58) addresses
|
||||
@ -63,5 +63,5 @@ import org.bitcoins.core.protocol.P2PKHAddress
|
||||
// we're reusing the same private/public key pair
|
||||
// from before. don't do this in an actual application!
|
||||
val legacyAddress = P2PKHAddress(pubkey, TestNet3)
|
||||
// legacyAddress: P2PKHAddress = mjSX5jLeUuAsmxLqzFEUMyjCKAKNo5WHJw
|
||||
// legacyAddress: P2PKHAddress = mikYoBWXrLKpagxwNLgMUyUVv6TEXvxDgz
|
||||
```
|
||||
|
@ -69,38 +69,6 @@ After providing this information, you can generate a validly signed bitcoin tran
|
||||
|
||||
To see a complete example of this, see [our `TxBuilder` example](txbuilder.md)
|
||||
|
||||
### The [`Sign` API](/api/org/bitcoins/core/crypto/Sign)
|
||||
|
||||
This is the API we define to sign things with. It takes in an arbitrary byte vector and returns a `Future[ECDigitalSignature]`. The reason we incorporate `Future`s here is for extensibility of this API. We would like to provide implementations of this API for hardware devices, which need to be asynchrnous since they may require user input.
|
||||
|
||||
From [`core/src/main/scala/org/bitcoins/core/crypto/Sign.scala`](/api/org/bitcoins/core/crypto/Sign):
|
||||
|
||||
```scala
|
||||
import scodec.bits._
|
||||
import org.bitcoins.core.crypto._
|
||||
import scala.concurrent._
|
||||
import scala.concurrent.duration._
|
||||
|
||||
trait Sign {
|
||||
def signFunction: ByteVector => Future[ECDigitalSignature]
|
||||
|
||||
def signFuture(bytes: ByteVector): Future[ECDigitalSignature] =
|
||||
signFunction(bytes)
|
||||
|
||||
def sign(bytes: ByteVector): ECDigitalSignature = {
|
||||
Await.result(signFuture(bytes), 30.seconds)
|
||||
}
|
||||
|
||||
def publicKey: ECPublicKey
|
||||
}
|
||||
```
|
||||
|
||||
The `ByteVector` that is input to the `signFunction` should be the hash that is output from [`TransactionSignatureSerializer`](/api/org/bitcoins/core/crypto/TransactionSignatureSerializer)'s `hashForSignature` method. Our in-memory [`ECKey`](/api/org/bitcoins/core/crypto/ECKey) types implement the `Sign` API.
|
||||
|
||||
If you wanted to implement a new `Sign` api for a hardware wallet, you can easily pass it into the `TxBuilder`/`Signer` classes to allow for you to use those devices to sign with Bitcoin-S.
|
||||
|
||||
This API is currently used to sign ordinary transactions with our [`Signer`](/api/org/bitcoins/core/wallet/signer/Signer)s. The `Signer` subtypes (i.e. `P2PKHSigner`) implement the specific functionality needed to produce a valid digital signature for their corresponding script type.
|
||||
|
||||
### Verifying a transaction's script is valid (does not check if UTXO is valid)
|
||||
|
||||
Transactions are run through the interpreter to check their validity. These are packaged up into an object called `ScriptProgram`, which contains the following:
|
||||
|
@ -30,13 +30,13 @@ import org.bitcoins.core.hd._
|
||||
// how long our phrase ends up being
|
||||
// 256 bits of entropy results in 24 words
|
||||
val entropy: BitVector = MnemonicCode.getEntropy256Bits
|
||||
// entropy: BitVector = BitVector(256 bits, 0x39f30e63d03882325006e97c5a15e6d471a4c7d35112569d2352b052a091e3cf)
|
||||
// entropy: BitVector = BitVector(256 bits, 0x8c462348afe97eef714535da78e85cba3fea90da954d0b4574f43104b0ded45c)
|
||||
|
||||
val mnemonicCode = MnemonicCode.fromEntropy(entropy)
|
||||
// mnemonicCode: MnemonicCode = MnemonicCodeImpl(Vector(delay, observe, ocean, parrot, market, bomb, divorce, tag, labor, spawn, keen, pottery, bottom, glue, essence, car, final, trouble, start, gaze, claw, employ, monkey, type))
|
||||
// mnemonicCode: MnemonicCode = MnemonicCodeImpl(Vector(middle, country, split, garlic, obey, jeans, shallow, pluck, surprise, shrug, blame, inner, wrong, embody, heart, predict, area, close, dial, ginger, enrich, hunt, fabric, mask))
|
||||
|
||||
mnemonicCode.words // the phrase the user should write down
|
||||
// res0: Vector[String] = Vector(delay, observe, ocean, parrot, market, bomb, divorce, tag, labor, spawn, keen, pottery, bottom, glue, essence, car, final, trouble, start, gaze, claw, employ, monkey, type) // the phrase the user should write down
|
||||
// res0: Vector[String] = Vector(middle, country, split, garlic, obey, jeans, shallow, pluck, surprise, shrug, blame, inner, wrong, embody, heart, predict, area, close, dial, ginger, enrich, hunt, fabric, mask) // the phrase the user should write down
|
||||
|
||||
// the password argument is an optional, extra security
|
||||
// measure. all MnemonicCode instances will give you a
|
||||
@ -46,13 +46,13 @@ mnemonicCode.words // the phrase the user should write down
|
||||
// different passwords.
|
||||
val bip39Seed = BIP39Seed.fromMnemonic(mnemonicCode,
|
||||
password = "secret password")
|
||||
// bip39Seed: BIP39Seed = BIP39SeedImpl(ByteVector(64 bytes, 0xd45cc7ef7aa2aae1a8cd90c91a4f79b866dd00a10cf8cdaae157a822167a4cc740b7364eb43f1474d8c86473db4faf845e6a9e3fd06ee39eeb493c751a0cdfee))
|
||||
// bip39Seed: BIP39Seed = BIP39SeedImpl(ByteVector(64 bytes, 0xed5dc8b858bf78427b4fb26645c79e59b777201281549c224b56efbae399846e5b03f284b05bad1499880b10a0592c3ac9a7b01842ced609ec83ccf134e14727))
|
||||
|
||||
val xpriv = ExtPrivateKey.fromBIP39Seed(ExtKeyVersion.SegWitMainNetPriv,
|
||||
bip39Seed)
|
||||
// xpriv: ExtPrivateKey = zprvAWgYBBk7JR8GjukHugLbrUkjRE3ycvmhRCT4cE2T2qU53j18nUjL4ocaDsXwBWYzU5u88ZFxQ42YWMLAT1S5V2wwcxgogsMrDQtNeLBwr3D
|
||||
// xpriv: ExtPrivateKey = zprvAWgYBBk7JR8GkeTo5WZtXUmTSjUXxw8kcA5LdBR8ySCKiXrGfLmCgSbdhrr1RtSjHe19Fc7BACFh5qfArFr5nf7WXaqGLgudpAdG7VzkGM5
|
||||
val xpub = xpriv.extPublicKey
|
||||
// xpub: ExtPublicKey = zpub6jftahH18ngZxPpm1hscDchTyFtU2PVYnRNfQcS4bB13vXLHL23acbw459g4XxYYHfo44rTmYSXzBQzzBEVqT3PfPcqL69fpdrgkxMHuQCy
|
||||
// xpub: ExtPublicKey = zpub6jftahH18ngZy8YGBY6ttciBzmK2NPrbyNzwRZpkXmjJbLBRCt5TEEv7Z6zRHkkrTR9nYzsUCry97Ru7NVqyMtbRreTo3WWqMdHxzj38dp4
|
||||
|
||||
// you can now use the generated xpriv to derive further
|
||||
// private or public keys
|
||||
@ -103,7 +103,7 @@ val accountXpub = {
|
||||
// can generate addresses with it!
|
||||
accountXpriv.extPublicKey
|
||||
}
|
||||
// accountXpub: ExtPublicKey = zpub6qUM2b9Nq9v51X1sPsXpXWznJnBhvhHUfhrXvMFntXQT8ZkK2tizi29cMm2HH3vb1Zz8CHb3933J9tvaH97GS4s6XUZQsrTYf7cWGYtmYLA
|
||||
// accountXpub: ExtPublicKey = zpub6rFK5YgNZ4VPaRxHLRp5sdC3TeWhEUjxuBm38y4tmH8M4RyA3QuxGEJVuq4YnRVxXdcjj4JajgGV787yGTKZM1SBK2Q1z4ZqJrV6uzewamM
|
||||
|
||||
// address no. 0 ---------------┐
|
||||
// external address ----------┐ |
|
||||
@ -126,12 +126,12 @@ val firstAccountAddress = {
|
||||
val scriptPubKey = P2WPKHWitnessSPKV0(pubkey)
|
||||
Bech32Address(scriptPubKey, TestNet3)
|
||||
}
|
||||
// firstAccountAddress: Bech32Address = Bech32Address(tb1quqvdsqdzt2nlszkfqsxndu5pg6ahzyjk2e5qmz)
|
||||
// firstAccountAddress: Bech32Address = Bech32Address(tb1qypxkhchu805aprywl8e4eezfqkkkwa39gj2qeu)
|
||||
|
||||
// tada! We just generated an address you can send money to,
|
||||
// without having access to the private key!
|
||||
firstAccountAddress.value
|
||||
// res2: String = tb1quqvdsqdzt2nlszkfqsxndu5pg6ahzyjk2e5qmz
|
||||
// res2: String = tb1qypxkhchu805aprywl8e4eezfqkkkwa39gj2qeu
|
||||
|
||||
// you can now continue deriving addresses from the same public
|
||||
// key, by imitating what we did above. To get the next
|
||||
@ -139,3 +139,7 @@ firstAccountAddress.value
|
||||
val nextAddressPath: SegWitHDPath = firstAddressPath.next
|
||||
// nextAddressPath: SegWitHDPath = m/84'/0'/0'/0/1
|
||||
```
|
||||
|
||||
### Signing things with HD keys
|
||||
|
||||
Please see [sign.md](sign.md) for information on how to sign things with HD keys.
|
@ -134,5 +134,5 @@ signedTx.outputs.length
|
||||
|
||||
//remember, you can call .hex on any bitcoin-s data structure to get the hex representation!
|
||||
signedTx.hex
|
||||
// res2: String = "0200000001aaa194af011ead436c86eddd507b9a02fc7b15b190d6975fa68757f5cf6ef640000000006a473044022070862947a8ee417f0873e9edb9484684c3671b109e1f69403135220bf4c9687c02207d2395edb2a88522d42fb3e34c6e86f8b81b333b18759dfb6a78ed978d30a07c01210342b79cc77b59e28a5f569348e9efd5fa9a37982f18c1d29b0818bc8890a1c60b000000000288130000000000001976a9146c9e69cc34268e73bbf02c0819d92db359385cd188aca6120000000000001976a914e5050227c7823cb7c5da0f8d879b1562b4ca581c88ac00000000"
|
||||
// res2: String = "020000000105ce42dbf90341da072dd5c55ae5a1c4d18fccc617ae95aa91d4f0c8721436ec000000006b483045022100cb92bb8e229baf1a91143dec4ebbd5e042e59c6d414af0155f807fe794015f860220010bb5fa4a4bd47443e9126763ad99427d13d783f265fa5ed16663c4c61a80b2012103beb6c43fc354dff73c504d056160c23a7683171dd82726fd4c3f45a92c90bda2000000000288130000000000001976a9141fef0151debc8f755c716f64fbf579fe627d4c3588aca6120000000000001976a91429219d3b85bf55540cbc64445f6ed85bc18af25c88ac00000000"
|
||||
```
|
||||
|
@ -55,7 +55,7 @@ libraryDependencies += "org.bitcoin-s" %% "bitcoin-s-zmq" % "0.2.0"
|
||||
|
||||
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 `0.2.0+113-52351447+20191215-2018-SNAPSHOT`.
|
||||
recent snapshot published is `0.2.0+129-56f20393+20191222-0903-SNAPSHOT`.
|
||||
|
||||
To fetch snapshots, you will need to add the correct
|
||||
resolver in your `build.sbt`:
|
||||
|
@ -6,7 +6,7 @@ original_id: rpc-bitcoind
|
||||
|
||||
> Note: `bitcoin-s-bitcoind-rpc` requires you to have `bitcoind` (Bitcoin Core daemon) installed. Grab this at [bitcoincore.org](https://bitcoincore.org/en/download/)
|
||||
|
||||
The Bitcoin Core RPC client in Bitcoin-S currently supports the Bitcoin Core 0.16 and 0.17
|
||||
The Bitcoin Core RPC client in Bitcoin-S currently supports the Bitcoin Core 0.16, 0.17, 0.18, and 0.19
|
||||
version lines. It can be set up to work with both local and remote Bitcoin Core servers.
|
||||
|
||||
## Connecting to a local `bitcoind` instance
|
||||
|
@ -7,6 +7,7 @@
|
||||
"version-0.2.0-core/core-intro",
|
||||
"version-0.2.0-core/addresses",
|
||||
"version-0.2.0-core/hd-keys",
|
||||
"version-0.2.0-core/sign",
|
||||
"version-0.2.0-core/txbuilder"
|
||||
],
|
||||
"RPC clients": [
|
||||
|
Loading…
Reference in New Issue
Block a user