Skip to content

Methods needed for Covenants in Script#3

Open
jcramer wants to merge 2 commits into
Bitcoin-com:masterfrom
jcramer:master
Open

Methods needed for Covenants in Script#3
jcramer wants to merge 2 commits into
Bitcoin-com:masterfrom
jcramer:master

Conversation

@jcramer
Copy link
Copy Markdown

@jcramer jcramer commented Jun 20, 2019

I wanted to share two methods I used for the purpose of creating a Covenant type script contract. The LastWill contract is an example that uses this preimage data within the "refresh" scriptSig.

  1. sigHashPreimageBufChunks(inIndex, prevOutScript, value, hashType) -->
[
    versionBuf,        // 4-bytes version    
    hPhSoBuf,          // 100-bytes (hashPrevouts, hashSequence, outpoint tx hash, outpoint vout)
    scriptCodeBuf,     // size varies 
    valueBuf,          // 8-bytes value
    nSequenceBuf,      // 4-bytes nSequence
    hashOutputs,       // 32-bytes hashOutputs
    tailBuf,           // 8-bytes nLockTime & sighash Type
]
  1. sigHashPreimageBuf(inIndex, prevOutScript, value, hashType) --> sigHash preimage buf

@christroutner
Copy link
Copy Markdown

These look like they are only additive changes, which removes the risk of regression bugs. This should be safe to merge.

@jcramer
Copy link
Copy Markdown
Author

jcramer commented Dec 2, 2019

@christroutner I will likely be adding some bits to this over the next few weeks. We want to have an option in the method to return the whole preimage, rather than the chunks.

@rkalis
Copy link
Copy Markdown

rkalis commented Dec 2, 2019

I like the idea of also being able to return the full preimage, but I think returning chunks is valuable too. Perhaps hPhSoBuf could be further broken up as well, in case someone might need it later on.

@jcramer
Copy link
Copy Markdown
Author

jcramer commented Dec 2, 2019

Good idea, I can have it broken up to leave it up to the consumer to combine the chunks as they wish.

I'll add a method parameter asChunks or something set to false by default so an un-chunked preimage will be returned by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants