Skip to content

Commit

Permalink
deploy: 536871e
Browse files Browse the repository at this point in the history
  • Loading branch information
tcharding committed May 1, 2024
1 parent 8cb1d6e commit 9900fd8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
20 changes: 10 additions & 10 deletions book/print.html
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ <h2 id="license"><a class="header" href="#license">License</a></h2>
(out_point, utxo)
}</code></pre>
<p><code>dummy_unspent_transaction_output</code> generates a dummy unspent transaction output (UTXO).
This is a SegWit V0 P2WPKH (<code>ScriptBuf::new_v0_p2wpkh</code>) UTXO with a dummy invalid transaction ID (<code>txid: Txid::all_zeros()</code>),
This is a SegWit V0 P2WPKH (<code>ScriptBuf::new_p2wpkh</code>) UTXO with a dummy invalid transaction ID (<code>txid: Txid::all_zeros()</code>),
and a value of the <code>const DUMMY_UTXO_AMOUNT</code> that we defined earlier.
We are using the <a href="https://docs.rs/bitcoin/0.31.1/bitcoin/blockdata/transaction/struct.OutPoint.html"><code>OutPoint</code></a> struct to represent the transaction output.
Finally, we return the tuple <code>(out_point, utxo)</code>.</p>
Expand Down Expand Up @@ -400,10 +400,10 @@ <h2 id="license"><a class="header" href="#license">License</a></h2>

// Sign the sighash using the secp256k1 library (exported by rust-bitcoin).
let msg = Message::from(sighash);
let sig = secp.sign_ecdsa(&amp;msg, &amp;sk);
let signature = secp.sign_ecdsa(&amp;msg, &amp;sk);

// Update the witness stack.
let signature = bitcoin::ecdsa::Signature { sig, hash_ty: EcdsaSighashType::All };
let signature = bitcoin::ecdsa::Signature { signature, sighash_type };
let pk = sk.public_key(&amp;secp);
*sighasher.witness_mut(input_index).unwrap() = Witness::p2wpkh(&amp;signature, &amp;pk);

