Psbt Functions

int wally_psbt_input_set_previous_txid(struct wally_psbt_input *input, const unsigned char *txhash, size_t txhash_len)

Set the previous txid in an input.

Parameters:
  • input – The input to update.
  • txhash – The previous hash for this input.
  • txhash_len – Length of txhash in bytes. Must be WALLY_TXHASH_LEN.
Returns:

See Error Codes

int wally_psbt_input_set_output_index(struct wally_psbt_input *input, uint32_t index)

Set the output index in an input.

Parameters:
  • input – The input to update.
  • index – The index of the spent output for this input.
Returns:

See Error Codes

int wally_psbt_input_set_sequence(struct wally_psbt_input *input, uint32_t sequence)

Set the sequence number in an input.

Parameters:
  • input – The input to update.
  • sequence – The sequence number for this input.
Returns:

See Error Codes

int wally_psbt_input_clear_sequence(struct wally_psbt_input *input)

Clear the sequence number in an input.

Parameters:
  • input – The input to update.
Returns:

See Error Codes

int wally_psbt_input_set_utxo(struct wally_psbt_input *input, const struct wally_tx *utxo)

Set the utxo in an input.

Parameters:
  • input – The input to update.
  • utxo – The (non witness) utxo for this input if it exists.
Returns:

See Error Codes

int wally_psbt_input_set_witness_utxo(struct wally_psbt_input *input, const struct wally_tx_output *witness_utxo)

Set the witness_utxo in an input.

Parameters:
  • input – The input to update.
  • witness_utxo – The witness utxo for this input if it exists.
Returns:

See Error Codes

int wally_psbt_input_set_witness_utxo_from_tx(struct wally_psbt_input *input, const struct wally_tx *utxo, uint32_t index)

Set the witness_utxo in an input from a transaction output.

Parameters:
  • input – The input to update.
  • utxo – The transaction containing the output to add.
  • index – The output index in utxo to add.
Returns:

See Error Codes

int wally_psbt_input_set_redeem_script(struct wally_psbt_input *input, const unsigned char *script, size_t script_len)

Set the redeem_script in an input.

Parameters:
  • input – The input to update.
  • script – The redeem script for this input.
  • script_len – Length of script in bytes.
Returns:

See Error Codes

int wally_psbt_input_set_witness_script(struct wally_psbt_input *input, const unsigned char *script, size_t script_len)

Set the witness_script in an input.

Parameters:
  • input – The input to update.
  • script – The witness script for this input.
  • script_len – Length of script in bytes.
Returns:

See Error Codes

int wally_psbt_input_set_final_scriptsig(struct wally_psbt_input *input, const unsigned char *final_scriptsig, size_t final_scriptsig_len)

Set the final_scriptsig in an input.

Parameters:
  • input – The input to update.
  • final_scriptsig – The scriptSig for this input.
  • final_scriptsig_len – Length of final_scriptsig in bytes.
Returns:

See Error Codes

int wally_psbt_input_set_final_witness(struct wally_psbt_input *input, const struct wally_tx_witness_stack *witness)

Set the final witness in an input.

Parameters:
  • input – The input to update.
  • witness – The witness stack for the input, or NULL if not present.
Returns:

See Error Codes

int wally_psbt_input_set_keypaths(struct wally_psbt_input *input, const struct wally_map *map_in)

Set the keypaths in an input.

Parameters:
  • input – The input to update.
  • map_in – The HD keypaths for this input.
Returns:

See Error Codes

int wally_psbt_input_find_keypath(struct wally_psbt_input *input, const unsigned char *pub_key, size_t pub_key_len, size_t *written)

Find a keypath matching a pubkey in an input.

Parameters:
  • input – The input to search in.
  • pub_key – The pubkey to find.
  • pub_key_len – Length of pub_key in bytes. Must be EC_PUBLIC_KEY_UNCOMPRESSED_LEN or EC_PUBLIC_KEY_LEN.
  • written – On success, set to zero if the item is not found, otherwise the index of the item plus one.
Returns:

See Error Codes

int wally_psbt_input_keypath_add(struct wally_psbt_input *input, const unsigned char *pub_key, size_t pub_key_len, const unsigned char *fingerprint, size_t fingerprint_len, const uint32_t *child_path, size_t child_path_len)

Convert and add a pubkey/keypath to an input.

Parameters:
  • input – The input to add to.
  • pub_key – The pubkey to add.
  • pub_key_len – Length of pub_key in bytes. Must be EC_PUBLIC_KEY_UNCOMPRESSED_LEN or EC_PUBLIC_KEY_LEN.
  • fingerprint – The master key fingerprint for the pubkey.
  • fingerprint_len – Length of fingerprint in bytes. Must be BIP32_KEY_FINGERPRINT_LEN.
  • child_path – The BIP32 derivation path for the pubkey.
  • child_path_len – The number of items in child_path.
Returns:

See Error Codes

int wally_psbt_input_set_signatures(struct wally_psbt_input *input, const struct wally_map *map_in)

Set the partial signatures in an input.

Parameters:
  • input – The input to update.
  • map_in – The partial signatures for this input.
Returns:

See Error Codes

int wally_psbt_input_find_signature(struct wally_psbt_input *input, const unsigned char *pub_key, size_t pub_key_len, size_t *written)

Find a partial signature matching a pubkey in an input.

Parameters:
  • input – The input to search in.
  • pub_key – The pubkey to find.
  • pub_key_len – Length of pub_key in bytes. Must be EC_PUBLIC_KEY_UNCOMPRESSED_LEN or EC_PUBLIC_KEY_LEN.
  • written – On success, set to zero if the item is not found, otherwise the index of the item plus one.
Returns:

See Error Codes

int wally_psbt_input_add_signature(struct wally_psbt_input *input, const unsigned char *pub_key, size_t pub_key_len, const unsigned char *sig, size_t sig_len)

Add a pubkey/partial signature item to an input.

Parameters:
  • input – The input to add the partial signature to.
  • pub_key – The pubkey to find.
  • pub_key_len – Length of pub_key in bytes. Must be EC_PUBLIC_KEY_UNCOMPRESSED_LEN or EC_PUBLIC_KEY_LEN.
  • sig – The DER-encoded signature plus sighash byte to add.
  • sig_len – The length of sig in bytes.
Returns:

See Error Codes

int wally_psbt_input_set_unknowns(struct wally_psbt_input *input, const struct wally_map *map_in)

Set the unknown values in an input.

Parameters:
  • input – The input to update.
  • map_in – The unknown key value pairs for this input.
Returns:

See Error Codes

int wally_psbt_input_find_unknown(struct wally_psbt_input *input, const unsigned char *key, size_t key_len, size_t *written)

Find an unknown item matching a key in an input.

Parameters:
  • input – The input to search in.
  • key – The key to find.
  • key_len – Length of key in bytes.
  • written – On success, set to zero if the item is not found, otherwise the index of the item plus one.
Returns:

See Error Codes

int wally_psbt_input_set_sighash(struct wally_psbt_input *input, uint32_t sighash)

Set the sighash type in an input.

Parameters:
  • input – The input to update.
  • sighash – The sighash type for this input.
Returns:

See Error Codes

int wally_psbt_input_set_required_locktime(struct wally_psbt_input *input, uint32_t required_locktime)

Set the required lock time in an input.

Parameters:
  • input – The input to update.
  • required_locktime – The required locktime for this input.
Returns:

See Error Codes

int wally_psbt_input_clear_required_locktime(struct wally_psbt_input *input)

Clear the required lock time in an input.

Parameters:
  • input – The input to update.
Returns:

See Error Codes

int wally_psbt_input_set_required_lockheight(struct wally_psbt_input *input, uint32_t required_lockheight)

Set the required lock height in an input.

