From 4a308cb87ea5c2ad32c1bbfbf4bd70fa2a9ad401 Mon Sep 17 00:00:00 2001
From: Daira Hopwood
Date: Wed, 12 Oct 2022 15:00:15 +0100
Subject: [PATCH] ZIP 317: fill in values for
`p2pkh_standard_{input,output}_size`.
Signed-off-by: Daira Hopwood
---
zip-0317.html | 33 +++++++++++++++++++++++++++++++--
zip-0317.rst | 33 +++++++++++++++++++++++++++++++--
2 files changed, 62 insertions(+), 4 deletions(-)
diff --git a/zip-0317.html b/zip-0317.html
index 77dcb958..682db127 100644
--- a/zip-0317.html
+++ b/zip-0317.html
@@ -165,10 +165,10 @@ Pull-Request: <https://githu
\(grace\_actions = 2\)
;
- \(p2pkh\_standard\_input\_size = TODO\)
+ \(p2pkh\_standard\_input\_size = 150\)
bytes;
- \(p2pkh\_standard\_output\_size = TODO\)
+ \(p2pkh\_standard\_output\_size = 34\)
bytes.
It is not a consensus requirement that fees follow this formula; however, wallets SHOULD create transactions that pay this fee, in order to reduce information leakage, unless overridden by the user.
@@ -210,6 +210,35 @@ Pull-Request: <https://githu
\(grace\_actions = min\_actions = 2\)
. This also ensures that a denial-of-service adversary does not gain a significant per-logical-action cost advantage by using transactions with a smaller or larger number of logical actions.
+ Transparent Contribution
+ The specified formula calculates the contribution of transparent inputs and outputs based on their total size relative to a typical input or output. Another considered approach was to calculate this contribution simply as
+ \(\mathsf{max}(transparent\_inputs, transparent\_outputs)\)
+ . However, this would allow a denial-of-service adversary to create transactions with transparent components containing arbitrarily large scripts.
+ The chosen values for
+ \(p2pkh\_standard\_input\_size\)
+ and
+ \(p2pkh\_standard\_output\_size\)
+ are based on the maximum encoded length for simple P2PKH inputs and outputs, as follows:
+
+ -
+ \(p2pkh\_standard\_input\_size\)
+
+ - outpoint: 36 bytes
+ - stack script: 72 bytes
+ - redeem script: 34 bytes
+ - sequence: 4 bytes
+
+
+ -
+ \(p2pkh\_standard\_output\_size\)
+
+ - value: 8 bytes
+ - script: 26 bytes
+
+
+
+ Simple P2SH inputs and outputs are not typically larger than this.
+
Marginal Fee
This returns the conventional fee for a minimal transaction (as described above) to the original conventional fee of 10000 zatoshis specified in , and imposes a non-trivial cost for potential denial-of-service attacks.
diff --git a/zip-0317.rst b/zip-0317.rst
index 98597961..dcf06087 100644
--- a/zip-0317.rst
+++ b/zip-0317.rst
@@ -132,8 +132,8 @@ The parameters are set to the following values:
* :math:`marginal\_fee = 5000`;
* :math:`grace\_actions = 2`;
-* :math:`p2pkh\_standard\_input\_size = TODO` bytes;
-* :math:`p2pkh\_standard\_output\_size = TODO` bytes.
+* :math:`p2pkh\_standard\_input\_size = 150` bytes;
+* :math:`p2pkh\_standard\_output\_size = 34` bytes.
It is not a consensus requirement that fees follow this formula; however,
wallets SHOULD create transactions that pay this fee, in order to reduce
@@ -198,6 +198,35 @@ ensures that a denial-of-service adversary does not gain a
significant per-logical-action cost advantage by using transactions
with a smaller or larger number of logical actions.
+Transparent Contribution
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+The specified formula calculates the contribution of transparent inputs
+and outputs based on their total size relative to a typical input or
+output. Another considered approach was to calculate this contribution
+simply as :math:`\mathsf{max}(transparent\_inputs, transparent\_outputs)`.
+However, this would allow a denial-of-service adversary to create
+transactions with transparent components containing arbitrarily large
+scripts.
+
+The chosen values for :math:`p2pkh\_standard\_input\_size` and
+:math:`p2pkh\_standard\_output\_size` are based on the maximum encoded
+length for simple P2PKH inputs and outputs, as follows:
+
+* :math:`p2pkh\_standard\_input\_size`
+
+ * outpoint: 36 bytes
+ * stack script: 72 bytes
+ * redeem script: 34 bytes
+ * sequence: 4 bytes
+
+* :math:`p2pkh\_standard\_output\_size`
+
+ * value: 8 bytes
+ * script: 26 bytes
+
+Simple P2SH inputs and outputs are not typically larger than this.
+
Marginal Fee
~~~~~~~~~~~~