Merge branch 'master' of li.lan:labs/plasma
This commit is contained in:
commit
a4762b818f
@ -263,12 +263,12 @@ func createCommitTx(fundingOutput *wire.TxIn, ourKey, theirKey *btcec.PublicKey,
|
|||||||
//simple and assume dual funder (with both funding above reserve)
|
//simple and assume dual funder (with both funding above reserve)
|
||||||
func createCLTVFundingTx(fundingTimeLock int64, ourKey *btcec.PublicKey, theirKey *btcec.PublicKey) (*wire.MsgTx, error) {
|
func createCLTVFundingTx(fundingTimeLock int64, ourKey *btcec.PublicKey, theirKey *btcec.PublicKey) (*wire.MsgTx, error) {
|
||||||
script := txscript.NewScriptBuilder()
|
script := txscript.NewScriptBuilder()
|
||||||
//See how many entries there are
|
//In the scriptSig on the top of the stack, there will be either a 0 or
|
||||||
//2: it's a 2-of-2 multisig
|
//1 pushed.
|
||||||
//anything else: assume it's a CLTV-timeout 1-sig only
|
//So the scriptSig will be either:
|
||||||
script.AddOp(txscript.OP_DEPTH)
|
//<BobSig> <AliceSig> <1>
|
||||||
script.AddInt64(2)
|
//<BobSig> <RevocationHash> <0>
|
||||||
script.AddOp(txscript.OP_EQUAL)
|
//(Alice and Bob can be swapped depending on who's funding)
|
||||||
|
|
||||||
//If this is a 2-of-2 multisig, read the first sig
|
//If this is a 2-of-2 multisig, read the first sig
|
||||||
script.AddOp(txscript.OP_IF)
|
script.AddOp(txscript.OP_IF)
|
||||||
|
@ -72,6 +72,12 @@ func derive(from, to uint64, startingHash [32]byte) [32]byte {
|
|||||||
|
|
||||||
numBranches := from ^ to
|
numBranches := from ^ to
|
||||||
toDerive := uint64(math.Log2(float64(numBranches))) // uh.....
|
toDerive := uint64(math.Log2(float64(numBranches))) // uh.....
|
||||||
|
// math? floats? nahhh! :) bit-flipp-y way to do it:
|
||||||
|
for toDerive = 0; numBranches>>toDerive > 0; toDerive++ {
|
||||||
|
}
|
||||||
|
// ^^^this rounds up instead of down, may be off by 1?
|
||||||
|
toDerive-- // needed?
|
||||||
|
|
||||||
for i := int(toDerive - 1); i >= 0; i-- {
|
for i := int(toDerive - 1); i >= 0; i-- {
|
||||||
if (numBranches>>uint(i))&1 == 1 {
|
if (numBranches>>uint(i))&1 == 1 {
|
||||||
// Flip the ith bit, then hash the current state to
|
// Flip the ith bit, then hash the current state to
|
||||||
|
Loading…
Reference in New Issue
Block a user