Parameters:
  • input – The input to update.
  • required_lockheight – The required locktime for this input.
Returns:

See Error Codes

int wally_psbt_input_clear_required_lockheight(struct wally_psbt_input *input)

Clear the required lock height in an input.

Parameters:
  • input – The input to update.
Returns:

See Error Codes

int wally_psbt_input_set_amount(struct wally_psbt_input *input, uint64_t amount)

Set the unblinded amount in an input.

Parameters:
  • input – The input to update.
  • amount – The amount of the input.

Note

This operates on the PSET field PSBT_ELEMENTS_IN_EXPLICIT_VALUE.

Returns:See Error Codes
int wally_psbt_input_get_amount_rangeproof(const struct wally_psbt_input *input, unsigned char *bytes_out, size_t len, size_t *written)

Get the explicit amount rangeproof from an input.

Parameters:
  • input – The input to get from.
  • bytes_out – Destination for the explicit amount rangeproof.
  • len – Size of bytes_out in bytes.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.

Note

This operates on the PSET field PSBT_ELEMENTS_IN_VALUE_PROOF.

Returns:See Variable Length Output Buffers
int wally_psbt_input_get_amount_rangeproof_len(const struct wally_psbt_input *input, size_t *written)

Get the length of the explicit amount rangeproof from an input.

Parameters:
  • input – The input to get from.
  • written – Destination for the length, or zero if not present.
Returns:

See Error Codes

int wally_psbt_input_set_amount_rangeproof(struct wally_psbt_input *input, const unsigned char *rangeproof, size_t rangeproof_len)

Set the explicit amount rangeproof in an input.

Parameters:
  • input – The input to update.
  • rangeproof – The explicit amount rangeproof.
  • rangeproof_len – Size of rangeproof in bytes.
Returns:

See Error Codes

int wally_psbt_input_clear_amount_rangeproof(struct wally_psbt_input *input)

Clear the explicit amount rangeproof in an input.

Parameters:
  • input – The input to update.
Returns:

See Error Codes

int wally_psbt_input_get_asset(const struct wally_psbt_input *input, unsigned char *bytes_out, size_t len, size_t *written)

Get the explicit asset tag from an input.

Parameters:
  • input – The input to get from.
  • bytes_out – Destination for the explicit asset tag.
  • len – Size of bytes_out in bytes.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.

Note

This operates on the PSET field PSBT_ELEMENTS_IN_EXPLICIT_ASSET.

Returns:See Variable Length Output Buffers
int wally_psbt_input_get_asset_len(const struct wally_psbt_input *input, size_t *written)

Get the length of the explicit asset tag from an input.

Parameters:
  • input – The input to get from.
  • written – Destination for the length, or zero if not present.
Returns:

See Error Codes

int wally_psbt_input_set_asset(struct wally_psbt_input *input, const unsigned char *asset, size_t asset_len)

Set the explicit asset tag in an input.

Parameters:
  • input – The input to update.
  • asset – The explicit asset tag.
  • asset_len – Size of asset in bytes. Must be ASSET_TAG_LEN.
Returns:

See Error Codes

int wally_psbt_input_clear_asset(struct wally_psbt_input *input)

Clear the explicit asset tag in an input.

Parameters:
  • input – The input to update.
Returns:

See Error Codes

int wally_psbt_input_get_asset_surjectionproof(const struct wally_psbt_input *input, unsigned char *bytes_out, size_t len, size_t *written)

Get the explicit asset surjection proof from an input.

Parameters:
  • input – The input to get from.
  • bytes_out – Destination for the explicit asset surjection proof.
  • len – Size of bytes_out in bytes.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.

Note

This operates on the PSET field PSBT_ELEMENTS_IN_ASSET_PROOF.

Returns:See Variable Length Output Buffers
int wally_psbt_input_get_asset_surjectionproof_len(const struct wally_psbt_input *input, size_t *written)

Get the length of the explicit asset surjection proof from an input.

Parameters:
  • input – The input to get from.
  • written – Destination for the length, or zero if not present.
Returns:

See Error Codes

int wally_psbt_input_set_asset_surjectionproof(struct wally_psbt_input *input, const unsigned char *surjectionproof, size_t surjectionproof_len)

Set the explicit asset surjection proof in an input.

Parameters:
  • input – The input to update.
  • surjectionproof – The explicit asset surjection proof.
  • surjectionproof_len – Size of surjectionproof in bytes.
Returns:

See Error Codes

int wally_psbt_input_clear_asset_surjectionproof(struct wally_psbt_input *input)

Clear the explicit asset surjection proof in an input.

Parameters:
  • input – The input to update.
Returns:

See Error Codes

int wally_psbt_input_set_issuance_amount(struct wally_psbt_input *input, uint64_t amount)

Set the unblinded token issuance amount in an input.

Parameters:
  • input – The input to update.
  • amount – The issuance amount.

Note

Setting the amount to zero indicates no issuance.

Returns:See Error Codes
int wally_psbt_input_set_inflation_keys(struct wally_psbt_input *input, uint64_t value)

Set the unblinded number of inflation (reissuance) keys in an input.

Parameters:
  • input – The input to update.
  • value – The number of inflation keys.
Returns:

See Error Codes

int wally_psbt_input_set_pegin_amount(struct wally_psbt_input *input, uint64_t amount)

Set the peg-in amount in an input.

Parameters:
  • input – The input to update.
  • amount – The peg-in amount.
Returns:

See Error Codes

int wally_psbt_input_set_pegin_tx(struct wally_psbt_input *input, const struct wally_tx *tx)

Set the peg-in transaction in an input.

Parameters:
  • input – The input to update.
  • tx – The (non witness) peg-in transaction for this input if it exists.
Returns:

See Error Codes

int wally_psbt_input_set_pegin_witness(struct wally_psbt_input *input, const struct wally_tx_witness_stack *witness)

Set the peg-in witness in an input.

Parameters:
  • input – The input to update.
  • witness – The peg-in witness stack for the input, or NULL if not present.
Returns:

See Error Codes

int wally_psbt_input_get_pegin_txout_proof(const struct wally_psbt_input *input, unsigned char *bytes_out, size_t len, size_t *written)

Get the peg-in transaction output proof from an input.

Parameters:
  • input – The input to get from.
  • bytes_out – Destination for the peg-in transaction output proof.
  • len – Size of bytes_out in bytes.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.

Note

This operates on the PSET field PSBT_ELEMENTS_IN_PEG_IN_TXOUT_PROOF.

Returns:See Variable Length Output Buffers
int wally_psbt_input_get_pegin_txout_proof_len(const struct wally_psbt_input *input, size_t *written)

Get the length of a peg-in transaction output proof from an input.

Parameters:
  • input – The input to get from.
  • written – Destination for the length, or zero if not present.
Returns:

See Error Codes

int wally_psbt_input_set_pegin_txout_proof(struct wally_psbt_input *input, const unsigned char *txout_proof, size_t txout_proof_len)

Set the peg-in transaction output proof in an input.

Parameters:
  • input – The input to update.
  • txout_proof – The peg-in transaction output proof.
  • txout_proof_len – Size of txout_proof in bytes.
Returns:

See Error Codes

int wally_psbt_input_clear_pegin_txout_proof(struct wally_psbt_input *input)

Clear the peg-in transaction output proof in an input.

Parameters:
  • input – The input to update.
Returns:

See Error Codes

int wally_psbt_input_get_pegin_genesis_blockhash(const struct wally_psbt_input *input, unsigned char *bytes_out, size_t len, size_t *written)

Get the peg-in genesis blockhash from an input.

Parameters:
  • input – The input to get from.
  • bytes_out – Destination for the peg-in genesis blockhash.
  • len – Size of bytes_out in bytes.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.
Returns:

See Variable Length Output Buffers

int wally_psbt_input_get_pegin_genesis_blockhash_len(const struct wally_psbt_input *input, size_t *written)

Get the length of a peg-in genesis blockhash from an input.

Parameters:
  • input – The input to get from.
  • written – Destination for the length, or zero if not present.

Note

This operates on the PSET field PSBT_ELEMENTS_IN_PEG_IN_GENESIS_HASH.

Returns:See Error Codes
int wally_psbt_input_set_pegin_genesis_blockhash(struct wally_psbt_input *input, const unsigned char *genesis_blockhash, size_t genesis_blockhash_len)

Set the peg-in genesis blockhash in an input.

Parameters:
  • input – The input to update.
  • genesis_blockhash – The peg-in genesis blockhash.
  • genesis_blockhash_len – Size of genesis_blockhash in bytes. Must be WALLY_TXHASH_LEN.
Returns:

See Error Codes

int wally_psbt_input_clear_pegin_genesis_blockhash(struct wally_psbt_input *input)

Clear the peg-in genesis blockhash in an input.

Parameters:
  • input – The input to update.
Returns:

See Error Codes

int wally_psbt_input_get_pegin_claim_script(const struct wally_psbt_input *input, unsigned char *bytes_out, size_t len, size_t *written)

Get the peg-in claim script from an input.

Parameters:
  • input – The input to get from.
  • bytes_out – Destination for the peg-in claim script.
  • len – Size of bytes_out in bytes.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.

Note

This operates on the PSET field PSBT_ELEMENTS_IN_PEG_IN_CLAIM_SCRIPT.

Returns:See Variable Length Output Buffers
int wally_psbt_input_get_pegin_claim_script_len(const struct wally_psbt_input *input, size_t *written)

Get the length of a peg-in claim script from an input.

Parameters:
  • input – The input to get from.
  • written – Destination for the length, or zero if not present.
Returns:

See Error Codes

int wally_psbt_input_set_pegin_claim_script(struct wally_psbt_input *input, const unsigned char *script, size_t script_len)

Set the peg-in claim script in an input.

Parameters:
  • input – The input to update.
  • script – The peg-in claim script.
  • script_len – Size of script in bytes.
Returns:

See Error Codes

int wally_psbt_input_clear_pegin_claim_script(struct wally_psbt_input *input)

Clear the peg-in claim script in an input.

Parameters:
  • input – The input to update.
Returns:

See Error Codes

int wally_psbt_input_get_issuance_amount_commitment(const struct wally_psbt_input *input, unsigned char *bytes_out, size_t len, size_t *written)

Get the blinded token issuance amount from an input.

Parameters:
  • input – The input to get from.
  • bytes_out – Destination for the blinded issuance amount.
  • len – Size of bytes_out in bytes. Must be ASSET_COMMITMENT_LEN.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.

Note

This operates on the PSET field PSBT_ELEMENTS_IN_ISSUANCE_VALUE_COMMITMENT.

Returns:See Variable Length Output Buffers
int wally_psbt_input_get_issuance_amount_commitment_len(const struct wally_psbt_input *input, size_t *written)

Get the length of a blinded token issuance amount from an input.

Parameters:
  • input – The input to get from.
  • written – Destination for the length, or zero if not present.
Returns:

See Error Codes

int wally_psbt_input_set_issuance_amount_commitment(struct wally_psbt_input *input, const unsigned char *commitment, size_t commitment_len)

Set the blinded token issuance amount in an input.

Parameters:
  • input – The input to update.
  • commitment – The blinded issuance amount commitment.
  • commitment_len – Size of commitment in bytes. Must be ASSET_COMMITMENT_LEN.
Returns:

See Error Codes

int wally_psbt_input_clear_issuance_amount_commitment(struct wally_psbt_input *input)

Clear the blinded token issuance amount in an input.

Parameters:
  • input – The input to update.
Returns:

See Error Codes

int wally_psbt_input_get_issuance_amount_rangeproof(const struct wally_psbt_input *input, unsigned char *bytes_out, size_t len, size_t *written)

Get the issuance amount rangeproof from an input.

Parameters:
  • input – The input to get from.
  • bytes_out – Destination for the issuance amount rangeproof.
  • len – Size of bytes_out in bytes.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.

Note

This operates on the PSET field PSBT_ELEMENTS_IN_ISSUANCE_VALUE_RANGEPROOF.

Returns:See Variable Length Output Buffers
int wally_psbt_input_get_issuance_amount_rangeproof_len(const struct wally_psbt_input *input, size_t *written)

Get the length of the issuance amount rangeproof from an input.

Parameters:
  • input – The input to get from.
  • written – Destination for the length, or zero if not present.
Returns:

See Error Codes

int wally_psbt_input_set_issuance_amount_rangeproof(struct wally_psbt_input *input, const unsigned char *rangeproof, size_t rangeproof_len)

Set the issuance amount rangeproof in an input.

Parameters:
  • input – The input to update.
  • rangeproof – The issuance amount rangeproof.
  • rangeproof_len – Size of rangeproof in bytes.
Returns:

See Error Codes

int wally_psbt_input_clear_issuance_amount_rangeproof(struct wally_psbt_input *input)

Clear the issuance amount rangeproof in an input.

Parameters:
  • input – The input to update.
Returns:

See Error Codes

int wally_psbt_input_get_issuance_blinding_nonce(const struct wally_psbt_input *input, unsigned char *bytes_out, size_t len, size_t *written)

Get the asset issuance blinding nonce from an input.

Parameters:
  • input – The input to get from.
  • bytes_out – Destination for the asset issuance blinding nonce.
  • len – Size of bytes_out in bytes. Must be BLINDING_FACTOR_LEN.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.

Note

This operates on the PSET field PSBT_ELEMENTS_IN_ISSUANCE_BLINDING_NONCE.

Returns:See Variable Length Output Buffers
int wally_psbt_input_get_issuance_blinding_nonce_len(const struct wally_psbt_input *input, size_t *written)

Get the length of a asset issuance blinding nonce from an input.

Parameters:
  • input – The input to get from.
  • written – Destination for the length, or zero if not present.
Returns:

See Error Codes

int wally_psbt_input_set_issuance_blinding_nonce(struct wally_psbt_input *input, const unsigned char *nonce, size_t nonce_len)

Set the asset issuance blinding nonce in an input.

Parameters:
  • input – The input to update.
  • nonce – Asset issuance or revelation blinding nonce.
  • nonce_len – Size of nonce in bytes. Must be ASSET_TAG_LEN.
Returns:

See Error Codes

int wally_psbt_input_clear_issuance_blinding_nonce(struct wally_psbt_input *input)

Clear the asset issuance blinding nonce in an input.

Parameters:
  • input – The input to update.
Returns:

See Error Codes

int wally_psbt_input_get_issuance_asset_entropy(const struct wally_psbt_input *input, unsigned char *bytes_out, size_t len, size_t *written)

Get the asset issuance entropy from an input.

Parameters:
  • input – The input to get from.
  • bytes_out – Destination for the asset issuance entropy.
  • len – Size of bytes_out in bytes. Must be BLINDING_FACTOR_LEN.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.

Note

This operates on the PSET field PSBT_ELEMENTS_IN_ISSUANCE_ASSET_ENTROPY.

Returns:See Variable Length Output Buffers
int wally_psbt_input_get_issuance_asset_entropy_len(const struct wally_psbt_input *input, size_t *written)

Get the length of a asset issuance entropy from an input.

Parameters:
  • input – The input to get from.
  • written – Destination for the length, or zero if not present.
Returns:

See Error Codes

int wally_psbt_input_set_issuance_asset_entropy(struct wally_psbt_input *input, const unsigned char *entropy, size_t entropy_len)

Set the asset issuance entropy in an input.

