"context"
"encoding/json"
+ log "github.com/sirupsen/logrus"
+
"github.com/bytom/crypto/ed25519/chainkd"
"github.com/bytom/crypto/sha3pool"
chainjson "github.com/bytom/encoding/json"
)
type (
+ // SignatureWitness is a sign struct
SignatureWitness struct {
// Quorum is the number of signatures required.
Quorum int `json:"quorum"`
}
)
+// ErrEmptyProgram is a type of error
var ErrEmptyProgram = errors.New("empty signature program")
// Sign populates sw.Sigs with as many signatures of the predicate in
// - the mintime and maxtime of the transaction (if non-zero)
// - the outputID and (if non-empty) reference data of the current input
// - the assetID, amount, control program, and (if non-empty) reference data of each output.
-func (sw *SignatureWitness) sign(ctx context.Context, tpl *Template, index uint32, xpubs []chainkd.XPub, auth []string, signFn SignFunc) error {
+func (sw *SignatureWitness) sign(ctx context.Context, tpl *Template, index uint32, xpubs []chainkd.XPub, auth string, signFn SignFunc) error {
// Compute the predicate to sign. This is either a
// txsighash program if tpl.AllowAdditional is false (i.e., the tx is complete
// and no further changes are allowed) or a program enforcing
for i, p := range keyID.DerivationPath {
path[i] = p
}
- sigBytes, err := signFn(ctx, keyID.XPub, path, h, auth[i])
+ sigBytes, err := signFn(ctx, keyID.XPub, path, h, auth)
if err != nil {
- return errors.WithDetailf(err, "computing signature %d", i)
+ log.WithField("err", err).Warningf("computing signature %d", i)
+ return nil
}
sw.Sigs[i] = sigBytes
}
return nil
}
+// MarshalJSON convert struct to json
func (sw SignatureWitness) MarshalJSON() ([]byte, error) {
obj := struct {
Type string `json:"type"`