hsd icon indicating copy to clipboard operation
hsd copied to clipboard

feature request: covenant library helper functions

Open pinheadmz opened this issue 2 years ago • 1 comments

Replaces https://github.com/handshake-org/hsd/issues/619

For library users I think we can make covenants easier to navigate. For example, we could add getters for all the covenant items:

nameHash
height
renewalBlock
resource
rawName
addressVersion
addressHash

Example:

// OPEN
const rawName = tx.output[0].covenant.rawName;

// "proofofconcept"
console.log(rawName)

Getter functions could throw or return null if a datum is requested that is not part of that covenant's items. Setters could be interesting too, or even "options" functions like:

covenant.makeOpen({
  nameHash,
  height
})

pinheadmz avatar Mar 22 '22 00:03 pinheadmz

This would be really useful. Currently I have to keep a tab open for https://github.com/namebasehq/handshake-types to look at indexes and figure out how to parse it every time.

rithvikvibhu avatar Mar 22 '22 04:03 rithvikvibhu