Parameters:
  • input – The input to update.
  • entropy – The asset issuance entropy.
  • entropy_len – Size of entropy in bytes.
Returns:

See Error Codes

int wally_psbt_input_clear_issuance_asset_entropy(struct wally_psbt_input *input)

Clear the asset issuance entropy in an input.

Parameters:
  • input – The input to update.
Returns:

See Error Codes

int wally_psbt_input_get_issuance_amount_blinding_rangeproof(const struct wally_psbt_input *input, unsigned char *bytes_out, size_t len, size_t *written)

Get the issuance amount blinding rangeproof from an input.

Parameters:
  • input – The input to get from.
  • bytes_out – Destination for the issuance amount blinding rangeproof.
  • len – Size of bytes_out in bytes.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.

Note

This operates on the PSET field PSBT_ELEMENTS_IN_ISSUANCE_BLIND_VALUE_PROOF.

Returns:See Variable Length Output Buffers
int wally_psbt_input_get_issuance_amount_blinding_rangeproof_len(const struct wally_psbt_input *input, size_t *written)

Get the length of a issuance amount blinding rangeproof from an input.

Parameters:
  • input – The input to get from.
  • written – Destination for the length, or zero if not present.
Returns:

See Error Codes

int wally_psbt_input_set_issuance_amount_blinding_rangeproof(struct wally_psbt_input *input, const unsigned char *rangeproof, size_t rangeproof_len)

Set the issuance amount blinding rangeproof in an input.

Parameters:
  • input – The input to update.
  • rangeproof – The issuance amount blinding rangeproof.
  • rangeproof_len – Size of rangeproof in bytes.
Returns:

See Error Codes

int wally_psbt_input_clear_issuance_amount_blinding_rangeproof(struct wally_psbt_input *input)

Clear the issuance amount blinding rangeproof in an input.

Parameters:
  • input – The input to update.
Returns:

See Error Codes

int wally_psbt_input_get_inflation_keys_commitment(const struct wally_psbt_input *input, unsigned char *bytes_out, size_t len, size_t *written)

Get the blinded number of reissuance tokens from an input.

Parameters:
  • input – The input to get from.
  • bytes_out – Destination for the blinded number of reissuance tokens.
  • len – Size of bytes_out in bytes. Must be ASSET_COMMITMENT_LEN.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.

Note

This operates on the PSET field PSBT_ELEMENTS_IN_INFLATION_KEYS_COMMITMENT.

Returns:See Variable Length Output Buffers
int wally_psbt_input_get_inflation_keys_commitment_len(const struct wally_psbt_input *input, size_t *written)

Get the length of the blinded number of reissuance tokens from an input.

Parameters:
  • input – The input to get from.
  • written – Destination for the length, or zero if not present.
Returns:

See Error Codes

int wally_psbt_input_set_inflation_keys_commitment(struct wally_psbt_input *input, const unsigned char *commitment, size_t commitment_len)

Set the blinded number of reissuance tokens in an input.

Parameters:
  • input – The input to update.
  • commitment – The blinded number of reissuance tokens.
  • commitment_len – Size of commitment in bytes. Must be ASSET_COMMITMENT_LEN.
Returns:

See Error Codes

int wally_psbt_input_clear_inflation_keys_commitment(struct wally_psbt_input *input)

Clear the blinded number of reissuance tokens in an input.

Parameters:
  • input – The input to update.
Returns:

See Error Codes

int wally_psbt_input_get_inflation_keys_rangeproof(const struct wally_psbt_input *input, unsigned char *bytes_out, size_t len, size_t *written)

Get the reissuance tokens rangeproof from an input.

Parameters:
  • input – The input to get from.
  • bytes_out – Destination for the reissuance tokens rangeproof.
  • len – Size of bytes_out in bytes.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.

Note

This operates on the PSET field PSBT_ELEMENTS_IN_INFLATION_KEYS_RANGEPROOF.

Returns:See Variable Length Output Buffers
int wally_psbt_input_get_inflation_keys_rangeproof_len(const struct wally_psbt_input *input, size_t *written)

Get the length of a reissuance tokens rangeproof from an input.

Parameters:
  • input – The input to get from.
  • written – Destination for the length, or zero if not present.
Returns:

See Error Codes

int wally_psbt_input_set_inflation_keys_rangeproof(struct wally_psbt_input *input, const unsigned char *rangeproof, size_t rangeproof_len)

Set the reissuance tokens rangeproof in an input.

Parameters:
  • input – The input to update.
  • rangeproof – The reissuance tokens rangeproof.
  • rangeproof_len – Size of rangeproof in bytes.
Returns:

See Error Codes

int wally_psbt_input_clear_inflation_keys_rangeproof(struct wally_psbt_input *input)

Clear the reissuance tokens rangeproof in an input.

Parameters:
  • input – The input to update.
Returns:

See Error Codes

int wally_psbt_input_get_inflation_keys_blinding_rangeproof(const struct wally_psbt_input *input, unsigned char *bytes_out, size_t len, size_t *written)

Get the reissuance tokens blinding rangeproof from an input.

Parameters:
  • input – The input to get from.
  • bytes_out – Destination for the reissuance tokens blinding rangeproof.
  • len – Size of bytes_out in bytes.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.

Note

This operates on the PSET field PSBT_ELEMENTS_IN_ISSUANCE_BLIND_INFLATION_KEYS_PROOF.

Returns:See Variable Length Output Buffers
int wally_psbt_input_get_inflation_keys_blinding_rangeproof_len(const struct wally_psbt_input *input, size_t *written)

Get the length of a reissuance tokens blinding rangeproof from an input.

Parameters:
  • input – The input to get from.
  • written – Destination for the length, or zero if not present.
Returns:

See Error Codes

int wally_psbt_input_set_inflation_keys_blinding_rangeproof(struct wally_psbt_input *input, const unsigned char *rangeproof, size_t rangeproof_len)

Set the reissuance tokens blinding rangeproof in an input.

Parameters:
  • input – The input to update.
  • rangeproof – The reissuance tokens blinding rangeproof.
  • rangeproof_len – Size of rangeproof in bytes.
Returns:

See Error Codes

int wally_psbt_input_clear_inflation_keys_blinding_rangeproof(struct wally_psbt_input *input)

Clear the reissuance tokens blinding rangeproof in an input.

Parameters:
  • input – The input to update.
Returns:

See Error Codes

int wally_psbt_input_get_utxo_rangeproof(const struct wally_psbt_input *input, unsigned char *bytes_out, size_t len, size_t *written)

Get the UTXO rangeproof from an input.

Parameters:
  • input – The input to get from.
  • bytes_out – Destination for the UTXO rangeproof.
  • len – Size of bytes_out in bytes.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.

Note

This operates on the PSET field PSBT_ELEMENTS_IN_UTXO_RANGEPROOF.

Returns:See Variable Length Output Buffers
int wally_psbt_input_get_utxo_rangeproof_len(const struct wally_psbt_input *input, size_t *written)

Get the length of a UTXO rangeproof from an input.

Parameters:
  • input – The input to get from.
  • written – Destination for the length, or zero if not present.
Returns:

See Error Codes

int wally_psbt_input_set_utxo_rangeproof(struct wally_psbt_input *input, const unsigned char *rangeproof, size_t rangeproof_len)

Set the UTXO rangeproof in an input.

Parameters:
  • input – The input to update.
  • rangeproof – The UTXO rangeproof.
  • rangeproof_len – Size of rangeproof in bytes.
Returns:

See Error Codes

int wally_psbt_input_clear_utxo_rangeproof(struct wally_psbt_input *input)

Clear the UTXO rangeproof in an input.

Parameters:
  • input – The input to update.
Returns:

See Error Codes

