Giter VIP home page Giter VIP logo

Comments (4)

ajtowns avatar ajtowns commented on August 24, 2024

I guess that might look something like:

taproot_message(uint8_t hash_type, uint8_t spend_type, tx, uint32_t input_index) {
  uint8_t epoch = 0;
  bm =  epoch + hash_type + tx.nVersion + tx.nLockTime
  if ((hash_type & ANYONECANPAY)== 0)  bm += sha_prevouts(tx) + sha_amounts(tx) + sha_sequences(tx);
  if ((hash_type & (NONE | SINGLE) == 0) bm += sha_outputs(tx);
  bm += spend_type + scriptPubKey(tx, input_index);
  if (hash_type & ANYONECANPAY) {
    bm += outpoint(tx,input_index) + amount(tx,input_index) + nSequence(tx,input_index);
  } else {
    bm += input_index;
  }
  if (spend_type & 1)  bm += sha_annex(tx, input_index);
  if (hash_type & SINGLE) bm += sha_single_output(tx, input_index);
  return bm;
}

tapscript_message(uint8_t hash_type, uint8_t spend_type, tx, uint32_t input_index,
  uint8_t key_version, uint32_t codeseparator_position)
{
  msg = taproot_message(hash_type, (spend_type | 0x02), tx, input_index);
  msg += tapleaf_hash + key_version + codeseparator_position;
  return msg;
}

presuming sha_annex and so on are defined in text. For anyprevout (which drops outpoint(tx,input_index) rather than just adding stuff on the end) you'd have to redefine the whole block of code that way, but that's still probably easier to follow...

from bips.

sipa avatar sipa commented on August 24, 2024

I was more thinking about keeping the existing "list of serialized fields" approach, but just separated out.

from bips.

ajtowns avatar ajtowns commented on August 24, 2024

Not quite sure that would look like, but sounds plausible

from bips.

sipa avatar sipa commented on August 24, 2024

See #186.

from bips.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.