github.com/gagliardetto/solana-go@v1.11.0/rpc/getSignatureStatuses.go (about)

     1  // Copyright 2021 github.com/gagliardetto
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package rpc
    16  
    17  import (
    18  	"context"
    19  
    20  	"github.com/gagliardetto/solana-go"
    21  )
    22  
    23  // GetSignatureStatuses Returns the statuses of a list of signatures.
    24  // Unless the searchTransactionHistory configuration parameter
    25  // is included,this method only searches the recent status cache
    26  // of signatures, which retains statuses for all active slots plus
    27  // MAX_RECENT_BLOCKHASHES rooted slots.
    28  func (cl *Client) GetSignatureStatuses(
    29  	ctx context.Context,
    30  
    31  	// If true, a Solana node will search its ledger
    32  	// cache for any signatures not found in the recent status cache.
    33  	searchTransactionHistory bool,
    34  
    35  	// Transaction signatures to confirm.
    36  	transactionSignatures ...solana.Signature,
    37  ) (out *GetSignatureStatusesResult, err error) {
    38  	params := []interface{}{transactionSignatures}
    39  	if searchTransactionHistory {
    40  		params = append(params, M{"searchTransactionHistory": searchTransactionHistory})
    41  	}
    42  	err = cl.rpcClient.CallForInto(ctx, &out, "getSignatureStatuses", params)
    43  	if err != nil {
    44  		return nil, err
    45  	}
    46  	if out.Value == nil {
    47  		// Unknown transaction
    48  		return nil, ErrNotFound
    49  	}
    50  
    51  	return
    52  }
    53  
    54  type GetSignatureStatusesResult struct {
    55  	RPCContext
    56  	Value []*SignatureStatusesResult `json:"value"`
    57  }
    58  
    59  type SignatureStatusesResult struct {
    60  	// The slot the transaction was processed.
    61  	Slot uint64 `json:"slot"`
    62  
    63  	// Number of blocks since signature confirmation,
    64  	// null if rooted or finalized by a supermajority of the cluster.
    65  	Confirmations *uint64 `json:"confirmations"`
    66  
    67  	// Error if transaction failed, null if transaction succeeded.
    68  	Err interface{} `json:"err"`
    69  
    70  	// The transaction's cluster confirmation status; either processed, confirmed, or finalized.
    71  	ConfirmationStatus ConfirmationStatusType `json:"confirmationStatus"`
    72  
    73  	// DEPRECATED: Transaction status.
    74  	Status DeprecatedTransactionMetaStatus `json:"status"`
    75  }
    76  
    77  type ConfirmationStatusType string
    78  
    79  const (
    80  	ConfirmationStatusProcessed ConfirmationStatusType = "processed"
    81  	ConfirmationStatusConfirmed ConfirmationStatusType = "confirmed"
    82  	ConfirmationStatusFinalized ConfirmationStatusType = "finalized"
    83  )