1
0
mirror of https://github.com/bitcoin/bips.git synced 2026-03-09 15:53:54 +00:00

BIP-352: test vectors: allow specifying repeated recipients for sending

Introduce an optional "count" field for recipient objects.
Also update the documentation of the fields.
This commit is contained in:
Sebastian Falbesoner
2026-02-26 20:14:59 +01:00
parent f665c2c142
commit 3aa17caaa3
2 changed files with 14 additions and 2 deletions

View File

@@ -393,7 +393,15 @@ A [[bip-0352/send_and_receive_test_vectors.json|collection of test vectors in JS
{
"given": {
"vin": [<array of vin objects with an added field for the private key. These objects are structured to match the `vin` output field from `getrawtransaction verbosity=2`>],
"recipients": [<array of strings, where each string is a bech32m encoding representing a silent payment address>]
"recipients": [<array of recipient objects, consisting of the address and its contained scan/spend public keys each>
{
"address": <bech32m encoding representing a silent payment address>,
"scan_pub_key": <hex encoded scan public key>,
"spend_pub_key": <hex encoded spend public key>,
"count": <optional integer for specifying the same recipient repeatedly (1 by default)>
},
...
]
},
"expected": {
"outputs": [<array of strings, where each string is a hex encoding of 32-byte X-only public key; contains all possible output sets, test must match a subset of size `n_outputs`>],

View File

@@ -268,7 +268,11 @@ if __name__ == "__main__":
sending_outputs = []
if (len(input_pub_keys) > 0):
outpoints = [vin.outpoint for vin in vins]
sending_outputs = create_outputs(input_priv_keys, outpoints, given["recipients"], expected=expected, hrp="sp")
recipients = [] # expand given recipient entries to full list
for recipient_entry in given["recipients"]:
count = recipient_entry.get("count", 1)
recipients.extend([recipient_entry] * count)
sending_outputs = create_outputs(input_priv_keys, outpoints, recipients, expected=expected, hrp="sp")
# Note: order doesn't matter for creating/finding the outputs. However, different orderings of the recipient addresses
# will produce different generated outputs if sending to multiple silent payment addresses belonging to the