OSDN Git Service

rename (#465)
[bytom/vapor.git] / blockchain / txbuilder / rawtxsig_witness.go
index 85caa94..1bc6b84 100644 (file)
@@ -6,8 +6,7 @@ import (
 
        log "github.com/sirupsen/logrus"
 
-       "github.com/vapor/crypto/ed25519/chainkd"
-       chainjson "github.com/vapor/encoding/json"
+       chainjson "github.com/bytom/vapor/encoding/json"
 )
 
 // TODO(bobg): most of the code here is duplicated from
@@ -41,7 +40,7 @@ func (sw *RawTxSigWitness) sign(ctx context.Context, tpl *Template, index uint32
                }
                sigBytes, err := signFn(ctx, keyID.XPub, path, tpl.Hash(index).Byte32(), auth)
                if err != nil {
-                       log.WithField("err", err).Warningf("computing signature %d", i)
+                       log.WithFields(log.Fields{"module": logModule, "err": err}).Warningf("computing signature %d", i)
                        continue
                }
 
@@ -54,35 +53,7 @@ func (sw *RawTxSigWitness) sign(ctx context.Context, tpl *Template, index uint32
        return nil
 }
 
-func (sw *RawTxSigWitness) Sign(tpl *Template, index uint32, xprv chainkd.XPrv) error {
-       if len(sw.Sigs) < len(sw.Keys) {
-               // Each key in sw.Keys may produce a signature in sw.Sigs. Make
-               // sure there are enough slots in sw.Sigs and that we preserve any
-               // sigs already present.
-               newSigs := make([]chainjson.HexBytes, len(sw.Keys))
-               copy(newSigs, sw.Sigs)
-               sw.Sigs = newSigs
-       }
-       for i, keyID := range sw.Keys {
-               if len(sw.Sigs[i]) > 0 {
-                       // Already have a signature for this key
-                       continue
-               }
-               if keyID.XPub.String() != xprv.XPub().String() {
-                       continue
-               }
-               data := tpl.Hash(index).Byte32()
-               sigBytes := xprv.Sign(data[:])
-               // This break is ordered to avoid signing transaction successfully only once for a multiple-sign account
-               // that consist of different keys by the same password. Exit immediately when the signature is success,
-               // it means that only one signature will be successful in the loop for this multiple-sign account.
-               sw.Sigs[i] = sigBytes
-               break
-       }
-       return nil
-}
-
-func (sw RawTxSigWitness) Materialize(args *[][]byte) error {
+func (sw RawTxSigWitness) materialize(args *[][]byte) error {
        var nsigs int
        for i := 0; i < len(sw.Sigs) && nsigs < sw.Quorum; i++ {
                if len(sw.Sigs[i]) > 0 {