Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fee discount update #459

Merged
merged 3 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bip32.c
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ int bip32_key_from_parent_path(const struct ext_key *hdkey,
{
struct ext_key tmp[2];
size_t i, tmp_idx = 0, private_until = 0;
int ret;
int ret = WALLY_OK;

if (flags & ~BIP32_ALL_DEFINED_FLAGS)
return WALLY_EINVAL; /* These flags are not defined yet */
Expand Down
24 changes: 12 additions & 12 deletions src/data/elip200_vectors.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/psbt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2243,7 +2243,7 @@ static int pull_psbt_input(const struct wally_psbt *psbt,
bool is_pset_ft;
uint64_t field_type = pull_field_type(cursor, max, &key, &key_len, is_pset, &is_pset_ft);
const uint64_t raw_field_type = field_type;
uint64_t field_bit;
uint64_t field_bit = 0;
bool is_known;

if (is_pset_ft) {
Expand Down Expand Up @@ -2452,7 +2452,7 @@ static int pull_psbt_output(const struct wally_psbt *psbt,
bool is_pset_ft;
uint64_t field_type = pull_field_type(cursor, max, &key, &key_len, is_pset, &is_pset_ft);
const uint64_t raw_field_type = field_type;
uint64_t field_bit;
uint64_t field_bit = 0;
bool is_known;

if (is_pset_ft) {
Expand Down Expand Up @@ -2600,7 +2600,7 @@ int wally_psbt_from_bytes(const unsigned char *bytes, size_t len,
const unsigned char *key;
bool is_pset_ft;
uint64_t field_type = pull_field_type(cursor, max, &key, &key_len, is_pset, &is_pset_ft);
uint64_t field_bit;
uint64_t field_bit = 0;
bool is_known;

if (is_pset_ft) {
Expand Down
6 changes: 3 additions & 3 deletions src/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,11 @@ static size_t get_commitment_len(const unsigned char *bytes,
if (*bytes == WALLY_TX_ASSET_CT_EXPLICIT_PREFIX) {
/* Explicit value (unblinded) */
if (prefixA == WALLY_TX_ASSET_CT_VALUE_PREFIX_A)
return WALLY_TX_ASSET_CT_VALUE_UNBLIND_LEN; /* uint64 value */
return WALLY_TX_ASSET_CT_LEN; /* 32 byte asset tag, or nonce */
return WALLY_TX_ASSET_CT_VALUE_UNBLIND_LEN; /* prefix + uint64 value */
return WALLY_TX_ASSET_CT_LEN; /* prefix + 32 byte asset tag or nonce */
}
if (*bytes == prefixA || *bytes == prefixB)
return WALLY_TX_ASSET_CT_LEN; /* 32 byte commitment */
return WALLY_TX_ASSET_CT_LEN; /* prefix + 32 byte commitment */
return 0; /* Invalid serialization */
}

Expand Down
9 changes: 5 additions & 4 deletions src/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -1990,15 +1990,16 @@ int wally_tx_get_elements_weight_discount(const struct wally_tx *tx,
n += varbuff_get_length(output->surjectionproof_len);
n += varbuff_get_length(output->rangeproof_len);
n -= 2; /* Add 2 bytes to serialize empty proofs */
/* Discount value and nonce, weighted as part of the tx base size */
if (output->value_len == WALLY_TX_ASSET_CT_VALUE_LEN) {
/* Discount confidential value to an explicit value */
n += WALLY_TX_ASSET_CT_VALUE_LEN;
n -= WALLY_TX_ASSET_CT_VALUE_UNBLIND_LEN;
n += WALLY_TX_ASSET_CT_VALUE_LEN * 4;
n -= WALLY_TX_ASSET_CT_VALUE_UNBLIND_LEN * 4;
}
if (output->nonce_len == WALLY_TX_ASSET_CT_NONCE_LEN) {
/* Discount nonce commitment to an empty commitment */
n += WALLY_TX_ASSET_CT_NONCE_LEN;
n -= 1; /* Add a byte for the empty commitment */
n += WALLY_TX_ASSET_CT_NONCE_LEN * 4;
n -= 1 * 4; /* Add a byte for the empty commitment */
}
}
}
Expand Down