mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-18 21:22:04 +01:00
parent
4f3984a9e8
commit
8a22077d56
8 changed files with 30 additions and 30 deletions
|
@ -78,9 +78,9 @@ reason to keep using legacy transaction formats.</p>
|
|||
|
||||
<span class="hljs-comment">// this generates a random private key</span>
|
||||
<span class="hljs-keyword">val</span> privkey = <span class="hljs-type">ECPrivateKey</span>()
|
||||
<span class="hljs-comment">// privkey: ECPrivateKey = ECPrivateKey(daa301d22b1df44fc4614848bf44d458b67a3dc455d9c49a88ab878aebb38600,true)</span>
|
||||
<span class="hljs-comment">// privkey: ECPrivateKey = ECPrivateKey(6e9e795bbe61e1318ca408bb3327d01cf66b9cea311f18ab942ed8046064807b,true)</span>
|
||||
<span class="hljs-keyword">val</span> pubkey = privkey.publicKey
|
||||
<span class="hljs-comment">// pubkey: crypto.ECPublicKey = ECPublicKey(0266e67e530acf703830a36da46fca6618166b05c48c075ad53578e123b0b4459f)</span>
|
||||
<span class="hljs-comment">// pubkey: crypto.ECPublicKey = ECPublicKey(03a16d625c86170dddb65884a33d65febcac21d2aebf4b7ee7c347873b9eed3e61)</span>
|
||||
|
||||
<span class="hljs-keyword">val</span> segwitAddress = {
|
||||
<span class="hljs-comment">// see https://bitcoin.org/en/glossary/pubkey-script</span>
|
||||
|
@ -89,7 +89,7 @@ reason to keep using legacy transaction formats.</p>
|
|||
<span class="hljs-keyword">val</span> scriptPubKey = <span class="hljs-type">P2WPKHWitnessSPKV0</span>(pubkey)
|
||||
<span class="hljs-type">Bech32Address</span>(scriptPubKey, <span class="hljs-type">TestNet3</span>)
|
||||
}
|
||||
<span class="hljs-comment">// segwitAddress: Bech32Address = Bech32Address(tb1qcs9xmkyamgvpekdxcr0xl0nl0l9ym9mylzlsd3)</span>
|
||||
<span class="hljs-comment">// segwitAddress: Bech32Address = Bech32Address(tb1qyavyxzcxtzxjltu8c4g86ad4wfmuv4rr25zdz7)</span>
|
||||
</code></pre>
|
||||
<h2><a class="anchor" aria-hidden="true" id="generating-legacy-base58-addresses"></a><a href="#generating-legacy-base58-addresses" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Generating legacy (base58) addresses</h2>
|
||||
<p>If you need to generate legacy addresses for backwards
|
||||
|
@ -101,7 +101,7 @@ Take a look:</p>
|
|||
<span class="hljs-comment">// we're reusing the same private/public key pair</span>
|
||||
<span class="hljs-comment">// from before. don't do this in an actual application!</span>
|
||||
<span class="hljs-keyword">val</span> legacyAddress = <span class="hljs-type">P2PKHAddress</span>(pubkey, <span class="hljs-type">TestNet3</span>)
|
||||
<span class="hljs-comment">// legacyAddress: P2PKHAddress = myPXEH6ruEgeDbEmwVo7eSNhF2TrVWdAUG</span>
|
||||
<span class="hljs-comment">// legacyAddress: P2PKHAddress = mj6zP5XRPRqU1sZB2BDCSoUXwsbxjcXnsP</span>
|
||||
</code></pre>
|
||||
</span></div></article></div><div class="docs-prevnext"><a class="docs-prev button" href="/docs/next/core/core-intro"><span class="arrow-prev">← </span><span>Core module</span></a><a class="docs-next button" href="/docs/next/core/hd-keys"><span>HD key generation</span><span class="arrow-next"> →</span></a></div></div></div><nav class="onPageNav"><ul class="toc-headings"><li><a href="#generating-segwit-bech32-addresses">Generating SegWit (bech32) addresses</a></li><li><a href="#generating-legacy-base58-addresses">Generating legacy (base58) addresses</a></li></ul></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><a href="/" class="nav-home"><img src="/img/favicon.ico" alt="bitcoin-s" width="66" height="58"/></a><div><h5>Docs</h5><a href="/docs/en/getting-started">Getting Started</a><a href="/docs/en/core/core-intro">Guides</a><a href="/api/org/bitcoins">API Reference</a></div><div><h5>Community</h5><a href="/en/users.html">User Showcase</a><a href="https://join.slack.com/t/suredbits/shared_invite/enQtNDEyMjY3MTg1MTg3LTYyYjkwOGUzMDQ4NDAwZjE1M2I3MmQyNWNlZjNlYjg4OGRjYTRjNWUwNjRjNjg4Y2NjZjAxYjU1N2JjMTU1YWM" target="_blank" rel="noreferrer noopener">Slack</a><a href="https://gitter.im/bitcoin-s-core/">Gitter chat</a></div><div><h5>More</h5><a href="https://github.com/bitcoin-s/bitcoin-s">GitHub</a><a class="github-button" href="https://github.com/bitcoin-s/bitcoin-s" data-icon="octicon-star" data-count-href="/bitcoin-s/bitcoin-s-core/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star this project on GitHub">Star</a></div></section><section class="copyright">Copyright © 2019 Suredbits & the bitcoin-s developers</section></footer></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.js"></script><script>
|
||||
document.addEventListener('keyup', function(e) {
|
||||
|
|
|
@ -78,9 +78,9 @@ reason to keep using legacy transaction formats.</p>
|
|||
|
||||
<span class="hljs-comment">// this generates a random private key</span>
|
||||
<span class="hljs-keyword">val</span> privkey = <span class="hljs-type">ECPrivateKey</span>()
|
||||
<span class="hljs-comment">// privkey: ECPrivateKey = ECPrivateKey(daa301d22b1df44fc4614848bf44d458b67a3dc455d9c49a88ab878aebb38600,true)</span>
|
||||
<span class="hljs-comment">// privkey: ECPrivateKey = ECPrivateKey(6e9e795bbe61e1318ca408bb3327d01cf66b9cea311f18ab942ed8046064807b,true)</span>
|
||||
<span class="hljs-keyword">val</span> pubkey = privkey.publicKey
|
||||
<span class="hljs-comment">// pubkey: crypto.ECPublicKey = ECPublicKey(0266e67e530acf703830a36da46fca6618166b05c48c075ad53578e123b0b4459f)</span>
|
||||
<span class="hljs-comment">// pubkey: crypto.ECPublicKey = ECPublicKey(03a16d625c86170dddb65884a33d65febcac21d2aebf4b7ee7c347873b9eed3e61)</span>
|
||||
|
||||
<span class="hljs-keyword">val</span> segwitAddress = {
|
||||
<span class="hljs-comment">// see https://bitcoin.org/en/glossary/pubkey-script</span>
|
||||
|
@ -89,7 +89,7 @@ reason to keep using legacy transaction formats.</p>
|
|||
<span class="hljs-keyword">val</span> scriptPubKey = <span class="hljs-type">P2WPKHWitnessSPKV0</span>(pubkey)
|
||||
<span class="hljs-type">Bech32Address</span>(scriptPubKey, <span class="hljs-type">TestNet3</span>)
|
||||
}
|
||||
<span class="hljs-comment">// segwitAddress: Bech32Address = Bech32Address(tb1qcs9xmkyamgvpekdxcr0xl0nl0l9ym9mylzlsd3)</span>
|
||||
<span class="hljs-comment">// segwitAddress: Bech32Address = Bech32Address(tb1qyavyxzcxtzxjltu8c4g86ad4wfmuv4rr25zdz7)</span>
|
||||
</code></pre>
|
||||
<h2><a class="anchor" aria-hidden="true" id="generating-legacy-base58-addresses"></a><a href="#generating-legacy-base58-addresses" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Generating legacy (base58) addresses</h2>
|
||||
<p>If you need to generate legacy addresses for backwards
|
||||
|
@ -101,7 +101,7 @@ Take a look:</p>
|
|||
<span class="hljs-comment">// we're reusing the same private/public key pair</span>
|
||||
<span class="hljs-comment">// from before. don't do this in an actual application!</span>
|
||||
<span class="hljs-keyword">val</span> legacyAddress = <span class="hljs-type">P2PKHAddress</span>(pubkey, <span class="hljs-type">TestNet3</span>)
|
||||
<span class="hljs-comment">// legacyAddress: P2PKHAddress = myPXEH6ruEgeDbEmwVo7eSNhF2TrVWdAUG</span>
|
||||
<span class="hljs-comment">// legacyAddress: P2PKHAddress = mj6zP5XRPRqU1sZB2BDCSoUXwsbxjcXnsP</span>
|
||||
</code></pre>
|
||||
</span></div></article></div><div class="docs-prevnext"><a class="docs-prev button" href="/docs/next/core/core-intro"><span class="arrow-prev">← </span><span>Core module</span></a><a class="docs-next button" href="/docs/next/core/hd-keys"><span>HD key generation</span><span class="arrow-next"> →</span></a></div></div></div><nav class="onPageNav"><ul class="toc-headings"><li><a href="#generating-segwit-bech32-addresses">Generating SegWit (bech32) addresses</a></li><li><a href="#generating-legacy-base58-addresses">Generating legacy (base58) addresses</a></li></ul></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><a href="/" class="nav-home"><img src="/img/favicon.ico" alt="bitcoin-s" width="66" height="58"/></a><div><h5>Docs</h5><a href="/docs/en/getting-started">Getting Started</a><a href="/docs/en/core/core-intro">Guides</a><a href="/api/org/bitcoins">API Reference</a></div><div><h5>Community</h5><a href="/en/users.html">User Showcase</a><a href="https://join.slack.com/t/suredbits/shared_invite/enQtNDEyMjY3MTg1MTg3LTYyYjkwOGUzMDQ4NDAwZjE1M2I3MmQyNWNlZjNlYjg4OGRjYTRjNWUwNjRjNjg4Y2NjZjAxYjU1N2JjMTU1YWM" target="_blank" rel="noreferrer noopener">Slack</a><a href="https://gitter.im/bitcoin-s-core/">Gitter chat</a></div><div><h5>More</h5><a href="https://github.com/bitcoin-s/bitcoin-s">GitHub</a><a class="github-button" href="https://github.com/bitcoin-s/bitcoin-s" data-icon="octicon-star" data-count-href="/bitcoin-s/bitcoin-s-core/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star this project on GitHub">Star</a></div></section><section class="copyright">Copyright © 2019 Suredbits & the bitcoin-s developers</section></footer></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.js"></script><script>
|
||||
document.addEventListener('keyup', function(e) {
|
||||
|
|
|
@ -74,13 +74,13 @@ use that to generate further private and public keys:</p>
|
|||
<span class="hljs-comment">// how long our phrase ends up being</span>
|
||||
<span class="hljs-comment">// 256 bits of entropy results in 24 words</span>
|
||||
<span class="hljs-keyword">val</span> entropy: <span class="hljs-type">BitVector</span> = <span class="hljs-type">MnemonicCode</span>.getEntropy256Bits
|
||||
<span class="hljs-comment">// entropy: BitVector = BitVector(256 bits, 0x67d4e889430b0edb0deb5082feddbf141acda9c540e481f33023cdfbf7e24f67)</span>
|
||||
<span class="hljs-comment">// entropy: BitVector = BitVector(256 bits, 0x24a6a8b463e5d5a36c4538ce30cc58657486ba7c1d25ec9a53f8ab05305486e1)</span>
|
||||
|
||||
<span class="hljs-keyword">val</span> mnemonicCode = <span class="hljs-type">MnemonicCode</span>.fromEntropy(entropy)
|
||||
<span class="hljs-comment">// mnemonicCode: MnemonicCode = MnemonicCodeImpl(Vector(guitar, point, car, maid, rail, horn, dash, head, load, want, hurt, choice, proud, stay, bench, broken, limit, office, angry, orbit, satoshi, van, diesel, vintage))</span>
|
||||
<span class="hljs-comment">// mnemonicCode: MnemonicCode = MnemonicCodeImpl(Vector(caution, crystal, code, sick, front, spider, rain, poem, soda, major, bid, slab, embody, frog, vacant, pigeon, uncle, spoon, wreck, figure, fantasy, clean, breeze, connect))</span>
|
||||
|
||||
mnemonicCode.words <span class="hljs-comment">// the phrase the user should write down</span>
|
||||
<span class="hljs-comment">// res0: Vector[String] = Vector(guitar, point, car, maid, rail, horn, dash, head, load, want, hurt, choice, proud, stay, bench, broken, limit, office, angry, orbit, satoshi, van, diesel, vintage) // the phrase the user should write down</span>
|
||||
<span class="hljs-comment">// res0: Vector[String] = Vector(caution, crystal, code, sick, front, spider, rain, poem, soda, major, bid, slab, embody, frog, vacant, pigeon, uncle, spoon, wreck, figure, fantasy, clean, breeze, connect) // the phrase the user should write down</span>
|
||||
|
||||
<span class="hljs-comment">// the password argument is an optional, extra security</span>
|
||||
<span class="hljs-comment">// measure. all MnemonicCode instances will give you a</span>
|
||||
|
@ -90,13 +90,13 @@ mnemonicCode.words <span class="hljs-comment">// the phrase the user should writ
|
|||
<span class="hljs-comment">// different passwords.</span>
|
||||
<span class="hljs-keyword">val</span> bip39Seed = <span class="hljs-type">BIP39Seed</span>.fromMnemonic(mnemonicCode,
|
||||
password = <span class="hljs-string">"secret password"</span>)
|
||||
<span class="hljs-comment">// bip39Seed: BIP39Seed = BIP39SeedImpl(ByteVector(64 bytes, 0xc004327975d130d99f55ca3b51d824be4f2a281160555d1fdcc0bbbac35b20200b059af7c3919f711874c9b933d691de06826eaad7e6fafa8029dc21fb1d88ec))</span>
|
||||
<span class="hljs-comment">// bip39Seed: BIP39Seed = BIP39SeedImpl(ByteVector(64 bytes, 0x0a438fbded89688adbc233066fc0c8a45a6243188f2f67562bd953694668f3b2d6acfa2c477f048f739976c0204c6204652a7cfb848ea7b612ad1820a6603299))</span>
|
||||
|
||||
<span class="hljs-keyword">val</span> xpriv = <span class="hljs-type">ExtPrivateKey</span>.fromBIP39Seed(<span class="hljs-type">ExtKeyVersion</span>.<span class="hljs-type">SegWitMainNetPriv</span>,
|
||||
bip39Seed)
|
||||
<span class="hljs-comment">// xpriv: ExtPrivateKey = zprvAWgYBBk7JR8Gkdz2aNqdKZHTFxSsgJx8EEZ4hy8X6ZCYJPRf1ySetG8QbVrg77hPsy18LgaHWbu6Z3NTpfLfRCwVEsiVP9XqkbUvvAgACwH</span>
|
||||
<span class="hljs-comment">// xpriv: ExtPrivateKey = zprvAWgYBBk7JR8Gj9jYFNaWZ1q1PSodi3FzXSeQuMkWxK6kD1fSFACxAGehgw3BDms9fzqJi9HJY5FyFqxBQYn238M5r1S6nAvt2duj8c2Hwi7</span>
|
||||
<span class="hljs-keyword">val</span> xpub = xpriv.extPublicKey
|
||||
<span class="hljs-comment">// xpub: ExtPublicKey = zpub6jftahH18ngZy84VgQNdghEBozHN5mfybTUfWMY8etjXBBkoZWkuS4StSmvUywjtPaic4EZtmafQYYhkfmWdZrbsegPS8dGySa5tgQF9GJS</span>
|
||||
<span class="hljs-comment">// xpub: ExtPublicKey = zpub6jftahH18ngZwdp1MQ7Wv9mjwUe87Vyqtfa1hkA8Wedj5ozanhXCi4yBYDqedwYjsTtYAciQkRPnUUofLkqvhqGz7pPZeWSGuiXK9mkGisJ</span>
|
||||
|
||||
<span class="hljs-comment">// you can now use the generated xpriv to derive further</span>
|
||||
<span class="hljs-comment">// private or public keys</span>
|
||||
|
@ -142,7 +142,7 @@ spend or steal any of your money.</p>
|
|||
<span class="hljs-comment">// can generate addresses with it!</span>
|
||||
accountXpriv.extPublicKey
|
||||
}
|
||||
<span class="hljs-comment">// accountXpub: ExtPublicKey = zpub6rohRdg3BuGn6o8Di1co1Va1gRKEV6dy1sDrbtQ3xLVUwW5iUBivzepNNyrL3qMGxbyMhe87sZLjz7vrXd8qhV8TwhVypXyEjCLhtvVi9ps</span>
|
||||
<span class="hljs-comment">// accountXpub: ExtPublicKey = zpub6s6qgxRN6nKd4y9Cvf59AKA2YTf32mq6tMobA43vMdgaWh5ioLWWjTghLcPykYk4AYX9viVTGYbzrz6Exof1Kpyk6FkCzNb4MDwygNYWpCJ</span>
|
||||
|
||||
<span class="hljs-comment">// address no. 0 ---------------┐</span>
|
||||
<span class="hljs-comment">// external address ----------┐ |</span>
|
||||
|
@ -165,12 +165,12 @@ spend or steal any of your money.</p>
|
|||
<span class="hljs-keyword">val</span> scriptPubKey = <span class="hljs-type">P2WPKHWitnessSPKV0</span>(pubkey)
|
||||
<span class="hljs-type">Bech32Address</span>(scriptPubKey, <span class="hljs-type">TestNet3</span>)
|
||||
}
|
||||
<span class="hljs-comment">// firstAccountAddress: Bech32Address = Bech32Address(tb1qryac80j6n3alq4ueflldn6fhc5603s57g6ww2m)</span>
|
||||
<span class="hljs-comment">// firstAccountAddress: Bech32Address = Bech32Address(tb1qnzwrxyja36jxygrvnz8duern6dgym7qjkgazsr)</span>
|
||||
|
||||
<span class="hljs-comment">// tada! We just generated an address you can send money to,</span>
|
||||
<span class="hljs-comment">// without having access to the private key!</span>
|
||||
firstAccountAddress.value
|
||||
<span class="hljs-comment">// res2: String = tb1qryac80j6n3alq4ueflldn6fhc5603s57g6ww2m</span>
|
||||
<span class="hljs-comment">// res2: String = tb1qnzwrxyja36jxygrvnz8duern6dgym7qjkgazsr</span>
|
||||
|
||||
<span class="hljs-comment">// you can now continue deriving addresses from the same public</span>
|
||||
<span class="hljs-comment">// key, by imitating what we did above. To get the next</span>
|
||||
|
|
|
@ -74,13 +74,13 @@ use that to generate further private and public keys:</p>
|
|||
<span class="hljs-comment">// how long our phrase ends up being</span>
|
||||
<span class="hljs-comment">// 256 bits of entropy results in 24 words</span>
|
||||
<span class="hljs-keyword">val</span> entropy: <span class="hljs-type">BitVector</span> = <span class="hljs-type">MnemonicCode</span>.getEntropy256Bits
|
||||
<span class="hljs-comment">// entropy: BitVector = BitVector(256 bits, 0x67d4e889430b0edb0deb5082feddbf141acda9c540e481f33023cdfbf7e24f67)</span>
|
||||
<span class="hljs-comment">// entropy: BitVector = BitVector(256 bits, 0x24a6a8b463e5d5a36c4538ce30cc58657486ba7c1d25ec9a53f8ab05305486e1)</span>
|
||||
|
||||
<span class="hljs-keyword">val</span> mnemonicCode = <span class="hljs-type">MnemonicCode</span>.fromEntropy(entropy)
|
||||
<span class="hljs-comment">// mnemonicCode: MnemonicCode = MnemonicCodeImpl(Vector(guitar, point, car, maid, rail, horn, dash, head, load, want, hurt, choice, proud, stay, bench, broken, limit, office, angry, orbit, satoshi, van, diesel, vintage))</span>
|
||||
<span class="hljs-comment">// mnemonicCode: MnemonicCode = MnemonicCodeImpl(Vector(caution, crystal, code, sick, front, spider, rain, poem, soda, major, bid, slab, embody, frog, vacant, pigeon, uncle, spoon, wreck, figure, fantasy, clean, breeze, connect))</span>
|
||||
|
||||
mnemonicCode.words <span class="hljs-comment">// the phrase the user should write down</span>
|
||||
<span class="hljs-comment">// res0: Vector[String] = Vector(guitar, point, car, maid, rail, horn, dash, head, load, want, hurt, choice, proud, stay, bench, broken, limit, office, angry, orbit, satoshi, van, diesel, vintage) // the phrase the user should write down</span>
|
||||
<span class="hljs-comment">// res0: Vector[String] = Vector(caution, crystal, code, sick, front, spider, rain, poem, soda, major, bid, slab, embody, frog, vacant, pigeon, uncle, spoon, wreck, figure, fantasy, clean, breeze, connect) // the phrase the user should write down</span>
|
||||
|
||||
<span class="hljs-comment">// the password argument is an optional, extra security</span>
|
||||
<span class="hljs-comment">// measure. all MnemonicCode instances will give you a</span>
|
||||
|
@ -90,13 +90,13 @@ mnemonicCode.words <span class="hljs-comment">// the phrase the user should writ
|
|||
<span class="hljs-comment">// different passwords.</span>
|
||||
<span class="hljs-keyword">val</span> bip39Seed = <span class="hljs-type">BIP39Seed</span>.fromMnemonic(mnemonicCode,
|
||||
password = <span class="hljs-string">"secret password"</span>)
|
||||
<span class="hljs-comment">// bip39Seed: BIP39Seed = BIP39SeedImpl(ByteVector(64 bytes, 0xc004327975d130d99f55ca3b51d824be4f2a281160555d1fdcc0bbbac35b20200b059af7c3919f711874c9b933d691de06826eaad7e6fafa8029dc21fb1d88ec))</span>
|
||||
<span class="hljs-comment">// bip39Seed: BIP39Seed = BIP39SeedImpl(ByteVector(64 bytes, 0x0a438fbded89688adbc233066fc0c8a45a6243188f2f67562bd953694668f3b2d6acfa2c477f048f739976c0204c6204652a7cfb848ea7b612ad1820a6603299))</span>
|
||||
|
||||
<span class="hljs-keyword">val</span> xpriv = <span class="hljs-type">ExtPrivateKey</span>.fromBIP39Seed(<span class="hljs-type">ExtKeyVersion</span>.<span class="hljs-type">SegWitMainNetPriv</span>,
|
||||
bip39Seed)
|
||||
<span class="hljs-comment">// xpriv: ExtPrivateKey = zprvAWgYBBk7JR8Gkdz2aNqdKZHTFxSsgJx8EEZ4hy8X6ZCYJPRf1ySetG8QbVrg77hPsy18LgaHWbu6Z3NTpfLfRCwVEsiVP9XqkbUvvAgACwH</span>
|
||||
<span class="hljs-comment">// xpriv: ExtPrivateKey = zprvAWgYBBk7JR8Gj9jYFNaWZ1q1PSodi3FzXSeQuMkWxK6kD1fSFACxAGehgw3BDms9fzqJi9HJY5FyFqxBQYn238M5r1S6nAvt2duj8c2Hwi7</span>
|
||||
<span class="hljs-keyword">val</span> xpub = xpriv.extPublicKey
|
||||
<span class="hljs-comment">// xpub: ExtPublicKey = zpub6jftahH18ngZy84VgQNdghEBozHN5mfybTUfWMY8etjXBBkoZWkuS4StSmvUywjtPaic4EZtmafQYYhkfmWdZrbsegPS8dGySa5tgQF9GJS</span>
|
||||
<span class="hljs-comment">// xpub: ExtPublicKey = zpub6jftahH18ngZwdp1MQ7Wv9mjwUe87Vyqtfa1hkA8Wedj5ozanhXCi4yBYDqedwYjsTtYAciQkRPnUUofLkqvhqGz7pPZeWSGuiXK9mkGisJ</span>
|
||||
|
||||
<span class="hljs-comment">// you can now use the generated xpriv to derive further</span>
|
||||
<span class="hljs-comment">// private or public keys</span>
|
||||
|
@ -142,7 +142,7 @@ spend or steal any of your money.</p>
|
|||
<span class="hljs-comment">// can generate addresses with it!</span>
|
||||
accountXpriv.extPublicKey
|
||||
}
|
||||
<span class="hljs-comment">// accountXpub: ExtPublicKey = zpub6rohRdg3BuGn6o8Di1co1Va1gRKEV6dy1sDrbtQ3xLVUwW5iUBivzepNNyrL3qMGxbyMhe87sZLjz7vrXd8qhV8TwhVypXyEjCLhtvVi9ps</span>
|
||||
<span class="hljs-comment">// accountXpub: ExtPublicKey = zpub6s6qgxRN6nKd4y9Cvf59AKA2YTf32mq6tMobA43vMdgaWh5ioLWWjTghLcPykYk4AYX9viVTGYbzrz6Exof1Kpyk6FkCzNb4MDwygNYWpCJ</span>
|
||||
|
||||
<span class="hljs-comment">// address no. 0 ---------------┐</span>
|
||||
<span class="hljs-comment">// external address ----------┐ |</span>
|
||||
|
@ -165,12 +165,12 @@ spend or steal any of your money.</p>
|
|||
<span class="hljs-keyword">val</span> scriptPubKey = <span class="hljs-type">P2WPKHWitnessSPKV0</span>(pubkey)
|
||||
<span class="hljs-type">Bech32Address</span>(scriptPubKey, <span class="hljs-type">TestNet3</span>)
|
||||
}
|
||||
<span class="hljs-comment">// firstAccountAddress: Bech32Address = Bech32Address(tb1qryac80j6n3alq4ueflldn6fhc5603s57g6ww2m)</span>
|
||||
<span class="hljs-comment">// firstAccountAddress: Bech32Address = Bech32Address(tb1qnzwrxyja36jxygrvnz8duern6dgym7qjkgazsr)</span>
|
||||
|
||||
<span class="hljs-comment">// tada! We just generated an address you can send money to,</span>
|
||||
<span class="hljs-comment">// without having access to the private key!</span>
|
||||
firstAccountAddress.value
|
||||
<span class="hljs-comment">// res2: String = tb1qryac80j6n3alq4ueflldn6fhc5603s57g6ww2m</span>
|
||||
<span class="hljs-comment">// res2: String = tb1qnzwrxyja36jxygrvnz8duern6dgym7qjkgazsr</span>
|
||||
|
||||
<span class="hljs-comment">// you can now continue deriving addresses from the same public</span>
|
||||
<span class="hljs-comment">// key, by imitating what we did above. To get the next</span>
|
||||
|
|
|
@ -174,7 +174,7 @@ signedTx.outputs.length
|
|||
|
||||
<span class="hljs-comment">//remember, you can call .hex on any bitcoin-s data structure to get the hex representation!</span>
|
||||
signedTx.hex
|
||||
<span class="hljs-comment">// res2: String = "0200000001e2e8c36781a92da4482c727bbd107e9a56d315ac398a2e264c25a56a6d70bd50000000006b483045022100c400748c74a3ebbcfc8169bc26d17dae3aca9fef741ca44c2792c14179823b40022011fb71e0996e1dc64599ec1e08c658308bcffc00eb8381e7a644d5ed6fbe42ec01210240e4716500437a2e22ab563373dbd406e7cb20155a6965465e7b35551475930e000000000288130000000000001976a91422fc35a1b4e3768917d8fcf6c5b576d6be9b521988aca6120000000000001976a914d5fe164e4145150d76c2a1905ac5aea823f0b1d188ac00000000"</span>
|
||||
<span class="hljs-comment">// res2: String = "02000000015a04cdd59c6a111d5568db3c20b8416e6c0e1f5368a91a98361fdc2db776b018000000006b483045022100d71506e4c4f666265912c5b49e83385f1b8b7ca6da547746408d70ccf1b97ce602204674ba78d7059e6dc9416b2a0bd1f06b134bce80a87911e0c9e81c048225f078012102f56d09bbfc3044b284a1e5add3c59140d235fe422c2ba21971ea521a60b73931000000000288130000000000001976a91437d9e0cdcd331f20825349ce5c808407ec00766588aca6120000000000001976a9149f9d8a6b0a0dfe828c8f22aed129e7c62b64ee5b88ac00000000"</span>
|
||||
</code></pre>
|
||||
</span></div></article></div><div class="docs-prevnext"><a class="docs-prev button" href="/docs/next/core/hd-keys"><span class="arrow-prev">← </span><span>HD key generation</span></a><a class="docs-next button" href="/docs/next/rpc/rpc-clients-intro"><span>Introduction</span><span class="arrow-next"> →</span></a></div></div></div><nav class="onPageNav"></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><a href="/" class="nav-home"><img src="/img/favicon.ico" alt="bitcoin-s" width="66" height="58"/></a><div><h5>Docs</h5><a href="/docs/en/getting-started">Getting Started</a><a href="/docs/en/core/core-intro">Guides</a><a href="/api/org/bitcoins">API Reference</a></div><div><h5>Community</h5><a href="/en/users.html">User Showcase</a><a href="https://join.slack.com/t/suredbits/shared_invite/enQtNDEyMjY3MTg1MTg3LTYyYjkwOGUzMDQ4NDAwZjE1M2I3MmQyNWNlZjNlYjg4OGRjYTRjNWUwNjRjNjg4Y2NjZjAxYjU1N2JjMTU1YWM" target="_blank" rel="noreferrer noopener">Slack</a><a href="https://gitter.im/bitcoin-s-core/">Gitter chat</a></div><div><h5>More</h5><a href="https://github.com/bitcoin-s/bitcoin-s">GitHub</a><a class="github-button" href="https://github.com/bitcoin-s/bitcoin-s" data-icon="octicon-star" data-count-href="/bitcoin-s/bitcoin-s-core/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star this project on GitHub">Star</a></div></section><section class="copyright">Copyright © 2019 Suredbits & the bitcoin-s developers</section></footer></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.js"></script><script>
|
||||
document.addEventListener('keyup', function(e) {
|
||||
|
|
|
@ -174,7 +174,7 @@ signedTx.outputs.length
|
|||
|
||||
<span class="hljs-comment">//remember, you can call .hex on any bitcoin-s data structure to get the hex representation!</span>
|
||||
signedTx.hex
|
||||
<span class="hljs-comment">// res2: String = "0200000001e2e8c36781a92da4482c727bbd107e9a56d315ac398a2e264c25a56a6d70bd50000000006b483045022100c400748c74a3ebbcfc8169bc26d17dae3aca9fef741ca44c2792c14179823b40022011fb71e0996e1dc64599ec1e08c658308bcffc00eb8381e7a644d5ed6fbe42ec01210240e4716500437a2e22ab563373dbd406e7cb20155a6965465e7b35551475930e000000000288130000000000001976a91422fc35a1b4e3768917d8fcf6c5b576d6be9b521988aca6120000000000001976a914d5fe164e4145150d76c2a1905ac5aea823f0b1d188ac00000000"</span>
|
||||
<span class="hljs-comment">// res2: String = "02000000015a04cdd59c6a111d5568db3c20b8416e6c0e1f5368a91a98361fdc2db776b018000000006b483045022100d71506e4c4f666265912c5b49e83385f1b8b7ca6da547746408d70ccf1b97ce602204674ba78d7059e6dc9416b2a0bd1f06b134bce80a87911e0c9e81c048225f078012102f56d09bbfc3044b284a1e5add3c59140d235fe422c2ba21971ea521a60b73931000000000288130000000000001976a91437d9e0cdcd331f20825349ce5c808407ec00766588aca6120000000000001976a9149f9d8a6b0a0dfe828c8f22aed129e7c62b64ee5b88ac00000000"</span>
|
||||
</code></pre>
|
||||
</span></div></article></div><div class="docs-prevnext"><a class="docs-prev button" href="/docs/next/core/hd-keys"><span class="arrow-prev">← </span><span>HD key generation</span></a><a class="docs-next button" href="/docs/next/rpc/rpc-clients-intro"><span>Introduction</span><span class="arrow-next"> →</span></a></div></div></div><nav class="onPageNav"></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><a href="/" class="nav-home"><img src="/img/favicon.ico" alt="bitcoin-s" width="66" height="58"/></a><div><h5>Docs</h5><a href="/docs/en/getting-started">Getting Started</a><a href="/docs/en/core/core-intro">Guides</a><a href="/api/org/bitcoins">API Reference</a></div><div><h5>Community</h5><a href="/en/users.html">User Showcase</a><a href="https://join.slack.com/t/suredbits/shared_invite/enQtNDEyMjY3MTg1MTg3LTYyYjkwOGUzMDQ4NDAwZjE1M2I3MmQyNWNlZjNlYjg4OGRjYTRjNWUwNjRjNjg4Y2NjZjAxYjU1N2JjMTU1YWM" target="_blank" rel="noreferrer noopener">Slack</a><a href="https://gitter.im/bitcoin-s-core/">Gitter chat</a></div><div><h5>More</h5><a href="https://github.com/bitcoin-s/bitcoin-s">GitHub</a><a class="github-button" href="https://github.com/bitcoin-s/bitcoin-s" data-icon="octicon-star" data-count-href="/bitcoin-s/bitcoin-s-core/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star this project on GitHub">Star</a></div></section><section class="copyright">Copyright © 2019 Suredbits & the bitcoin-s developers</section></footer></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.js"></script><script>
|
||||
document.addEventListener('keyup', function(e) {
|
||||
|
|
|
@ -89,7 +89,7 @@ libraryDependencies += <span class="hljs-string">"org.bitcoin-s"</span> %% <span
|
|||
<h3><a class="anchor" aria-hidden="true" id="nightly-builds"></a><a href="#nightly-builds" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Nightly builds</h3>
|
||||
<p>You can also run on the bleeding edge of Bitcoin-S, by
|
||||
adding a snapshot build to your <code>build.sbt</code>. The most
|
||||
recent snapshot published is <code>158-10d5352e-SNAPSHOT</code>.</p>
|
||||
recent snapshot published is <code>155-b5aed58e-SNAPSHOT</code>.</p>
|
||||
<p>To fetch snapshots, you will need to add the correct
|
||||
resolver in your <code>build.sbt</code>:</p>
|
||||
<pre><code class="hljs css language-sbt">resolvers += Resolver.sonatypeRepo(<span class="hljs-string">"snapshots"</span>)
|
||||
|
|
|
@ -89,7 +89,7 @@ libraryDependencies += <span class="hljs-string">"org.bitcoin-s"</span> %% <span
|
|||
<h3><a class="anchor" aria-hidden="true" id="nightly-builds"></a><a href="#nightly-builds" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Nightly builds</h3>
|
||||
<p>You can also run on the bleeding edge of Bitcoin-S, by
|
||||
adding a snapshot build to your <code>build.sbt</code>. The most
|
||||
recent snapshot published is <code>158-10d5352e-SNAPSHOT</code>.</p>
|
||||
recent snapshot published is <code>155-b5aed58e-SNAPSHOT</code>.</p>
|
||||
<p>To fetch snapshots, you will need to add the correct
|
||||
resolver in your <code>build.sbt</code>:</p>
|
||||
<pre><code class="hljs css language-sbt">resolvers += Resolver.sonatypeRepo(<span class="hljs-string">"snapshots"</span>)
|
||||
|
|
Loading…
Add table
Reference in a new issue