int wally_psbt_input_generate_explicit_proofs(struct wally_psbt_input *input, uint64_t satoshi, const unsigned char *asset, size_t asset_len, const unsigned char *abf, size_t abf_len, const unsigned char *vbf, size_t vbf_len, const unsigned char *entropy, size_t entropy_len)

Generate explicit proofs and unblinded values from an inputs witness UTXO.

Parameters:
  • input – The input to generate proofs for.
  • satoshi – The explicit value of the input.
  • asset – The explicit asset tag.
  • asset_len – Size of asset in bytes. Must be ASSET_TAG_LEN.
  • abf – Asset blinding factor.
  • abf_len – Length of abf. Must be BLINDING_FACTOR_LEN.
  • vbf – Value blinding factor.
  • vbf_len – Length of vbf. Must be BLINDING_FACTOR_LEN.
  • entropy – Random entropy for explicit range proof generation.
  • entropy_len – Size of entropy in bytes. Must be BLINDING_FACTOR_LEN.

Note

This function exposes the unblinded asset and value in the PSET,

which is only appropriate in certain multi-party protocols.

Returns:See Error Codes
int wally_psbt_input_is_finalized(const struct wally_psbt_input *input, size_t *written)

Determine if a PSBT input is finalized.

Parameters:
  • input – The input to check.
  • written – On success, set to one if the input is finalized, otherwise zero.
Returns:

See Error Codes

int wally_psbt_output_set_redeem_script(struct wally_psbt_output *output, const unsigned char *script, size_t script_len)

Set the redeem_script in an output.

Parameters:
  • output – The input to update.
  • script – The redeem script for this output.
  • script_len – Length of script in bytes.
Returns:

See Error Codes

int wally_psbt_output_set_witness_script(struct wally_psbt_output *output, const unsigned char *script, size_t script_len)

Set the witness_script in an output.

Parameters:
  • output – The output to update.
  • script – The witness script for this output.
  • script_len – Length of script in bytes.
Returns:

See Error Codes

int wally_psbt_output_set_keypaths(struct wally_psbt_output *output, const struct wally_map *map_in)

Set the keypaths in an output.

Parameters:
  • output – The output to update.
  • map_in – The HD keypaths for this output.
Returns:

See Error Codes

int wally_psbt_output_find_keypath(struct wally_psbt_output *output, const unsigned char *pub_key, size_t pub_key_len, size_t *written)

Find a keypath matching a pubkey in an output.

Parameters:
  • output – The output to search in.
  • pub_key – The pubkey to find.
  • pub_key_len – Length of pub_key in bytes. Must be EC_PUBLIC_KEY_UNCOMPRESSED_LEN or EC_PUBLIC_KEY_LEN.
  • written – On success, set to zero if the item is not found, otherwise the index of the item plus one.
Returns:

See Error Codes

int wally_psbt_output_keypath_add(struct wally_psbt_output *output, const unsigned char *pub_key, size_t pub_key_len, const unsigned char *fingerprint, size_t fingerprint_len, const uint32_t *child_path, size_t child_path_len)

Convert and add a pubkey/keypath to an output.

Parameters:
  • output – The output to add to.
  • pub_key – The pubkey to add.
  • pub_key_len – Length of pub_key in bytes. Must be EC_PUBLIC_KEY_UNCOMPRESSED_LEN or EC_PUBLIC_KEY_LEN.
  • fingerprint – The master key fingerprint for the pubkey.
  • fingerprint_len – Length of fingerprint in bytes. Must be BIP32_KEY_FINGERPRINT_LEN.
  • child_path – The BIP32 derivation path for the pubkey.
  • child_path_len – The number of items in child_path.
Returns:

See Error Codes

int wally_psbt_output_set_unknowns(struct wally_psbt_output *output, const struct wally_map *map_in)

Set the unknown map in an output.

Parameters:
  • output – The output to update.
  • map_in – The unknown key value pairs for this output.
Returns:

See Error Codes

int wally_psbt_output_find_unknown(struct wally_psbt_output *output, const unsigned char *key, size_t key_len, size_t *written)

Find an unknown item matching a key in an output.

Parameters:
  • output – The output to search in.
  • key – The key to find.
  • key_len – Length of key in bytes.
  • written – On success, set to zero if the item is not found, otherwise the index of the item plus one.
Returns:

See Error Codes

int wally_psbt_output_set_amount(struct wally_psbt_output *output, uint64_t amount)

Set the amount in an output.

Parameters:
  • output – The output to update.
  • amount – The amount for this output.
Returns:

See Error Codes

int wally_psbt_output_clear_amount(struct wally_psbt_output *output)

Clear the amount in an output.

Parameters:
  • output – The output to update.
Returns:

See Error Codes

int wally_psbt_output_set_script(struct wally_psbt_output *output, const unsigned char *script, size_t script_len)

Set the script in an output.

Parameters:
  • output – The output to update.
  • script – The script for this output.
  • script_len – Length of script in bytes.
Returns:

See Error Codes

int wally_psbt_output_set_blinder_index(struct wally_psbt_output *output, uint32_t index)

Set the input blinder index in an output.

Parameters:
  • output – The output to update.
  • index – The input blinder index for this output.
Returns:

See Error Codes

int wally_psbt_output_clear_blinder_index(struct wally_psbt_output *output)

Clear the input blinder index from an output.

Parameters:
  • output – The output to update.
Returns:

See Error Codes

int wally_psbt_output_get_value_commitment(const struct wally_psbt_output *output, unsigned char *bytes_out, size_t len, size_t *written)

Get the blinded asset value from an output.

Parameters:
  • output – The output to get from.
  • bytes_out – Destination for the blinded asset value.
  • len – Size of bytes_out in bytes.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.

Note

This operates on the PSET field PSBT_ELEMENTS_OUT_VALUE_COMMITMENT.

Returns:See Variable Length Output Buffers
int wally_psbt_output_get_value_commitment_len(const struct wally_psbt_output *output, size_t *written)

Get the length of the blinded asset value from an output.

Parameters:
  • output – The output to get from.
  • written – Destination for the length, or zero if not present.
Returns:

See Error Codes

int wally_psbt_output_set_value_commitment(struct wally_psbt_output *output, const unsigned char *commitment, size_t commitment_len)

Set the blinded asset value in an output.

Parameters:
  • output – The output to update.
  • commitment – The blinded asset value.
  • commitment_len – Size of commitment in bytes.
Returns:

See Error Codes

int wally_psbt_output_clear_value_commitment(struct wally_psbt_output *output)

Clear the blinded asset value in an output.

Parameters:
  • output – The output to update.
Returns:

See Error Codes

int wally_psbt_output_get_asset(const struct wally_psbt_output *output, unsigned char *bytes_out, size_t len, size_t *written)

Get the asset tag from an output.

Parameters:
  • output – The output to get from.
  • bytes_out – Destination for the asset tag.
  • len – Size of bytes_out in bytes.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.

Note

This operates on the PSET field PSBT_ELEMENTS_OUT_ASSET.

Returns:See Variable Length Output Buffers
int wally_psbt_output_get_asset_len(const struct wally_psbt_output *output, size_t *written)

Get the length of the asset tag from an output.

Parameters:
  • output – The output to get from.
  • written – Destination for the length, or zero if not present.
Returns:

See Error Codes

int wally_psbt_output_set_asset(struct wally_psbt_output *output, const unsigned char *asset, size_t asset_len)

Set the asset tag in an output.

Parameters:
  • output – The output to update.
  • asset – The asset tag.
  • asset_len – Size of asset in bytes. Must be ASSET_TAG_LEN.
Returns:

See Error Codes

int wally_psbt_output_clear_asset(struct wally_psbt_output *output)

Clear the asset tag in an output.

Parameters:
  • output – The output to update.
Returns:

See Error Codes

int wally_psbt_output_get_asset_commitment(const struct wally_psbt_output *output, unsigned char *bytes_out, size_t len, size_t *written)

