Skip to content

Commit

Permalink
fixup! sweeptimelockmanual: fix bug and enhance options.
Browse files Browse the repository at this point in the history
  • Loading branch information
ziggie1984 committed Jan 13, 2024
1 parent 6c57c50 commit 1855dc1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cmd/chantools/sweeptimelock.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,12 @@ func bruteForceDelay(delayPubkey, revocationPubkey *btcec.PublicKey,
return 0, nil, nil, fmt.Errorf("error hashing script: "+
"%w", err)
}

_, targetAddr, _, _ := txscript.ExtractPkScriptAddrs(targetScript, chainParams)
_, addr, _, _ := txscript.ExtractPkScriptAddrs(sh, chainParams)

log.Infof("Target address: %v, Computed Address :%v, at "+
"csv_delay=%v", targetAddr, addr, i)
if bytes.Equal(targetScript[0:8], sh[0:8]) {
return int32(i), s, sh, nil
}
Expand Down
9 changes: 8 additions & 1 deletion cmd/chantools/sweeptimelockmanual.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ func sweepTimeLockManual(extendedKey *hdkeychain.ExtendedKey, apiURL string,
commitPoint *btcec.PublicKey
)
for i := startNumChannels; i < maxNumChannels; i++ {
log.Infof("Trying RevocationRoot at %v", i)

csvTimeout, script, scriptHash, commitPoint, delayDesc, err = tryKey(
baseKey, remoteRevPoint, startCsvTimeout, maxCsvTimeout,
lockScript, uint32(i), startNumChanUpdates,
Expand All @@ -335,7 +337,8 @@ func sweepTimeLockManual(extendedKey *hdkeychain.ExtendedKey, apiURL string,
break
}

log.Infof("Tried %d of %d keys.", i+1, maxKeys)
log.Infof("Tried key %d of %d keys.", startNumChannels,
maxNumChannels)
}

// Did we find what we looked for or did we just exhaust all
Expand Down Expand Up @@ -598,13 +601,17 @@ func bruteForceDelayPoint(delayBase, revBase *btcec.PublicKey,
maxChanUpdates uint64) (int32, []byte, []byte, *btcec.PublicKey,
error) {

log.Infof("=========Different ShaRootCreation===========")

for i := startNumChanUpdates; i < maxChanUpdates; i++ {
revPreimage, err := revRoot.AtIndex(i)
if err != nil {
return 0, nil, nil, nil, err
}
commitPoint := input.ComputeCommitmentPoint(revPreimage[:])

log.Infof("CommitPoint at ChanUpdate#%v", i)

csvTimeout, script, scriptHash, err := bruteForceDelay(
input.TweakPubKey(delayBase, commitPoint),
input.DeriveRevocationPubkey(revBase, commitPoint),
Expand Down

0 comments on commit 1855dc1

Please sign in to comment.