Expand Down Expand Up @@ -449,7 +449,7 @@ <h2 id="license"><a class="header" href="#license">License</a></h2>
</ul>
<p>In <code>let change = TxOut {...}</code> we are instantiating the change output.
It is very similar to the <code>spend</code> output, but we are now using the <code>const CHANGE_AMOUNT</code> that we defined earlier<sup class="footnote-reference"><a href="#spend">5</a></sup>.
This is done by setting the <code>script_pubkey</code> field to <a href="https://docs.rs/bitcoin/0.31.1/bitcoin/blockdata/script/struct.ScriptBuf.html#method.new_v0_p2wpkh"><code>ScriptBuf::new_v0_p2wpkh(&amp;wpkh)</code></a>,
This is done by setting the <code>script_pubkey</code> field to <a href="https://docs.rs/bitcoin/0.31.1/bitcoin/blockdata/script/struct.ScriptBuf.html#method.new_p2wpkh"><code>ScriptBuf::new_p2wpkh(&amp;wpkh)</code></a>,
which generates P2WPKH-type of script pubkey.</p>
<p>In <code>let unsigned_tx = Transaction {...}</code> we are instantiating the transaction we want to sign and broadcast using the <a href="https://docs.rs/bitcoin/0.31.1/bitcoin/blockdata/transaction/struct.Transaction.html"><code>Transaction</code></a> struct.
We set the following fields:</p>
Expand Down Expand Up @@ -609,7 +609,7 @@ <h2 id="license"><a class="header" href="#license">License</a></h2>
secp: &amp;Secp256k1&lt;C&gt;,
internal_key: UntweakedPublicKey,
) -&gt; (OutPoint, TxOut) {
let script_pubkey = ScriptBuf::new_v1_p2tr(secp, internal_key, None);
let script_pubkey = ScriptBuf::new_p2tr(secp, internal_key, None);

let out_point = OutPoint {
txid: Txid::all_zeros(), // Obviously invalid.
Expand All @@ -621,7 +621,7 @@ <h2 id="license"><a class="header" href="#license">License</a></h2>
(out_point, utxo)
}</code></pre>
<p><code>dummy_unspent_transaction_output</code> generates a dummy unspent transaction output (UTXO).
This is a P2TR (<code>ScriptBuf::new_v1_p2tr</code>) UTXO.
This is a P2TR (<code>ScriptBuf::new_p2tr</code>) UTXO.
It takes the following arguments:</p>
<ul>
<li><code>secp</code> is a reference to a <a href="https://docs.rs/secp256k1/0.27.0/secp256k1/struct.Secp256k1.html"><code>Secp256k1</code></a> type.
Expand Down Expand Up @@ -674,7 +674,7 @@ <h2 id="license"><a class="header" href="#license">License</a></h2>
</span><span class="boring"> secp: &amp;Secp256k1&lt;C&gt;,
</span><span class="boring"> internal_key: UntweakedPublicKey,
</span><span class="boring">) -&gt; (OutPoint, TxOut) {
</span><span class="boring"> let script_pubkey = ScriptBuf::new_v1_p2tr(secp, internal_key, None);
</span><span class="boring"> let script_pubkey = ScriptBuf::new_p2tr(secp, internal_key, None);
</span><span class="boring">
</span><span class="boring"> let out_point = OutPoint {
</span><span class="boring"> txid: Txid::all_zeros(), // Obviously invalid.
Expand Down Expand Up @@ -740,10 +740,10 @@ <h2 id="license"><a class="header" href="#license">License</a></h2>
// Sign the sighash using the secp256k1 library (exported by rust-bitcoin).
let tweaked: TweakedKeypair = keypair.tap_tweak(&amp;secp, None);
let msg = Message::from_digest(sighash.to_byte_array());
let sig = secp.sign_schnorr(&amp;msg, &amp;tweaked.to_inner());
let signature = secp.sign_schnorr(&amp;msg, &amp;tweaked.to_inner());

// Update the witness stack.
let signature = bitcoin::taproot::Signature { sig, hash_ty: sighash_type };
let signature = bitcoin::taproot::Signature { signature, sighash_type };
sighasher.witness_mut(input_index).unwrap().push(&amp;signature.to_vec());

// Get the signed transaction.
Expand Down Expand Up @@ -785,7 +785,7 @@ <h2 id="license"><a class="header" href="#license">License</a></h2>
</ul>
<p>In <code>let change = TxOut {...}</code> we are instantiating the change output.
It is very similar to the <code>spend</code> output, but we are now using the <code>const CHANGE_AMOUNT</code> that we defined earlier<sup class="footnote-reference"><a href="#spend">5</a></sup>.
This is done by setting the <code>script_pubkey</code> field to <a href="https://docs.rs/bitcoin/0.31.1/bitcoin/blockdata/script/struct.ScriptBuf.html#method.new_v1_p2tr"><code>ScriptBuf::new_v1_p2tr(...)</code></a>,
This is done by setting the <code>script_pubkey</code> field to <a href="https://docs.rs/bitcoin/0.31.1/bitcoin/blockdata/script/struct.ScriptBuf.html#method.new_p2tr"><code>ScriptBuf::new_p2tr(...)</code></a>,
which generates P2TR-type of script pubkey.</p>
<p>In <code>let unsigned_tx = Transaction {...}</code> we are instantiating the transaction we want to sign and broadcast using the <a href="https://docs.rs/bitcoin/0.31.1/bitcoin/blockdata/transaction/struct.Transaction.html"><code>Transaction</code></a> struct.
We set the following fields:</p>
Expand Down
2 changes: 1 addition & 1 deletion book/searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion book/searchindex.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions book/tx_segwit-v0.html
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ <h1 id="constructing-and-signing-transactions---segwit-v0"><a class="header" hre
(out_point, utxo)
}</code></pre>
<p><code>dummy_unspent_transaction_output</code> generates a dummy unspent transaction output (UTXO).
This is a SegWit V0 P2WPKH (<code>ScriptBuf::new_v0_p2wpkh</code>) UTXO with a dummy invalid transaction ID (<code>txid: Txid::all_zeros()</code>),
This is a SegWit V0 P2WPKH (<code>ScriptBuf::new_p2wpkh</code>) UTXO with a dummy invalid transaction ID (<code>txid: Txid::all_zeros()</code>),
and a value of the <code>const DUMMY_UTXO_AMOUNT</code> that we defined earlier.
We are using the <a href="https://docs.rs/bitcoin/0.31.1/bitcoin/blockdata/transaction/struct.OutPoint.html"><code>OutPoint</code></a> struct to represent the transaction output.
Finally, we return the tuple <code>(out_point, utxo)</code>.</p>
Expand Down Expand Up @@ -357,10 +357,10 @@ <h1 id="constructing-and-signing-transactions---segwit-v0"><a class="header" hre

// Sign the sighash using the secp256k1 library (exported by rust-bitcoin).
let msg = Message::from(sighash);
let sig = secp.sign_ecdsa(&amp;msg, &amp;sk);
let signature = secp.sign_ecdsa(&amp;msg, &amp;sk);

// Update the witness stack.
let signature = bitcoin::ecdsa::Signature { sig, hash_ty: EcdsaSighashType::All };
let signature = bitcoin::ecdsa::Signature { signature, sighash_type };
let pk = sk.public_key(&amp;secp);
*sighasher.witness_mut(input_index).unwrap() = Witness::p2wpkh(&amp;signature, &amp;pk);

Expand Down Expand Up @@ -406,7 +406,7 @@ <h1 id="constructing-and-signing-transactions---segwit-v0"><a class="header" hre
</ul>
<p>In <code>let change = TxOut {...}</code> we are instantiating the change output.
It is very similar to the <code>spend</code> output, but we are now using the <code>const CHANGE_AMOUNT</code> that we defined earlier<sup class="footnote-reference"><a href="#spend">5</a></sup>.
This is done by setting the <code>script_pubkey</code> field to <a href="https://docs.rs/bitcoin/0.31.1/bitcoin/blockdata/script/struct.ScriptBuf.html#method.new_v0_p2wpkh"><code>ScriptBuf::new_v0_p2wpkh(&amp;wpkh)</code></a>,
This is done by setting the <code>script_pubkey</code> field to <a href="https://docs.rs/bitcoin/0.31.1/bitcoin/blockdata/script/struct.ScriptBuf.html#method.new_p2wpkh"><code>ScriptBuf::new_p2wpkh(&amp;wpkh)</code></a>,
which generates P2WPKH-type of script pubkey.</p>
<p>In <code>let unsigned_tx = Transaction {...}</code> we are instantiating the transaction we want to sign and broadcast using the <a href="https://docs.rs/bitcoin/0.31.1/bitcoin/blockdata/transaction/struct.Transaction.html"><code>Transaction</code></a> struct.
We set the following fields:</p>
Expand Down
12 changes: 6 additions & 6 deletions book/tx_taproot.html
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ <h1 id="constructing-and-signing-transactions---taproot"><a class="header" href=
secp: &amp;Secp256k1&lt;C&gt;,
internal_key: UntweakedPublicKey,
) -&gt; (OutPoint, TxOut) {
let script_pubkey = ScriptBuf::new_v1_p2tr(secp, internal_key, None);
let script_pubkey = ScriptBuf::new_p2tr(secp, internal_key, None);

let out_point = OutPoint {
txid: Txid::all_zeros(), // Obviously invalid.
Expand All @@ -262,7 +262,7 @@ <h1 id="constructing-and-signing-transactions---taproot"><a class="header" href=
(out_point, utxo)
}</code></pre>
<p><code>dummy_unspent_transaction_output</code> generates a dummy unspent transaction output (UTXO).
This is a P2TR (<code>ScriptBuf::new_v1_p2tr</code>) UTXO.
This is a P2TR (<code>ScriptBuf::new_p2tr</code>) UTXO.
It takes the following arguments:</p>
<ul>
<li><code>secp</code> is a reference to a <a href="https://docs.rs/secp256k1/0.27.0/secp256k1/struct.Secp256k1.html"><code>Secp256k1</code></a> type.
Expand Down Expand Up @@ -315,7 +315,7 @@ <h1 id="constructing-and-signing-transactions---taproot"><a class="header" href=
</span><span class="boring"> secp: &amp;Secp256k1&lt;C&gt;,
</span><span class="boring"> internal_key: UntweakedPublicKey,
</span><span class="boring">) -&gt; (OutPoint, TxOut) {
</span><span class="boring"> let script_pubkey = ScriptBuf::new_v1_p2tr(secp, internal_key, None);
</span><span class="boring"> let script_pubkey = ScriptBuf::new_p2tr(secp, internal_key, None);
</span><span class="boring">
</span><span class="boring"> let out_point = OutPoint {
</span><span class="boring"> txid: Txid::all_zeros(), // Obviously invalid.
Expand Down Expand Up @@ -381,10 +381,10 @@ <h1 id="constructing-and-signing-transactions---taproot"><a class="header" href=
// Sign the sighash using the secp256k1 library (exported by rust-bitcoin).
let tweaked: TweakedKeypair = keypair.tap_tweak(&amp;secp, None);
let msg = Message::from_digest(sighash.to_byte_array());
let sig = secp.sign_schnorr(&amp;msg, &amp;tweaked.to_inner());
let signature = secp.sign_schnorr(&amp;msg, &amp;tweaked.to_inner());

// Update the witness stack.
let signature = bitcoin::taproot::Signature { sig, hash_ty: sighash_type };
let signature = bitcoin::taproot::Signature { signature, sighash_type };
sighasher.witness_mut(input_index).unwrap().push(&amp;signature.to_vec());

// Get the signed transaction.
Expand Down Expand Up @@ -426,7 +426,7 @@ <h1 id="constructing-and-signing-transactions---taproot"><a class="header" href=
</ul>
<p>In <code>let change = TxOut {...}</code> we are instantiating the change output.
It is very similar to the <code>spend</code> output, but we are now using the <code>const CHANGE_AMOUNT</code> that we defined earlier<sup class="footnote-reference"><a href="#spend">5</a></sup>.
This is done by setting the <code>script_pubkey</code> field to <a href="https://docs.rs/bitcoin/0.31.1/bitcoin/blockdata/script/struct.ScriptBuf.html#method.new_v1_p2tr"><code>ScriptBuf::new_v1_p2tr(...)</code></a>,
This is done by setting the <code>script_pubkey</code> field to <a href="https://docs.rs/bitcoin/0.31.1/bitcoin/blockdata/script/struct.ScriptBuf.html#method.new_p2tr"><code>ScriptBuf::new_p2tr(...)</code></a>,
which generates P2TR-type of script pubkey.</p>
<p>In <code>let unsigned_tx = Transaction {...}</code> we are instantiating the transaction we want to sign and broadcast using the <a href="https://docs.rs/bitcoin/0.31.1/bitcoin/blockdata/transaction/struct.Transaction.html"><code>Transaction</code></a> struct.
We set the following fields:</p>
Expand Down

0 comments on commit 9900fd8

Please sign in to comment.