* return error when sign-submit-transaction has no sign
* upgrade version
* correct the way to check sign
* Revert "correct the way to check sign"
This reverts commit
04484a82a540bf705a9ebecc8f1cdb373f98e801.
* fix the way to check sign
m.Handle("/build-transaction", jsonHandler(a.build))
m.Handle("/sign-transaction", jsonHandler(a.pseudohsmSignTemplates))
m.Handle("/submit-transaction", jsonHandler(a.submit))
+ // TODO remove this api, separate sign and submit process
m.Handle("/sign-submit-transaction", jsonHandler(a.signSubmit))
m.Handle("/get-transaction", jsonHandler(a.getTransaction))
m.Handle("/list-transactions", jsonHandler(a.listTransactions))
log "github.com/sirupsen/logrus"
+ "github.com/bytom/blockchain/pseudohsm"
"github.com/bytom/blockchain/txbuilder"
"github.com/bytom/errors"
"github.com/bytom/net/http/reqid"
// POST /sign-submit-transaction
func (a *API) signSubmit(ctx context.Context, x struct {
- Password string `json:"password"`
+ Password string `json:"password"`
Txs txbuilder.Template `json:"transaction"`
}) Response {
if err := txbuilder.Sign(ctx, &x.Txs, nil, x.Password, a.pseudohsmSignTemplate); err != nil {
log.WithField("build err", err).Error("fail on sign transaction.")
return NewErrorResponse(err)
}
+
+ if signCount, complete := txbuilder.SignInfo(&x.Txs); !complete && signCount == 0 {
+ return NewErrorResponse(pseudohsm.ErrLoadKey)
+ }
log.Info("Sign Transaction complete.")
txID, err := a.submitSingle(nil, &x.Txs)
return
}
+// SignInfo
+func SignInfo(txTemplate *Template) (int, bool) {
+ var count int
+ for _, sigInst := range txTemplate.SigningInstructions {
+ for _, wc := range sigInst.WitnessComponents {
+ switch sw := wc.(type) {
+ case *SignatureWitness:
+ if count = signedCount(sw.Sigs); count < sw.Quorum {
+ return count, false
+ }
+ case *RawTxSigWitness:
+ if count = signedCount(sw.Sigs); count < sw.Quorum {
+ return count, false
+ }
+ }
+ }
+ }
+ return count, true
+}
+
// SignProgress check is all the sign requirement are satisfy
func SignProgress(txTemplate *Template) bool {
for _, sigInst := range txTemplate.SigningInstructions {
var (
// The full version string
- Version = "0.4.5"
+ Version = "0.4.6"
// GitCommit is set with --ldflags "-X main.gitCommit=$(git rev-parse HEAD)"
GitCommit string
)