Skip to content

Commit

Permalink
psbt: re-number value_commitment in output to match new spec
Browse files Browse the repository at this point in the history
  • Loading branch information
jgriffiths committed Aug 20, 2020
1 parent 4b03077 commit c4de62c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions include/wally_psbt.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,22 @@ struct wally_psbt_output {
struct wally_map keypaths;
struct wally_map unknowns;
#ifdef BUILD_ELEMENTS
unsigned char *blinding_pub_key;
size_t blinding_pub_key_len;
unsigned char *value_commitment;
size_t value_commitment_len;
unsigned char *vbf;
size_t vbf_len;
unsigned char *value_commitment;
size_t value_commitment_len;
unsigned char *asset;
size_t asset_len;
unsigned char *asset_commitment;
size_t asset_commitment_len;
unsigned char *ecdh_pub_key;
size_t ecdh_pub_key_len;
unsigned char *rangeproof;
size_t rangeproof_len;
unsigned char *surjectionproof;
size_t surjectionproof_len;
unsigned char *blinding_pub_key;
size_t blinding_pub_key_len;
unsigned char *ecdh_pub_key;
size_t ecdh_pub_key_len;
#endif /* BUILD_ELEMENTS */
};

Expand Down
12 changes: 6 additions & 6 deletions src/psbt.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ static const input_bytes_setter_fn PSET_INPUT_SETTERS[PSET_IN_PEGIN_CLAIM_SCRIPT
wally_psbt_input_set_pegin_claim_script /* PSET_IN_PEGIN_CLAIM_SCRIPT */
};

#define PSET_OUT_VALUE_COMMITMENT 0x00
#define PSET_OUT_VALUE_BLINDER 0x01
#define PSET_OUT_VALUE_BLINDER 0x00
#define PSET_OUT_VALUE_COMMITMENT 0x01
#define PSET_OUT_ASSET 0x02
#define PSET_OUT_ASSET_COMMITMENT 0x03
#define PSET_OUT_RANGE_PROOF 0x04
Expand All @@ -101,8 +101,8 @@ static const input_bytes_setter_fn PSET_INPUT_SETTERS[PSET_IN_PEGIN_CLAIM_SCRIPT
#define PSET_OUT_ECDH_PUB_KEY 0x07

static const output_bytes_setter_fn PSET_OUTPUT_SETTERS[PSET_OUT_ECDH_PUB_KEY + 1] = {
wally_psbt_output_set_value_commitment, /* PSET_OUT_VALUE_COMMITMENT */
wally_psbt_output_set_vbf, /* PSET_OUT_VALUE_BLINDER */
wally_psbt_output_set_value_commitment, /* PSET_OUT_VALUE_COMMITMENT */
wally_psbt_output_set_asset, /* PSET_OUT_ASSET */
wally_psbt_output_set_asset_commitment, /* PSET_OUT_ASSET_COMMITMENT */
wally_psbt_output_set_rangeproof, /* PSET_OUT_RANGE_PROOF */
Expand Down Expand Up @@ -1344,8 +1344,8 @@ static int pull_psbt_output(const unsigned char **cursor, size_t *max,

field_type = pull_varint(&key, &key_len);
switch (field_type) {
case PSET_OUT_VALUE_COMMITMENT:
case PSET_OUT_VALUE_BLINDER:
case PSET_OUT_VALUE_COMMITMENT:
case PSET_OUT_ASSET:
case PSET_OUT_ASSET_COMMITMENT:
case PSET_OUT_RANGE_PROOF:
Expand Down Expand Up @@ -1787,10 +1787,10 @@ static int push_psbt_output(unsigned char **cursor, size_t *max,
push_typed_map(cursor, max, PSBT_OUT_BIP32_DERIVATION, &output->keypaths);

#ifdef BUILD_ELEMENTS
push_elements_varbuff(cursor, max, PSET_OUT_VALUE_COMMITMENT,
output->value_commitment, output->value_commitment_len);
push_elements_varbuff(cursor, max, PSET_OUT_VALUE_BLINDER,
output->vbf, output->vbf_len);
push_elements_varbuff(cursor, max, PSET_OUT_VALUE_COMMITMENT,
output->value_commitment, output->value_commitment_len);
push_elements_varbuff(cursor, max, PSET_OUT_ASSET,
output->asset, output->asset_len);
push_elements_varbuff(cursor, max, PSET_OUT_ASSET_COMMITMENT,
Expand Down
14 changes: 7 additions & 7 deletions src/test/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,22 +166,22 @@ class wally_psbt_output(Structure):
('witness_script_len', c_ulong),
('keypaths', wally_map),
('unknowns', wally_map),
('blinding_pub_key', c_void_p),
('blinding_pub_key_len', c_ulong),
('value_commitment', c_void_p),
('value_commitment_len', c_ulong),
('vbf', c_void_p),
('vbf_len', c_ulong),
('value_commitment', c_void_p),
('value_commitment_len', c_ulong),
('asset', c_void_p),
('asset_len', c_ulong),
('asset_commitment', c_void_p),
('asset_commitment_len', c_ulong),
('ecdh_pub_key', c_void_p),
('ecdh_pub_key_len', c_ulong),
('rangeproof', c_void_p),
('rangeproof_len', c_ulong),
('surjectionproof', c_void_p),
('surjectionproof_len', c_ulong)]
('surjectionproof_len', c_ulong),
('blinding_pub_key', c_void_p),
('blinding_pub_key_len', c_ulong),
('ecdh_pub_key', c_void_p),
('ecdh_pub_key_len', c_ulong)]

class wally_psbt(Structure):
_fields_ = [('magic', c_ubyte * 5),
Expand Down

0 comments on commit c4de62c

Please sign in to comment.