-
Notifications
You must be signed in to change notification settings - Fork 26
/
unlocker.go
29 lines (24 loc) · 982 Bytes
/
unlocker.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package bt
import (
"context"
"github.com/libsv/go-bt/v2/bscript"
"github.com/libsv/go-bt/v2/sighash"
)
// UnlockerParams params used for unlocking an input with a `bt.Unlocker`.
type UnlockerParams struct {
// InputIdx the input to be unlocked. [DEFAULT 0]
InputIdx uint32
// SigHashFlags the be applied [DEFAULT ALL|FORKID]
SigHashFlags sighash.Flag
// TODO: add previous tx script and sats here instead of in
// input (and potentially remove from input) - see issue #143
}
// Unlocker interface to allow custom implementations of different unlocking mechanisms.
// Implement the Unlocker function as shown in LocalUnlocker, for example.
type Unlocker interface {
UnlockingScript(ctx context.Context, tx *Tx, up UnlockerParams) (uscript *bscript.Script, err error)
}
// UnlockerGetter interfaces getting an unlocker for a given output/locking script.
type UnlockerGetter interface {
Unlocker(ctx context.Context, lockingScript *bscript.Script) (Unlocker, error)
}