Get the blinded asset tag from an output.

Parameters:
  • output – The output to get from.
  • bytes_out – Destination for the blinded asset tag.
  • len – Size of bytes_out in bytes.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.

Note

This operates on the PSET field PSBT_ELEMENTS_OUT_ASSET_COMMITMENT.

Returns:See Variable Length Output Buffers
int wally_psbt_output_get_asset_commitment_len(const struct wally_psbt_output *output, size_t *written)

Get the length of the blinded asset tag from an output.

Parameters:
  • output – The output to get from.
  • written – Destination for the length, or zero if not present.
Returns:

See Error Codes

int wally_psbt_output_set_asset_commitment(struct wally_psbt_output *output, const unsigned char *commitment, size_t commitment_len)

Set the blinded asset tag in an output.

Parameters:
  • output – The output to update.
  • commitment – The blinded asset tag.
  • commitment_len – Size of commitment in bytes.
Returns:

See Error Codes

int wally_psbt_output_clear_asset_commitment(struct wally_psbt_output *output)

Clear the blinded asset tag in an output.

Parameters:
  • output – The output to update.
Returns:

See Error Codes

int wally_psbt_output_get_value_rangeproof(const struct wally_psbt_output *output, unsigned char *bytes_out, size_t len, size_t *written)

Get the output value range proof from an output.

Parameters:
  • output – The output to get from.
  • bytes_out – Destination for the output value range proof.
  • len – Size of bytes_out in bytes.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.

Note

This operates on the PSET field PSBT_ELEMENTS_OUT_VALUE_RANGEPROOF.

Returns:See Variable Length Output Buffers
int wally_psbt_output_get_value_rangeproof_len(const struct wally_psbt_output *output, size_t *written)

Get the length of the output value range proof from an output.

Parameters:
  • output – The output to get from.
  • written – Destination for the length, or zero if not present.
Returns:

See Error Codes

int wally_psbt_output_set_value_rangeproof(struct wally_psbt_output *output, const unsigned char *rangeproof, size_t rangeproof_len)

Set the output value range proof in an output.

Parameters:
  • output – The output to update.
  • rangeproof – The output value range proof.
  • rangeproof_len – Size of rangeproof in bytes.
Returns:

See Error Codes

int wally_psbt_output_clear_value_rangeproof(struct wally_psbt_output *output)

Clear the output value range proof in an output.

Parameters:
  • output – The output to update.
Returns:

See Error Codes

int wally_psbt_output_get_asset_surjectionproof(const struct wally_psbt_output *output, unsigned char *bytes_out, size_t len, size_t *written)

Get the asset surjection proof from an output.

Parameters:
  • output – The output to get from.
  • bytes_out – Destination for the asset surjection proof.
  • len – Size of bytes_out in bytes.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.

Note

This operates on the PSET field PSBT_ELEMENTS_OUT_ASSET_SURJECTION_PROOF.

Returns:See Variable Length Output Buffers
int wally_psbt_output_get_asset_surjectionproof_len(const struct wally_psbt_output *output, size_t *written)

Get the length of the asset surjection proof from an output.

Parameters:
  • output – The output to get from.
  • written – Destination for the length, or zero if not present.
Returns:

See Error Codes

int wally_psbt_output_set_asset_surjectionproof(struct wally_psbt_output *output, const unsigned char *surjectionproof, size_t surjectionproof_len)

Set the asset surjection proof in an output.

Parameters:
  • output – The output to update.
  • surjectionproof – The asset surjection proof.
  • surjectionproof_len – Size of surjectionproof in bytes.
Returns:

See Error Codes

int wally_psbt_output_clear_asset_surjectionproof(struct wally_psbt_output *output)

Clear the asset surjection proof in an output.

Parameters:
  • output – The output to update.
Returns:

See Error Codes

int wally_psbt_output_get_blinding_public_key(const struct wally_psbt_output *output, unsigned char *bytes_out, size_t len, size_t *written)

Get the blinding public key from an output.

Parameters:
  • output – The output to get from.
  • bytes_out – Destination for the blinding public key.
  • len – Size of bytes_out in bytes.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.

Note

This operates on the PSET field PSBT_ELEMENTS_OUT_BLINDING_PUBKEY.

Returns:See Variable Length Output Buffers
int wally_psbt_output_get_blinding_public_key_len(const struct wally_psbt_output *output, size_t *written)

Get the length of the blinding public key from an output.

Parameters:
  • output – The output to get from.
  • written – Destination for the length, or zero if not present.
Returns:

See Error Codes

int wally_psbt_output_set_blinding_public_key(struct wally_psbt_output *output, const unsigned char *pub_key, size_t pub_key_len)

Set the blinding public key in an output.

Parameters:
  • output – The output to update.
  • pub_key – The blinding public key.
  • pub_key_len – Size of pub_key in bytes.
Returns:

See Error Codes

int wally_psbt_output_clear_blinding_public_key(struct wally_psbt_output *output)

Clear the blinding public key in an output.

Parameters:
  • output – The output to update.
Returns:

See Error Codes

int wally_psbt_output_get_ecdh_public_key(const struct wally_psbt_output *output, unsigned char *bytes_out, size_t len, size_t *written)

Get the ephemeral ECDH public key from an output.

Parameters:
  • output – The output to get from.
  • bytes_out – Destination for the ephemeral ECDH public key.
  • len – Size of bytes_out in bytes.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.

Note

This operates on the PSET field PSBT_ELEMENTS_OUT_ECDH_PUBKEY.

Returns:See Variable Length Output Buffers
int wally_psbt_output_get_ecdh_public_key_len(const struct wally_psbt_output *output, size_t *written)

Get the length of the ephemeral ECDH public key from an output.

Parameters:
  • output – The output to get from.
  • written – Destination for the length, or zero if not present.
Returns:

See Error Codes

int wally_psbt_output_set_ecdh_public_key(struct wally_psbt_output *output, const unsigned char *pub_key, size_t pub_key_len)

Set the ephemeral ECDH public key in an output.

Parameters:
  • output – The output to update.
  • pub_key – The ephemeral ECDH public key.
  • pub_key_len – Size of pub_key in bytes.
Returns:

See Error Codes

int wally_psbt_output_clear_ecdh_public_key(struct wally_psbt_output *output)

Clear the ephemeral ECDH public key in an output.

Parameters:
  • output – The output to update.
Returns:

See Error Codes

int wally_psbt_output_get_value_blinding_rangeproof(const struct wally_psbt_output *output, unsigned char *bytes_out, size_t len, size_t *written)

Get the asset value blinding rangeproof from an output.

Parameters:
  • output – The output to get from.
  • bytes_out – Destination for the asset value blinding rangeproof.
  • len – Size of bytes_out in bytes.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.

Note

This operates on the PSET field PSBT_ELEMENTS_OUT_BLIND_VALUE_PROOF.

Returns:See Variable Length Output Buffers
int wally_psbt_output_get_value_blinding_rangeproof_len(const struct wally_psbt_output *output, size_t *written)

Get the length of the asset value blinding rangeproof from an output.

Parameters:
  • output – The output to get from.
  • written – Destination for the length, or zero if not present.
Returns:

See Error Codes

int wally_psbt_output_set_value_blinding_rangeproof(struct wally_psbt_output *output, const unsigned char *rangeproof, size_t rangeproof_len)

Set the asset value blinding rangeproof in an output.

Parameters:
  • output – The output to update.
  • rangeproof – The asset value blinding rangeproof.
  • rangeproof_len – Size of rangeproof in bytes.
Returns:

See Error Codes

int wally_psbt_output_clear_value_blinding_rangeproof(struct wally_psbt_output *output)

Clear the asset value blinding rangeproof in an output.

