mirror of https://github.com/zcash/zips.git
ZIP 320: The `code-block` rst directive is not supported by rst2html
This commit is contained in:
parent
342cd187cc
commit
d33a793a93
|
@ -73,9 +73,10 @@ Pull-Request: <<a href="https://github.com/zcash/zips/pull/760">https://githu
|
||||||
<p>Wallets and other Senders sending to a TEX address MUST ensure that only transparent UTXOs are spent in the creation of a transaction.</p>
|
<p>Wallets and other Senders sending to a TEX address MUST ensure that only transparent UTXOs are spent in the creation of a transaction.</p>
|
||||||
</section>
|
</section>
|
||||||
<section id="reference-implementation-alternative-1"><h3><span class="section-heading">Reference Implementation (Alternative 1)</span><span class="section-anchor"> <a rel="bookmark" href="#reference-implementation-alternative-1"><img width="24" height="24" class="section-anchor" src="assets/images/section-anchor.png" alt=""></a></span></h3>
|
<section id="reference-implementation-alternative-1"><h3><span class="section-heading">Reference Implementation (Alternative 1)</span><span class="section-anchor"> <a rel="bookmark" href="#reference-implementation-alternative-1"><img width="24" height="24" class="section-anchor" src="assets/images/section-anchor.png" alt=""></a></span></h3>
|
||||||
<!-- code-block: javascript
|
<p>Javascript:</p>
|
||||||
import bs58check from 'bs58check'
|
<pre>import bs58check from 'bs58check'
|
||||||
import {bech32m} from 'bech32'
|
import {bech32m} from 'bech32'
|
||||||
|
|
||||||
// From t1 to tex
|
// From t1 to tex
|
||||||
var b58decoded = bs58check.decode('t1VmmGiyjVNeCjxDZzg7vZmd99WyzVby9yC')
|
var b58decoded = bs58check.decode('t1VmmGiyjVNeCjxDZzg7vZmd99WyzVby9yC')
|
||||||
console.assert(b58decoded.length == 22, 'Invalid length');
|
console.assert(b58decoded.length == 22, 'Invalid length');
|
||||||
|
@ -83,13 +84,14 @@ console.assert(b58decoded[0] == 0x1C && b58decoded[1] == 0xB8, 'Invalid
|
||||||
var pkh = b58decoded.slice(2)
|
var pkh = b58decoded.slice(2)
|
||||||
var tex = bech32m.encode('tex', bech32m.toWords(pkh))
|
var tex = bech32m.encode('tex', bech32m.toWords(pkh))
|
||||||
console.log(tex)
|
console.log(tex)
|
||||||
|
|
||||||
// From tex to t1
|
// From tex to t1
|
||||||
var bech32decoded = bech32m.decode('tex1s2rt77ggv6q989lr49rkgzmh5slsksa9khdgte')
|
var bech32decoded = bech32m.decode('tex1s2rt77ggv6q989lr49rkgzmh5slsksa9khdgte')
|
||||||
console.assert(bech32decoded.prefix == 'tex', 'Invalid address prefix')
|
console.assert(bech32decoded.prefix == 'tex', 'Invalid address prefix')
|
||||||
var pkh2 = Uint8Array.from(bech32m.fromWords(bech32decoded.words))
|
var pkh2 = Uint8Array.from(bech32m.fromWords(bech32decoded.words))
|
||||||
console.assert(pkh2.length == 20, 'Invalid length');
|
console.assert(pkh2.length == 20, 'Invalid length');
|
||||||
var t1 = bs58check.encode(Buffer.concat([Uint8Array.from([0x1C, 0xB8]), pkh2]))
|
var t1 = bs58check.encode(Buffer.concat([Uint8Array.from([0x1C, 0xB8]), pkh2]))
|
||||||
console.log(t1) -->
|
console.log(t1)</pre>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
<section id="alternative-2"><h2><span class="section-heading">Alternative 2</span><span class="section-anchor"> <a rel="bookmark" href="#alternative-2"><img width="24" height="24" class="section-anchor" src="assets/images/section-anchor.png" alt=""></a></span></h2>
|
<section id="alternative-2"><h2><span class="section-heading">Alternative 2</span><span class="section-anchor"> <a rel="bookmark" href="#alternative-2"><img width="24" height="24" class="section-anchor" src="assets/images/section-anchor.png" alt=""></a></span></h2>
|
||||||
|
@ -134,28 +136,30 @@ A Unified Viewing Key MUST contain at least one shielded Item (Typecodes
|
||||||
<p>Wallets and other Senders sending to a Traceable Unified Address MUST ensure that only transparent UTXOs are spent in the creation of a transaction.</p>
|
<p>Wallets and other Senders sending to a Traceable Unified Address MUST ensure that only transparent UTXOs are spent in the creation of a transaction.</p>
|
||||||
</section>
|
</section>
|
||||||
<section id="reference-implementation-alternative-2"><h3><span class="section-heading">Reference Implementation (Alternative 2)</span><span class="section-anchor"> <a rel="bookmark" href="#reference-implementation-alternative-2"><img width="24" height="24" class="section-anchor" src="assets/images/section-anchor.png" alt=""></a></span></h3>
|
<section id="reference-implementation-alternative-2"><h3><span class="section-heading">Reference Implementation (Alternative 2)</span><span class="section-anchor"> <a rel="bookmark" href="#reference-implementation-alternative-2"><img width="24" height="24" class="section-anchor" src="assets/images/section-anchor.png" alt=""></a></span></h3>
|
||||||
<p>Javascript library <cite>zcash_address_wasm</cite> <a id="footnote-reference-17" class="footnote_reference" href="#zcash-address-wasm">13</a>:</p>
|
<p>Javascript using <cite>zcash_address_wasm</cite> <a id="footnote-reference-17" class="footnote_reference" href="#zcash-address-wasm">13</a>:</p>
|
||||||
<!-- code-block: javascript
|
<pre>import init, { to_traceable_address } from 'zcash_address_wasm';
|
||||||
import init, { to_traceable_address } from 'zcash_address_wasm;;
|
init().then(() => {
|
||||||
init().then(() => {
|
|
||||||
var t_address = "t1VmmGiyjVNeCjxDZzg7vZmd99WyzVby9yC";
|
var t_address = "t1VmmGiyjVNeCjxDZzg7vZmd99WyzVby9yC";
|
||||||
|
|
||||||
// Create a deposit address that is valid for 30 days
|
// Create a deposit address that is valid for 30 days
|
||||||
var expiry_time = new Date();
|
var expiry_time = new Date();
|
||||||
expiry_time.setDate(expiry_time.getDate() + 30);
|
expiry_time.setDate(expiry_time.getDate() + 30);
|
||||||
var expiry_unix_seconds = BigInt(Math.floor(expiry_time.getTime() / 1000));
|
var expiry_unix_seconds = BigInt(Math.floor(expiry_time.getTime() / 1000));
|
||||||
|
|
||||||
var traceable_address = to_traceable_address(t_address, expiry_unix_seconds);
|
var traceable_address = to_traceable_address(t_address, expiry_unix_seconds);
|
||||||
console.log(traceable_address);
|
console.log(traceable_address);
|
||||||
}); -->
|
});</pre>
|
||||||
<p>Rust:</p>
|
<p>Rust:</p>
|
||||||
<!-- code-block: rust
|
<pre>use zcash_address::{
|
||||||
use zcash_address::{
|
|
||||||
unified::{self, Encoding},
|
unified::{self, Encoding},
|
||||||
Network, ToAddress, TryFromAddress, ZcashAddress,
|
Network, ToAddress, TryFromAddress, ZcashAddress,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TraceableReceiver {
|
struct TraceableReceiver {
|
||||||
net: Network,
|
net: Network,
|
||||||
data: [u8; 20],
|
data: [u8; 20],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TraceableReceiver {
|
impl TraceableReceiver {
|
||||||
fn to_address(&self, expiry_time: u64) -> ZcashAddress {
|
fn to_address(&self, expiry_time: u64) -> ZcashAddress {
|
||||||
let traceable_addr = unified::Address::try_from_items(vec![
|
let traceable_addr = unified::Address::try_from_items(vec![
|
||||||
|
@ -169,18 +173,21 @@ impl TraceableReceiver {
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
.expect("We know that this produces a valid address.");
|
.expect("We know that this produces a valid address.");
|
||||||
|
|
||||||
ZcashAddress::from_unified(self.net, traceable_addr)
|
ZcashAddress::from_unified(self.net, traceable_addr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFromAddress for TraceableReceiver {
|
impl TryFromAddress for TraceableReceiver {
|
||||||
type Error = unified::ParseError;
|
type Error = unified::ParseError;
|
||||||
|
|
||||||
fn try_from_transparent_p2pkh(
|
fn try_from_transparent_p2pkh(
|
||||||
net: Network,
|
net: Network,
|
||||||
data: [u8; 20],
|
data: [u8; 20],
|
||||||
) -> Result<Self, zcash_address::ConversionError<Self::Error>> {
|
) -> Result<Self, zcash_address::ConversionError<Self::Error>> {
|
||||||
Ok(TraceableReceiver { net, data })
|
Ok(TraceableReceiver { net, data })
|
||||||
}
|
}
|
||||||
} -->
|
}</pre>
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
<section id="analysis-of-alternative-1"><h2><span class="section-heading">Analysis of Alternative 1</span><span class="section-anchor"> <a rel="bookmark" href="#analysis-of-alternative-1"><img width="24" height="24" class="section-anchor" src="assets/images/section-anchor.png" alt=""></a></span></h2>
|
<section id="analysis-of-alternative-1"><h2><span class="section-heading">Analysis of Alternative 1</span><span class="section-anchor"> <a rel="bookmark" href="#analysis-of-alternative-1"><img width="24" height="24" class="section-anchor" src="assets/images/section-anchor.png" alt=""></a></span></h2>
|
||||||
|
|
10
zip-0320.rst
10
zip-0320.rst
|
@ -130,7 +130,7 @@ transparent UTXOs are spent in the creation of a transaction.
|
||||||
Reference Implementation (Alternative 1)
|
Reference Implementation (Alternative 1)
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
.. code-block: javascript
|
Javascript::
|
||||||
|
|
||||||
import bs58check from 'bs58check'
|
import bs58check from 'bs58check'
|
||||||
import {bech32m} from 'bech32'
|
import {bech32m} from 'bech32'
|
||||||
|
@ -234,10 +234,9 @@ that only transparent UTXOs are spent in the creation of a transaction.
|
||||||
Reference Implementation (Alternative 2)
|
Reference Implementation (Alternative 2)
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
Javascript library `zcash_address_wasm` [#zcash_address_wasm]_:
|
Javascript using `zcash_address_wasm` [#zcash_address_wasm]_::
|
||||||
|
|
||||||
.. code-block: javascript
|
import init, { to_traceable_address } from 'zcash_address_wasm';
|
||||||
import init, { to_traceable_address } from 'zcash_address_wasm;;
|
|
||||||
init().then(() => {
|
init().then(() => {
|
||||||
var t_address = "t1VmmGiyjVNeCjxDZzg7vZmd99WyzVby9yC";
|
var t_address = "t1VmmGiyjVNeCjxDZzg7vZmd99WyzVby9yC";
|
||||||
|
|
||||||
|
@ -250,9 +249,8 @@ Javascript library `zcash_address_wasm` [#zcash_address_wasm]_:
|
||||||
console.log(traceable_address);
|
console.log(traceable_address);
|
||||||
});
|
});
|
||||||
|
|
||||||
Rust:
|
Rust::
|
||||||
|
|
||||||
.. code-block: rust
|
|
||||||
use zcash_address::{
|
use zcash_address::{
|
||||||
unified::{self, Encoding},
|
unified::{self, Encoding},
|
||||||
Network, ToAddress, TryFromAddress, ZcashAddress,
|
Network, ToAddress, TryFromAddress, ZcashAddress,
|
||||||
|
|
Loading…
Reference in New Issue