Detail bool `json:"detail"`
Unconfirmed bool `json:"unconfirmed"`
Count uint `json:"count"`
+ IsReverse bool `json:"is_reverse"`
}) Response {
accountID := filter.AccountID
if filter.AccountAlias != "" {
accountID = acc.ID
}
- transactions, err := a.wallet.GetTransactions(accountID, filter.StartTxID, filter.Count, filter.Unconfirmed)
+ transactions, err := a.wallet.GetTransactions(accountID, filter.StartTxID, filter.Count, filter.Unconfirmed, filter.IsReverse)
if err != nil {
return NewErrorResponse(err)
}
return &XPub{XPub: xpub, Alias: alias, File: file}, nil
}
+func (h *HSM) CreateKey(xprv chainkd.XPrv, alias string, auth string) (*XPub, error) {
+ xpub := xprv.XPub()
+ id := uuid.NewRandom()
+ key := &XKey{
+ ID: id,
+ KeyType: "bytom_kd",
+ XPub: xpub,
+ XPrv: xprv,
+ Alias: alias,
+ }
+
+ file := h.keyStore.JoinPath(keyFileName(key.ID.String()))
+ if err := h.keyStore.StoreKey(file, key, auth); err != nil {
+ return nil, errors.Wrap(err, "storing keys")
+ }
+ return &XPub{XPub: xpub, Alias: alias, File: file}, nil
+}
+
func (h *HSM) createChainKDKey(alias string, auth string, language string) (*XPub, *string, error) {
// Generate a mnemonic for memorization or user-friendly seeds
entropy, err := mnem.NewEntropy(EntropyLength)
}
// GetTransactions get all walletDB transactions or unconfirmed transactions, and filter transactions by accountID and StartTxID optional
-func (w *Wallet) GetTransactions(accountID string, StartTxID string, count uint, unconfirmed bool) ([]*query.AnnotatedTx, error) {
+func (w *Wallet) GetTransactions(accountID string, StartTxID string, count uint, unconfirmed bool, isReverse bool) ([]*query.AnnotatedTx, error) {
annotatedTxs := []*query.AnnotatedTx{}
var startKey []byte
preFix := TxPrefix
preFix = UnconfirmedTxPrefix
}
- itr := w.DB.IteratorPrefixWithStart([]byte(preFix), startKey, true)
+ itr := w.DB.IteratorPrefixWithStart([]byte(preFix), startKey, isReverse)
defer itr.Release()
for txNum := count; itr.Next() && txNum > 0; {
t.Fatal(err)
}
- wants, err := w.GetTransactions("", "", 100, false)
+ wants, err := w.GetTransactions("", "", 100, false, true)
if len(wants) != 1 {
t.Fatal(err)
}