code: func (idx *AddrIndex) indexPkScript(data writeIndexData, pkScript []byte, txIdx int) {
  	// Nothing to index if the script is non-standard or otherwise doesn't
  	// contain any addresses.
  	_, addrs, _, err := txscript.ExtractPkScriptAddrs(pkScript,
  		idx.chainParams)
  	if err != nil || len(addrs) == 0 {
  		return
  	}
  
  	for _, addr := range addrs {
  		addrKey, err := addrToKey(addr)
  		if err != nil {
  			// Ignore unsupported address types.
  			continue
  		}
  
  		// Avoid inserting the transaction more than once.  Since the
  		// transactions are indexed serially any duplicates will be
  		// indexed in a row, so checking the most recent entry for the
  		// address is enough to detect duplicates.
  		indexedTxns := data[addrKey]
  		numTxns := len(indexedTxns)
  		if numTxns > 0 && indexedTxns[numTxns-1] == txIdx {
  			continue
  		}
  		indexedTxns = append(indexedTxns, txIdx)
  		data[addrKey] = indexedTxns
  	}
  }
docs: // indexPkScript extracts all standard addresses from the passed public key
  // script and maps each of them to the associated transaction using the passed
  // map.