Parameters:
  • output – The output to update.
Returns:

See Error Codes

int wally_psbt_output_get_asset_blinding_surjectionproof(const struct wally_psbt_output *output, unsigned char *bytes_out, size_t len, size_t *written)

Get the asset tag blinding surjection proof from an output.

Parameters:
  • output – The output to get from.
  • bytes_out – Destination for the asset tag blinding surjection proof.
  • len – Size of bytes_out in bytes.
  • written – Destination for the number of bytes written to bytes_out. Will be zero if the value is not present.

Note

This operates on the PSET field PSBT_ELEMENTS_OUT_BLIND_ASSET_PROOF.

Returns:See Variable Length Output Buffers
int wally_psbt_output_get_asset_blinding_surjectionproof_len(const struct wally_psbt_output *output, size_t *written)

Get the length of the asset tag blinding surjection proof from an output.

Parameters:
  • output – The output to get from.
  • written – Destination for the length, or zero if not present.
Returns:

See Error Codes

int wally_psbt_output_set_asset_blinding_surjectionproof(struct wally_psbt_output *output, const unsigned char *surjectionproof, size_t surjectionproof_len)

Set the asset tag blinding surjection proof in an output.

Parameters:
  • output – The output to update.
  • surjectionproof – The asset tag blinding surjection proof.
  • surjectionproof_len – Size of surjectionproof in bytes.
Returns:

See Error Codes

int wally_psbt_output_clear_asset_blinding_surjectionproof(struct wally_psbt_output *output)

Clear the asset tag blinding surjection proof in an output.

Parameters:
  • output – The output to update.
Returns:

See Error Codes

int wally_psbt_output_get_blinding_status(const struct wally_psbt_output *output, uint32_t flags, size_t *written)

Get the blinding status of an output.

Parameters:
  • output – The output to get the blinding status from.
  • flags – Flags controlling the checks to perform. Must be 0.
  • written – Destination for the blinding status: WALLY_PSET_BLINDED_NONE if unblinded, WALLY_PSET_BLINDED_REQUIRED if only the blinding public key is present, WALLY_PSET_BLINDED_FULL or WALLY_PSET_BLINDED_PARTIAL if the blinding public key and all or only some blinding fields respectively are present.

Note

Returns WALLY_ERROR if the value or asset tag blinding key is invalid.

Returns:See Error Codes
int wally_psbt_init_alloc(uint32_t version, size_t inputs_allocation_len, size_t outputs_allocation_len, size_t global_unknowns_allocation_len, uint32_t flags, struct wally_psbt **output)

Allocate and initialize a new PSBT.

Parameters:
  • version – The version of the PSBT. Must be WALLY_PSBT_VERSION_0 or WALLY_PSBT_VERSION_0.
  • inputs_allocation_len – The number of inputs to pre-allocate space for.
  • outputs_allocation_len – The number of outputs to pre-allocate space for.
  • global_unknowns_allocation_len – The number of global unknowns to allocate space for.
  • flags – Flags controlling psbt creation. Must be 0 or WALLY_PSBT_INIT_PSET.
  • output – Destination for the resulting PSBT output.
Returns:

See Error Codes

int wally_psbt_free(struct wally_psbt *psbt)

Free a PSBT allocated by wally_psbt_init_alloc.

Parameters:
  • psbt – The PSBT to free.
Returns:

See Error Codes

int wally_psbt_set_version(struct wally_psbt *psbt, uint32_t flags, uint32_t version)

Set the version for a PSBT.

Parameters:
  • psbt – The PSBT to set the version for.
  • flags – Flags controlling the version upgrade/downgrade. Must be 0.
  • version – The version to use for the PSBT. Must be WALLY_PSBT_VERSION_0 or WALLY_PSBT_VERSION_2.

Note

This call converts the PSBT in place to the specified version.

Returns:See Error Codes
int wally_psbt_get_id(const struct wally_psbt *psbt, uint32_t flags, unsigned char *bytes_out, size_t len)

Return the BIP-370 unique id of a PSBT.

Parameters:
  • psbt – The PSBT to compute the id of.
  • flagsWALLY_PSBT_ID_ flags to change the id calculation, or pass 0 to compute a BIP-370 compatible id.
  • bytes_out – Destination for the id.
  • len – Size of bytes_out. Must be WALLY_TXHASH_LEN.

Note

The id is expensive to compute.

Returns:See Error Codes
int wally_psbt_get_locktime(const struct wally_psbt *psbt, size_t *written)

Return the calculated transaction lock time of a PSBT.

Parameters:
  • psbt – The PSBT to compute the lock time of. Must be a v2 PSBT.
  • written – Destination for the calculated transaction lock time.

Note

The calculated lock time may change as the PSBT is modified.

Returns:See Error Codes
int wally_psbt_is_finalized(const struct wally_psbt *psbt, size_t *written)

Determine if all PSBT inputs are finalized.

Parameters:
  • psbt – The PSBT to check.
  • written – On success, set to one if the PSBT is finalized, otherwise zero.
Returns:

See Error Codes

int wally_psbt_set_global_tx(struct wally_psbt *psbt, const struct wally_tx *tx)

Set the global transaction for a PSBT.

Parameters:
  • psbt – The PSBT to set the transaction for.
  • tx – The transaction to set.

The global transaction can only be set on a newly created version 0 PSBT. After this call completes the PSBT will have empty inputs and outputs for each input and output in the transaction tx given.

Returns:See Error Codes
int wally_psbt_set_tx_version(struct wally_psbt *psbt, uint32_t version)

Set the transaction version for a PSBT.

Parameters:
  • psbt – The PSBT to set the transaction version for. Must be a v2 PSBT.
  • version – The version to use for the transaction. Must be at least 2.
Returns:

See Error Codes

int wally_psbt_get_tx_version(const struct wally_psbt *psbt, size_t *written)

Get the transaction version of a PSBT.

Parameters:
  • psbt – The PSBT to get the transaction version for. Must be v2 PSBT.
  • written – Destination for the PSBT’s transaction version.

Note

Returns the default version 2 if none has been explicitly set.

Returns:See Error Codes
int wally_psbt_set_fallback_locktime(struct wally_psbt *psbt, uint32_t locktime)

Set the fallback locktime for a PSBT.

Parameters:
  • psbt – The PSBT to set the fallback locktime for.
  • locktime – The fallback locktime to set.

Sets the fallback locktime field in the transaction. Cannot be set on V0 PSBTs.

Returns:See Error Codes
int wally_psbt_clear_fallback_locktime(struct wally_psbt *psbt)

Clear the fallback locktime for a PSBT.

Parameters:
  • psbt – The PSBT to update.
Returns:

See Error Codes

int wally_psbt_set_tx_modifiable_flags(struct wally_psbt *psbt, uint32_t flags)

Set the transaction modifiable flags for a PSBT.

Parameters:
  • psbt – The PSBT to set the flags for.
  • flagsWALLY_PSBT_TXMOD_ flags indicating what can be modified.
Returns:

See Error Codes

int wally_psbt_set_global_scalars(struct wally_psbt *psbt, const struct wally_map *map_in)

Set the scalar offsets in a PSBT.

Parameters:
  • psbt – The psbt to update. Must be a PSET.
  • map_in – The scalar offsets for this PSBT.
Returns:

See Error Codes

int wally_psbt_add_global_scalar(struct wally_psbt *psbt, const unsigned char *scalar, size_t scalar_len)

Add a scalar offset to a PSBT.

Parameters:
  • psbt – The PSBT to add to. Must be a PSET.
  • scalar – The scalar offset to add.
  • scalar_len – The length of the scalar offset. Must be 32.
Returns:

See Error Codes

int wally_psbt_find_global_scalar(struct wally_psbt *psbt, const unsigned char *scalar, size_t scalar_len, size_t *written)

