nextAccountIndex := m.getNextXpubsIndex(xpubs)
- id, signer, err := signers.Create("account", xpubs, quorum, nextAccountIndex)
+ signer, err := signers.Create("account", xpubs, quorum, nextAccountIndex)
+ id := signers.IDGenerate()
if err != nil {
return nil, errors.Wrap(err)
}
return nil, errors.Wrap(err, "get asset index error")
}
- _, assetSigner, err := signers.Create("asset", xpubs, quorum, *nextAssetIndex)
+ assetSigner, err := signers.Create("asset", xpubs, quorum, *nextAssetIndex)
if err != nil {
return nil, err
}
}
// Create creates and stores a Signer in the database
-func Create(signerType string, xpubs []chainkd.XPub, quorum int, keyIndex uint64) (string, *Signer, error) {
+func Create(signerType string, xpubs []chainkd.XPub, quorum int, keyIndex uint64) (*Signer, error) {
if len(xpubs) == 0 {
- return "", nil, errors.Wrap(ErrNoXPubs)
+ return nil, errors.Wrap(ErrNoXPubs)
}
sort.Sort(sortKeys(xpubs)) // this transforms the input slice
for i := 1; i < len(xpubs); i++ {
if bytes.Equal(xpubs[i][:], xpubs[i-1][:]) {
- return "", nil, errors.WithDetailf(ErrDupeXPub, "duplicated key=%x", xpubs[i])
+ return nil, errors.WithDetailf(ErrDupeXPub, "duplicated key=%x", xpubs[i])
}
}
if quorum == 0 || quorum > len(xpubs) {
- return "", nil, errors.Wrap(ErrBadQuorum)
+ return nil, errors.Wrap(ErrBadQuorum)
}
- id := IDGenerate()
- return id, &Signer{
+ return &Signer{
Type: signerType,
XPubs: xpubs,
Quorum: quorum,