OSDN Git Service

feat(federation): add /get-fed-info api (#228)
[bytom/vapor.git] / api / query.go
index 7f29e07..938b3d3 100644 (file)
@@ -108,6 +108,26 @@ func (a *API) listBalances(ctx context.Context, filter struct {
        return NewSuccessResponse(balances)
 }
 
+func (a *API) listAccountVotes(ctx context.Context, filter struct {
+       AccountID    string `json:"account_id"`
+       AccountAlias string `json:"account_alias"`
+}) Response {
+       accountID := filter.AccountID
+       if filter.AccountAlias != "" {
+               acc, err := a.wallet.AccountMgr.FindByAlias(filter.AccountAlias)
+               if err != nil {
+                       return NewErrorResponse(err)
+               }
+               accountID = acc.ID
+       }
+
+       votes, err := a.wallet.GetAccountVotes(accountID, "")
+       if err != nil {
+               return NewErrorResponse(err)
+       }
+       return NewSuccessResponse(votes)
+}
+
 // POST /get-transaction
 func (a *API) getTransaction(ctx context.Context, txInfo struct {
        TxID string `json:"tx_id"`
@@ -201,7 +221,9 @@ func (a *API) getUnconfirmedTx(ctx context.Context, filter struct {
        resOutID := txDesc.Tx.ResultIds[0]
        resOut := txDesc.Tx.Entries[*resOutID]
        switch out := resOut.(type) {
-       case *bc.Output:
+       case *bc.IntraChainOutput:
+               tx.MuxID = *out.Source.Ref
+       case *bc.VoteOutput:
                tx.MuxID = *out.Source.Ref
        case *bc.Retirement:
                tx.MuxID = *out.Source.Ref
@@ -291,7 +313,7 @@ func (a *API) listUnspentOutputs(ctx context.Context, filter struct {
                }
                accountID = acc.ID
        }
-       accountUTXOs := a.wallet.GetAccountUtxos(accountID, filter.ID, filter.Unconfirmed, filter.SmartContract)
+       accountUTXOs := a.wallet.GetAccountUtxos(accountID, filter.ID, filter.Unconfirmed, filter.SmartContract, false)
 
        UTXOs := []query.AnnotatedUTXO{}
        for _, utxo := range accountUTXOs {