Find a scalar offset in a PSBT.

Parameters:
  • psbt – The PSBT to find in. Must be a PSET.
  • scalar – The scalar offset to find.
  • scalar_len – The length of the scalar offset. Must be 32.
  • written – On success, set to zero if the item is not found, otherwise the index of the item plus one.
Returns:

See Error Codes

int wally_psbt_set_pset_modifiable_flags(struct wally_psbt *psbt, uint32_t flags)

Set the Elements transaction modifiable flags for a PSBT.

Parameters:
Returns:

See Error Codes

int wally_psbt_add_tx_input_at(struct wally_psbt *psbt, uint32_t index, uint32_t flags, const struct wally_tx_input *input)

Add a transaction input to a PSBT at a given position.

Parameters:
  • psbt – The PSBT to add the input to.
  • index – The zero-based index of the position to add the input at.
  • flags – Flags controlling input insertion. Must be 0 or WALLY_PSBT_FLAG_NON_FINAL.
  • input – The transaction input to add.
Returns:

See Error Codes

int wally_psbt_remove_input(struct wally_psbt *psbt, uint32_t index)

Remove a transaction input from a PSBT.

Parameters:
  • psbt – The PSBT to remove the input from.
  • index – The zero-based index of the input to remove.
Returns:

See Error Codes

int wally_psbt_add_tx_output_at(struct wally_psbt *psbt, uint32_t index, uint32_t flags, const struct wally_tx_output *output)

Add a transaction output to a PSBT at a given position.

Parameters:
  • psbt – The PSBT to add the output to.
  • index – The zero-based index of the position to add the output at.
  • flags – Flags controlling output insertion. Must be 0.
  • output – The transaction output to add.
Returns:

See Error Codes

int wally_psbt_remove_output(struct wally_psbt *psbt, uint32_t index)

Remove a transaction output from a PSBT.

Parameters:
  • psbt – The PSBT to remove the output from.
  • index – The zero-based index of the output to remove.
Returns:

See Error Codes

int wally_psbt_from_bytes(const unsigned char *bytes, size_t bytes_len, uint32_t flags, struct wally_psbt **output)

Create a PSBT from its serialized bytes.

Parameters:
  • bytes – Bytes to create the PSBT from.
  • bytes_len – Length of bytes in bytes.
  • flagsWALLY_PSBT_PARSE_FLAG_ flags controlling deserialization.
  • output – Destination for the resulting PSBT.
Returns:

See Error Codes

int wally_psbt_get_length(const struct wally_psbt *psbt, uint32_t flags, size_t *written)

Get the length of a PSBT when serialized to bytes.

Parameters:
  • psbt – the PSBT.
  • flags – Flags controlling length determination. Must be 0.
  • written – Destination for the length in bytes when serialized.
Returns:

See Error Codes

int wally_psbt_to_bytes(const struct wally_psbt *psbt, uint32_t flags, unsigned char *bytes_out, size_t len, size_t *written)

Serialize a PSBT to bytes.

Parameters:
  • psbt – the PSBT to serialize.
  • flags – Flags controlling serialization. Must be 0.
  • bytes_out – Bytes to create the transaction from.
  • len – Length of bytes in bytes (use wally_psbt_get_length).
  • written – number of bytes written to bytes_out.
Returns:

See Variable Length Output Buffers

int wally_psbt_from_base64(const char *base64, uint32_t flags, struct wally_psbt **output)

Create a PSBT from its serialized base64 string.

Parameters:
  • base64 – Base64 string to create the PSBT from.
  • flagsWALLY_PSBT_PARSE_FLAG_ flags controlling deserialization.
  • output – Destination for the resulting PSBT.
Returns:

See Error Codes

int wally_psbt_to_base64(const struct wally_psbt *psbt, uint32_t flags, char **output)

Serialize a PSBT to a base64 string.

Parameters:
  • psbt – the PSBT to serialize.
  • flags – Flags controlling serialization. Must be 0.
  • output – Destination for the resulting serialized PSBT.
Returns:

See Error Codes

int wally_psbt_combine(struct wally_psbt *psbt, const struct wally_psbt *source)

Combine the metadata from a source PSBT into another PSBT.

Parameters:
  • psbt – the PSBT to combine into.
  • source – the PSBT to copy data from.
Returns:

See Error Codes

int wally_psbt_clone_alloc(const struct wally_psbt *psbt, uint32_t flags, struct wally_psbt **output)

Clone a PSBT into a newly allocated copy.

Parameters:
  • psbt – the PSBT to clone.
  • flags – Flags controlling PSBT creation. Must be 0.
  • output – Destination for the resulting cloned PSBT.
Returns:

See Error Codes

int wally_psbt_blind(struct wally_psbt *psbt, const struct wally_map *values, const struct wally_map *vbfs, const struct wally_map *assets, const struct wally_map *abfs, const unsigned char *entropy, size_t entropy_len, uint32_t output_index, uint32_t flags, struct wally_map *output)

Blind a PSBT.

Parameters:
  • psbt – PSBT to blind. Directly modifies this PSBT.
  • values – Integer map of input index to value for the callers inputs.
  • vbfs – Integer map of input index to value blinding factor for the callers inputs.
  • assets – Integer map of input index to asset tags for the callers inputs.
  • abfs – Integer map of input index to asset blinding factors for the callers inputs.
  • entropy – Random entropy for asset and blinding factor generation.
  • entropy_len – Size of entropy in bytes. Must be a multiple of 5 * BLINDING_FACTOR_LEN for each non-fee output to be blinded, with an additional 2 * BLINDING_FACTOR_LEN bytes for any issuance outputs.
  • output_index – The zero based index of the output to blind, or WALLY_PSET_BLIND_ALL.
  • flags – Flags controlling blinding. Must be 0.
  • output – Destination for a map of integer output index to the ephemeral private key used to blind the output. Ignored if NULL.
Returns:

See Error Codes

int wally_psbt_blind_alloc(struct wally_psbt *psbt, const struct wally_map *values, const struct wally_map *vbfs, const struct wally_map *assets, const struct wally_map *abfs, const unsigned char *entropy, size_t entropy_len, uint32_t output_index, uint32_t flags, struct wally_map **output)

Blind a PSBT.

As per wally_psbt_blind, but allocates the output map.

Returns:See Error Codes
int wally_psbt_sign(struct wally_psbt *psbt, const unsigned char *key, size_t key_len, uint32_t flags)

Sign a PSBT using the simple signer algorithm.

Parameters:
  • psbt – PSBT to sign. Directly modifies this PSBT.
  • key – Private key to sign PSBT with.
  • key_len – Length of key in bytes. Must be EC_PRIVATE_KEY_LEN.
  • flags – Flags controlling signing. Must be 0 or EC_FLAG_GRIND_R.

Note

See https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#simple-signer-algorithm for a description of the simple signer algorithm.

Returns:See Error Codes
int wally_psbt_finalize(struct wally_psbt *psbt)

Finalize a PSBT.

Parameters:
  • psbt – PSBT to finalize. Directly modifies this PSBT.
Returns:

See Error Codes

int wally_psbt_extract(const struct wally_psbt *psbt, uint32_t flags, struct wally_tx **output)

Extract a network transaction from a finalized PSBT.

Parameters:
  • psbt – PSBT to extract from.
  • flags – Flags controlling signing. Must be 0 or WALLY_PSBT_EXTRACT_NON_FINAL.
  • output – Destination for the resulting transaction.
Returns:

See Error Codes

int wally_psbt_is_elements(const struct wally_psbt *psbt, size_t *written)

Determine if a PSBT is an elements PSBT.

Parameters:
  • psbt – The PSBT to check.
  • written – 1 if the PSBT is an elements PSBT, otherwise 0.
Returns:

See Error Codes